Prune Memory
Audit the per-project memory directory and remove entries that no longer reflect reality. Suggest-only: surface candidates with reasons, confirm before touching files, never rewrite memory bodies.
Locate the memory directory
Derive from the current working directory: replace every / with -, prepend ~/.claude/projects/, append /memory/. Example: /Users/jenc/code/agent-skills → ~/.claude/projects/-Users-jenc-code-agent-skills/memory/.
If the directory is missing or empty, report and stop. If MEMORY.md is absent but memory files exist, flag the index drift first.
Workflow
- Inventory. List
*.md files in the memory dir and read MEMORY.md. Read every memory file in full — they are small.
- Classify each memory by frontmatter
metadata.type (user, feedback, project, reference). Different types decay at different rates (see Bias by type below).
- Extract concrete claims from each memory body — file paths in backticks, function/symbol names, flag/env-var names, dates (
YYYY-MM-DD), external URLs, person names, ticket IDs.
- Verify against current state using one tool call per claim type:
- File path →
Read or ls; gone → stale.
- Symbol / flag →
Grep across the repo; zero hits → stale.
- Date → compare to today; past → stale if the memory's premise was the date.
- URL → leave alone (not the agent's job to fetch).
- Cross-check the index. Files not listed in
MEMORY.md → orphaned file. MEMORY.md entries pointing at missing files → orphaned link.
- Find duplicates by frontmatter
description overlap and body subject. Two memories on the same rule → propose keeping the more specific / more recent one.
- Group findings into a single report:
dead-reference — cites artifact that no longer exists
past-dated — project memory whose premise (deadline, freeze, sprint) has passed
orphaned — file ↔ index mismatch
duplicate — overlapping subject with another memory
contradicted — body claims X, current code does not-X (only flag when confidence is high)
- Confirm per item. Present each candidate with: path, type, one-line rationale, suggested action (delete / unlink from index / keep). Ask the user to approve, skip, or batch-approve a category. Default action on skip is keep.
- Apply approved actions. For deletes: remove the file and the matching line in
MEMORY.md. For index repairs: Edit MEMORY.md to add or remove the pointer. Never rewrite memory bodies — that is out of scope.
- Report.
Reviewed N, pruned M, kept N-M. <one line per pruned file>.
Bias by type
feedback and user memories are durable — only prune on dead-reference or duplicate. Personal preferences and rules do not expire just because a file moved.
project memories decay fast — past-dated, contradicted, and dead-reference all apply. Most pruning targets live here.
reference memories — verify URLs/paths still resolve in name only (does the file/dir exist); do not fetch.
What you must NOT do
- Do not edit memory bodies. If a memory needs an update, flag it for the user; auto-save will fix it next time the underlying fact is observed.
- Do not delete
MEMORY.md itself, even if empty.
- Do not prune memories that reference external projects or systems just because they are not in the current repo —
reference memories often point off-repo on purpose.
- Do not consolidate by merging two memories into one; that is rewriting.
- Do not act without per-item confirmation, except for the bulk-approve path the user explicitly chooses.
Final assistant-message summary
Memory pruned: <M>/<N> reviewed.
- <path>: <category> — <one-line reason>
- <path>: <category> — <one-line reason>
Index updated: MEMORY.md (<+a/-b> lines).
Kept: <N-M> (no action needed or user declined).
If nothing was prunable, say so and list the categories you checked.
1---2name: prune-memory3description: Audit the current project's memory store (`~/.claude/projects/<encoded-cwd>/memory/`) and prune memories that no longer match the project state — dead file/function/flag references, past-dated project memories, orphaned index entries, and duplicates. Suggests candidates with rationale and requires per-item confirmation before deleting; does not edit memory bodies. Use when the user says "prune memory", "clean up memory", "audit memory", "memory is stale", "remove old memories", or invokes /prune-memory.4---56# Prune Memory78Audit the per-project memory directory and remove entries that no longer reflect reality. Suggest-only: surface candidates with reasons, confirm before touching files, never rewrite memory bodies.910## Locate the memory directory1112Derive from the current working directory: replace every `/` with `-`, prepend `~/.claude/projects/`, append `/memory/`. Example: `/Users/jenc/code/agent-skills` → `~/.claude/projects/-Users-jenc-code-agent-skills/memory/`.1314If the directory is missing or empty, report and stop. If `MEMORY.md` is absent but memory files exist, flag the index drift first.1516## Workflow17181. **Inventory.** List `*.md` files in the memory dir and read `MEMORY.md`. Read every memory file in full — they are small.192. **Classify each memory** by frontmatter `metadata.type` (`user`, `feedback`, `project`, `reference`). Different types decay at different rates (see *Bias by type* below).203. **Extract concrete claims** from each memory body — file paths in backticks, function/symbol names, flag/env-var names, dates (`YYYY-MM-DD`), external URLs, person names, ticket IDs.214. **Verify against current state** using one tool call per claim type:22 - File path → `Read` or `ls`; gone → stale.23 - Symbol / flag → `Grep` across the repo; zero hits → stale.24 - Date → compare to today; past → stale if the memory's premise was the date.25 - URL → leave alone (not the agent's job to fetch).265. **Cross-check the index.** Files not listed in `MEMORY.md` → orphaned file. `MEMORY.md` entries pointing at missing files → orphaned link.276. **Find duplicates** by frontmatter `description` overlap and body subject. Two memories on the same rule → propose keeping the more specific / more recent one.287. **Group findings** into a single report:29 - `dead-reference` — cites artifact that no longer exists30 - `past-dated` — project memory whose premise (deadline, freeze, sprint) has passed31 - `orphaned` — file ↔ index mismatch32 - `duplicate` — overlapping subject with another memory33 - `contradicted` — body claims X, current code does not-X (only flag when confidence is high)348. **Confirm per item.** Present each candidate with: path, type, one-line rationale, suggested action (delete / unlink from index / keep). Ask the user to approve, skip, or batch-approve a category. Default action on skip is *keep*.359. **Apply approved actions.** For deletes: remove the file *and* the matching line in `MEMORY.md`. For index repairs: `Edit` `MEMORY.md` to add or remove the pointer. Never rewrite memory bodies — that is out of scope.3610. **Report.** `Reviewed N, pruned M, kept N-M. <one line per pruned file>.`3738## Bias by type3940- `feedback` and `user` memories are durable — only prune on **dead-reference** or **duplicate**. Personal preferences and rules do not expire just because a file moved.41- `project` memories decay fast — past-dated, contradicted, and dead-reference all apply. Most pruning targets live here.42- `reference` memories — verify URLs/paths still resolve in name only (does the file/dir exist); do not fetch.4344## What you must NOT do4546- Do not edit memory bodies. If a memory needs an update, flag it for the user; auto-save will fix it next time the underlying fact is observed.47- Do not delete `MEMORY.md` itself, even if empty.48- Do not prune memories that reference *external* projects or systems just because they are not in the current repo — `reference` memories often point off-repo on purpose.49- Do not consolidate by merging two memories into one; that is rewriting.50- Do not act without per-item confirmation, except for the bulk-approve path the user explicitly chooses.5152## Final assistant-message summary5354```text55Memory pruned: <M>/<N> reviewed.5657- <path>: <category> — <one-line reason>58- <path>: <category> — <one-line reason>5960Index updated: MEMORY.md (<+a/-b> lines).61Kept: <N-M> (no action needed or user declined).62```6364If nothing was prunable, say so and list the categories you checked.65