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 which of a project's memories are stale, out of date, or repeated, or to review, tidy, or prune them; not to save a new memory.
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Curate Agent Memory?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/ejryan89-curate-agent-memory)
---
name: curate-agent-memory
description: "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 which of a project's memories are stale, out of date, or repeated, or to review, tidy, or prune them; not to save a new memory."
argument-hint: "[repository path] [--memory-dir DIR]"
allowed-tools: ["Bash({{PYTHON}} -B \"${CLAUDE_SKILL_DIR}/scripts/memory_audit.py\" *)", "PowerShell({{PYTHON}} -B \"${CLAUDE_SKILL_DIR}/scripts/memory_audit.py\" *)", "Read", "Edit", "Grep", "AskUserQuestion", "Skill"]
---
# 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-dir` when given. Otherwise resolve it. The command below resolves it for the current repository; when the user named another repository, add `--repo "<repository>"`:
```bash
{{PYTHON}} -B "${CLAUDE_SKILL_DIR}/scripts/memory_audit.py" resolve
```
It prints `REPO <root>`, the repository to use from here on; then `MEMORY_DIR <path>`, `SOURCE <where it came from>`, `EXISTS no` only when nothing is at that path or `EXISTS yes` when anything is, and `REFUSED <reason>` when the later steps would refuse what is there, a file in the folder's place or a path that cannot be examined included, or `NO_MEMORY_DIR` when no usable directory resolves; a `CANDIDATE <dir>` line for each other memory directory it found when no usable one resolved; and a `NOTE` line for each caveat, such as the `--settings` launch flag it cannot see. A `FAILED <reason>` line names its own reason and any remedy, such as passing `--repo` or setting a variable; show it and stop.
- On `NO_MEMORY_DIR`, `EXISTS no`, or `REFUSED`, show the reason and notes, list the `CANDIDATE` lines, and ask the user to choose or supply `--memory-dir`. Something is at a `REFUSED` path, so never report it as missing. Never guess.
- Show the user the resolved directory and its source, and get explicit confirmation before continuing.
## Step 2: Run the mechanical audit
```bash
{{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 it, as in Step 1. The one exception, `FAILED the audit report <path> is made, but <copy> ...`, means the report is whole: read it, and tell the user the leftover copy it names can be deleted. A `FAILED <memory dir> ...` or `FAILED memory directory ...` line names why the directory cannot be used, and the later steps would refuse it too, so go back to Step 1 before changing anything. A `FAILED repository ...` or `FAILED user directory ...` line means the `--repo` or `--user-dir` it was given is no folder; show it and rerun with the repository Step 1 printed. 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:
```bash
{{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, or says no project skill was looked for because git could not read the repository. 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 `name` and `description` accurate: the index is built from them. Delete approved memories by file name, never with another command:
```bash
{{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 lone `FAILED <memory dir> ...` or `FAILED memory directory ...` line, here or from `reindex`, names why the directory cannot be used, and nothing changed; show it and go back to Step 1. `FAILED <file>: <reason>` lines with no `DELETED` line mean it refused those names and deleted nothing; show the reasons and fix the list. A `FAILED` line after `DELETED` lines means the deletion stopped part way: the `DELETED` files are gone and the rest remain, so show the reason and rerun with the remaining files.
- For review findings, invoke `flag-review-finding` through the `Skill` tool 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.md` last instead of editing it by hand:
```bash
{{PYTHON}} -B "${CLAUDE_SKILL_DIR}/scripts/memory_audit.py" reindex --memory-dir "<memory dir>" --write
```
It writes the index from the memory files and prints `WROTE <path>`, or `UNCHANGED`; `WOULD_WRITE <path>` means `--write` was left off, so run it again as shown. It first prints one `INDEX_LINE <file>` per entry of the index, in its order, which needs no report; report its `DROPPED`, `ADDED`, and `UNREADABLE` lines; an `UNREADABLE` entry is the user's to resolve. `OVER_LIMIT` (it still writes the index) or `NEAR_LIMIT` means the index still needs merging or moving entries. A last `FAILED <reason>` names why it wrote no index; show it.
- 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.