curate-agent-memory
Skill2 starsChanged 18 days agoMITView on GitHub
Audit and clean up Claude Code auto-memory for a project: find stale, duplicated, or misplaced memories, move durable rules to their proper home, and apply only the changes the user approves. Use it when asked to review, tidy, or prune a project's memories.
In this repository30 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- audit-repositorySkill
- change-skillSkill
- evaluate-skillSkill
- implement-changeSkill
- review-repositorySkill
- runtime-canarySkill
- shepherd-pull-requestsSkill
- audit-repositorySkill
- change-skillSkill
- evaluate-skillSkill
- implement-changeSkill
- review-repositorySkill
- runtime-canarySkill
- shepherd-pull-requestsSkill
- audit-ai-configSkill
- audit-skillSkill
- dotnet-dependenciesSkill
- dotnet-formatSkill
- ejryan89-code-review-coreSkill
- ejryan89-skill-coreSkill
- flag-review-findingSkill
- github-activity-reportSkill
- repo-cleanupSkill
- review-documentSkill
- review-insightsSkill
- review-prsSkill
- update-coding-agent-skillsSkill
- update-pr-dashboardSkill
The file
We split this skill into the rules it gives an agent
5 rules. About 0 are common, 1 is distinctive, and 4 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 17
Memory directory: use --memory-dir when given.
- Very specific: line 68
Ask which groups to apply with a multi-select AskUserQuestion, one option per non-empty group.
- Very specific: line 73
Only then delete or rewrite the memories those changes cover.
- Very specific: line 81
When any memory changed or the "Rebuild index" group was approved, rebuild MEMORY.md last instead of editing it by hand:
- Distinctive: line 88
Do not commit, push, or open pull requests.
≈ “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.
Files
Curate agent memory
Memory is for facts about the user and their work that nothing else records. Rules that belong to a repository, a skill, or the user's global instructions drift out of sync when they live only in memory. This skill finds those, proposes where each belongs, and changes nothing without approval.
Step 1: Resolve the memory directory
Everything later deletes or rewrites files, so the target must be the store Claude Code actually uses.
- Repository: the argument, else the current Git repository root. Worktrees of one repository share a single store.
Memory directory: use
--memory-dirwhen given. Otherwise resolve it. The command below resolves it for the current repository; when the user named another repository, add--repo "<repository>":{{PYTHON}} -B "${CLAUDE_SKILL_DIR}/scripts/memory_audit.py" resolveIt prints
REPO <root>, the repository to use from here on; thenMEMORY_DIR <path>,SOURCE <where it came from>,EXISTS yesorEXISTS no, andREFUSED <reason>when the later steps would refuse that directory, orNO_MEMORY_DIRwhen no usable directory resolves; aCANDIDATE <dir>line for each other memory directory it found when no usable one resolved; and aNOTEline for each caveat, such as the--settingslaunch flag it cannot see.FAILED not inside a Git repositorymeans you must pass--repo; aFAILEDline namingCLAUDE_CONFIG_DIR,USERPROFILE, orHOMEas not an absolute path means the user must set that variable as the line says; any otherFAILED <reason>means git could not read the repository, or a settings file it names could not be read. Either way, show it and stop.- On
NO_MEMORY_DIR,EXISTS no, orREFUSED, show the reason and notes, list theCANDIDATElines, and ask the user to choose or supply--memory-dir. Never guess. - Show the user the resolved directory and its source, and get explicit confirmation before continuing.
Step 2: Run the mechanical audit
{{PYTHON}} -B "${CLAUDE_SKILL_DIR}/scripts/memory_audit.py" audit --memory-dir "<memory dir>" --repo "<repository>"It prints REPORT <path>, a new JSON file in the system temporary directory; read that file. FAILED <reason> means it wrote no report; show the reason, which may name a variable to set, as in Step 1. A FAILED <memory dir> ... line means the later steps would refuse the directory too, so go back to Step 1 before changing anything. Its overlaps (up to three passages in the repository's or the user's guidance per memory, with overlaps_omitted counting any more it left out) are candidates only; the script cannot tell whether a passage states the same rule. Each cited path gives "exists": true or false for a path that is there or is not; "exists": null with an "unreadable" reason means the path could not be examined, which is no evidence that it is gone: report it as unreadable, and never take the memory for obsolete on it.
Step 3: Verify and classify every memory
Read every memory file in full, in one turn as parallel calls, and every overlapping passage in context. Memories are point-in-time notes, so check any claim about code, paths, or configuration by searching the current files with Grep before relying on it.
Assign each memory exactly one outcome, with a one-line reason and evidence (file:line for anything that exists elsewhere):
| Outcome | When |
| Keep | A personal preference, identity detail, or fact about the user's work that nothing else records. |
| Delete: obsolete | It describes something that no longer exists or no longer applies. |
| Delete: already covered | Its destination already states the same rule. Cite the passage; similar wording is not enough. |
| Merge | It overlaps other memories; name the survivor and show the merged text. |
| Move to global instructions | A rule the user wants in every repository. |
| Move to repository guidance | A convention for everyone working in this repository (CLAUDE.md, coding guidelines, contributor docs). |
| Move to a skill | A rule about how a specific skill must behave; the destination is a file skill-source prints (below). |
| Record as a review finding | A correction to an automated reviewer's findings rather than a preference. Use flag-review-finding when it is available. |
For a move to a skill, find the file to edit. Add --repo "<repository>" as in Step 1, or pass --file "<path>" in place of the name to check a source file the user names:
{{PYTHON}} -B "${CLAUDE_SKILL_DIR}/scripts/memory_audit.py" skill-source "<skill>"It prints SKILL_FILE <path> for each source of the skill: the checkout the deployer installed it from, and a project skill in the repository. Never edit a deployed copy under a skills directory: the deployer then stops updating that skill, and the next audit never sees the rule. A NOTE line names a file it passed over. When it ends with FAILED <reason>, show the reason; the outcome is Keep unless the user names a source file that --file accepts.
A memory whose rule is not yet at its destination is never simply deleted. Its outcome is the move, and the memory is deleted only after the destination change is applied. If the user declines the move, keep the memory. Record nothing about deferrals; the next run checks again.
Fix mechanical problems from Step 2 as part of the relevant outcome: repair or remove broken links, and bring an index that is over or near its load limit back under it by merging or moving entries. Memories missing from the index, entries whose file is gone, and duplicate entries form one "Rebuild index" group rather than per-memory outcomes. Show each unreadable entry with its reason; it is the user's to resolve.
Step 4: Get approval by group
Present the proposal grouped by outcome, headed by the memory directory it applies to, one line per memory: file, outcome, reason, evidence. For every move, show the exact text that would be added and where.
Ask which groups to apply with a multi-select AskUserQuestion, one option per non-empty group. Offer to review a group item by item when the user wants to exclude individual memories. Apply nothing that was not approved.
Step 5: Apply the approved changes
- Change destination files first with
Edit, reading each before changing it and keeping its existing style and structure. Never replace a whole existing file. Only then delete or rewrite the memories those changes cover. When rewriting one, keep its frontmatter
nameanddescriptionaccurate: the index is built from them. Delete approved memories by file name, never with another command:{{PYTHON}} -B "${CLAUDE_SKILL_DIR}/scripts/memory_audit.py" delete --memory-dir "<memory dir>" "<file>.md" ...It prints
DELETED <file>for each file it deletes. A loneFAILED <memory dir> ...line, here or fromreindex, means the directory holds noMEMORY.mdor lies inside a skills directory, so it changed nothing; show it and go back to Step 1.FAILED <file>: <reason>lines with noDELETEDline mean it refused those names and deleted nothing; show the reasons and fix the list. AFAILEDline afterDELETEDlines means the deletion stopped part way: theDELETEDfiles are gone and the rest remain, so show the reason and rerun with the remaining files.- For review findings, invoke
flag-review-findingthrough theSkilltool with the memory's substance; delete the memory the same way once the finding is recorded. When any memory changed or the "Rebuild index" group was approved, rebuild
MEMORY.mdlast instead of editing it by hand:{{PYTHON}} -B "${CLAUDE_SKILL_DIR}/scripts/memory_audit.py" reindex --memory-dir "<memory dir>" --writeIt writes the index from the memory files and prints
WROTE <path>, orUNCHANGED;WOULD_WRITE <path>means--writewas left off, so run it again as shown. It first prints oneINDEX_LINE <file>per entry of the index, in its order, which needs no report; report itsDROPPED,ADDED, andUNREADABLElines; anUNREADABLEentry is the user's to resolve.OVER_LIMIT(it still writes the index) orNEAR_LIMITmeans the index still needs merging or moving entries. A lastFAILED <reason>means it could not read a memory or write the index; show the reason.- Do not commit, push, or open pull requests; report which repository files changed so the user can review them, and that a change to a skill's source reaches the deployed skill at its next deployment.
Step 6: Re-audit and report
Rerun Step 2. Report what changed per outcome, any destination files edited, and anything the audit still flags. Everything left should be a memory you deliberately kept.
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
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.

