agentleFS
cerebrocybersolutionscerebrocybersolutions/libro/skills/memory-attribution-lint/SKILL.md

memory-attribution-lint

Skill1 starsChanged 39 days agoApache-2.0View on GitHub

Validate and auto-inject the 11-key provenance frontmatter contract on memory files at write time. Use when authoring memory entries, running lint passes on memory directories, or backfilling missing attribution fields. Enforces a uniform provenance schema (name, description, type, source_surface, host, tool, session_id, written_at_utc, source_path, confidence, lifecycle) so every memory entry is traceable to its origin surface, tool, and session.

The file

We split this skill into the rules it gives an agent

1 rule. About 0 are common, 0 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Write-time validator + auto-injector for memory file frontmatter.

    line 14

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

memory-attribution-lint

Write-time validator + auto-injector for memory file frontmatter. Enforces an 11-key provenance contract on .md files in memory directories. Closes the "where did this memory come from?" gap by capturing source surface, tool, host, and session at write time.

Why provenance matters

Memory entries accumulate across sessions, tools, and surfaces. Without provenance, stale or contradictory entries are hard to triage. The 11-key contract gives every memory file a complete audit trail: who wrote it, from what tool, on what host, in what session, at what time, with what confidence, and at what lifecycle stage.

Contract

Required frontmatter keys:

KeySourceAuto-derived
nameauthorNO
descriptionauthorNO
typeauthor (user/feedback/project/reference)NO
source_surfaceenv CLAUDE_SURFACE or defaultYES
hostsocket.gethostname()YES
toolenv CLAUDE_TOOL or default unknownYES
session_idenv CLAUDE_SESSION_ID or unknownYES
written_at_utcdatetime.now(timezone.utc).isoformat()YES
source_pathauthor declaresNO
confidenceauthor: high/med/lowNO
lifecycleauthor: pinned/active/archived/closed/superseded/stale-by:YYYY-MM-DDNO

Scripts

  • scripts/lint.py: validate + auto-inject; exit 0=pass, 1=blocked, 2=injected
  • scripts/backfill.py: bulk backfill existing memory files
  • scripts/tests/fixtures/: golden samples for validation cases

Invocation

# Validate single file
python3 scripts/lint.py path/to/memory.md

# Dry-run (report only)
python3 scripts/lint.py --dry-run path/to/memory.md

# Backfill all memory dirs
python3 scripts/backfill.py --dry-run
python3 scripts/backfill.py --execute

Hook wire (PreToolUse)

See .claude/settings.json hooks.PreToolUse → Write/Edit matching **/memory/*.md. The hook fires lint on any Write/Edit to a file matching the pattern; exit 1 blocks the write until missing required keys are supplied, exit 2 auto-injects derivable keys and allows the write to proceed.

Environment variables consumed

VariablePurposeDefault if unset
CLAUDE_SURFACETool surface label (cc / hermes / etc.)unknown
CLAUDE_TOOLSpecific tool that initiated the writeunknown
CLAUDE_SESSION_IDSession identifier for cross-referenceunknown

Set these at session start to capture full provenance automatically. Without them, the required keys still pass validation (defaulted to unknown) but lose audit value.

Scope Contract (Least-Privilege)

DimensionScope
Read pathsAny .md file passed as target argument
Write pathsSame file (auto-inject mode only); never writes outside target
MCP / tool surfaceNone — pure Python, stdlib only
Network egressNone
SurfaceAny (hook fires at write-time regardless of surface)
CredentialsNone
Escalation triggerExit 1 (blocked write) — operator must add missing required keys manually

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.