memory-hygiene
Skill0 starsChanged 15 days agoMITView on GitHub
Audit and clean a Claude Code auto-memory directory so the index actually loads: count how much of MEMORY.md reaches the agent at startup (200 lines / ~25k chars), find overlong index lines, broken and orphan entries, near-duplicates, frontmatter errors, and feedback rules that sit below the cut, then archive finished project memories and shorten the index after the user approves. Also a session-wrap mode that files one topic memory plus one short index line. Use when the user says 'clean up memory', 'MEMORY.md is too long', 'memory got truncated', 'tidy memories', 'wrap up the session', 'save what we learned', or when a startup warning says the memory index was cut off.
13 other projects use a version of this.
Adopted by
Most recently taken up by
- Guz007/claude-code-os-plugintheir own version, first seen Nov 29, 2026
- HEADING-OS-Official/heading-ostheir own version, first seen Nov 29, 2026
- HsuanYuLee/polaristheir own version, first seen Nov 12, 2026
- BSSE23047/nauraiz-devtheir own version, first seen Nov 8, 2026
- mahsumaktas/agent-evolution-kittheir own version, first seen Nov 8, 2026
- Kein-chronicle/claude-code-memory-linttheir own version, first seen Nov 1, 2026
Other versions13 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 13
- huytieu/COG-second-brain★ 1.3ksame name
- NUX-Design/claude-skills-fable-opus★ 24same name
- HsuanYuLee/polaris★ 5same name
- megandmartin/agent-skills-repo★ 4same name
- BSSE23047/nauraiz-dev★ 2same name
- HEADING-OS-Official/heading-os★ 2same name
- mahsumaktas/agent-evolution-kit★ 2same name
- NecturaLabs/AgentSkills★ 1same name
- NITISH-R-G/agent-memory-protocol★ 1same name
- chanjalme/claude-skills★ 0same name
3 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository24 other files it gives its agents.
- model-routerSkill
- notion-worklogSkill
- telegram-notifySkill
- collect-billsSkill
- morning-briefSkill
- vercel-triageSkill
- councilSkill
- draft-planSkill
- founder-modeSkill
- founder-setupSkill
- grillSkill
- new-skillSkill
- pr-foldSkill
- relaySkill
- safe-migrationSkill
- ship-prSkill
- shred-planSkill
- spikeSkill
- verifySkill
- whySkill
- free-diskSkill
- mac-compromise-checkSkill
- reclaimSkill
- worktree-janitorSkill
The file
We split this skill into the rules it gives an agent
5 rules. 0 are common, 2 are distinctive, and 3 are very specific to this project.
0
Common
Most of the 12 edited versions we read keep these.
2
Distinctive
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 49
Rules to the top: Every feedback and user memory gets an index line in a ## Rules block at the top of MEMORY.md.
- Distinctive: line 54
Read each candidate's description first — the audit's keyword match is a heuristic.
- Very specific: line 80
Run the audit's headline (audit.sh | head -4) — if the index is already over the limit, say so and offer the cleanup instead of adding to …
- Very specific: line 86
Add or replace one index line, ≤150 chars: - Title — hook.
- Distinctive: line 88
Do not save what the repo already records (code structure, git history, checked-in docs).
“Common” is measured: kept by at least 6 in 10 of the 12 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
/memory-hygiene — a memory the agent never reads is not a memory
Claude Code loads only the head of MEMORY.md at startup: the first 200 lines,
and in practice fewer, because it also stops at about 25,000 characters. An index
that grows one fat line per session hits that wall long before 200 lines. From
then on every new entry pushes an old one out of view, and the old ones are
usually the rules — the feedback memories the user gave once and expects to be
followed forever. The agent starts breaking them without knowing they exist.
This skill makes the loss visible, then fixes it without deleting anything:
finished project memories move to archive/, fat index lines get short, rules
move to the top.
When to use this
- A startup warning says MEMORY.md was cut off, or the user says memory is too long / truncated / messy.
- The agent keeps forgetting a rule the user remembers giving.
- Session wrap — end of a working session: "save what we learned", "wrap up".
When NOT to use this
- Editing a project's checked-in
CLAUDE.md/AGENTS.md— that is repo documentation, not auto-memory. - Deleting memories. This skill archives. Deleting a file needs the user's explicit yes for that file.
Workflow — cleanup
- Audit (read-only):
The headline is "only N lines load — M lines never reach the agent". Also: lines over 200 chars, links to missing files, orphans, frontmatter errors, feedback/user rules below the cut, near-duplicate names, and archive candidates (project memories whose text says DONE / MERGED / ENDED / SHIPPED / superseded, oldest first).bash "$SKILL_DIR/scripts/audit.sh" # memory dir for the current cwd bash "$SKILL_DIR/scripts/audit.sh" <memory-dir> bash "$SKILL_DIR/scripts/audit.sh" <memory-dir> --json - Propose a plan — numbers first, then the moves:
- Rules to the top. Every
feedbackandusermemory gets an index line in a## Rulesblock at the top of MEMORY.md. These must always load. - Archive finished projects. Move each finished
projectmemory toarchive/<same-name>.md, drop its index line, and keep one line:- [Archive](archive/) — N finished projects; grep here before re-investigating. Read each candidate's description first — the audit's keyword match is a heuristic; "DONE" next to "open = …" is not finished. - Shorten fat lines to ≤150 chars. What the line loses goes into the topic file's body, not into the void.
- Merge near-duplicates (dated re-runs of one topic,
run6/run7/run8) into the newest file; the older ones go toarchive/. - Fix orphans (index them or archive them) and frontmatter errors.
- Target: the whole index loads, with headroom (≤150 lines, ≤18k chars).
- Rules to the top. Every
- Ask before touching anything —
AskUserQuestionwith the plan's parts as options (recommended first: "rules to top + archive finished + shorten"), and name the count of files each part moves. - Apply with Edit/Write and
mvintoarchive/. Neverrm. Keep every file's frontmatter; when you merge, list the merged-from names in the body. Recently touched memories (under 3 days) stay put unless the user says so — another session may be writing them. - Re-run the audit and report before → after: lines loaded, chars, rules
loaded, files archived. Done means
✓ whole index loads at startupand zero rules below the cut.
Workflow — session wrap
At the end of a session, file what the next session needs and nothing else:
- Run the audit's headline (
audit.sh | head -4) — if the index is already over the limit, say so and offer the cleanup instead of adding to the pile. - Pick one topic file: update the existing one for this workstream if the index
has it, else create
<short-kebab-name>.mdwith frontmatter (name,description,type). Put detail — branches, PR numbers, open questions, exact commands — in the body. Convert relative dates to absolute. - Add or replace one index line, ≤150 chars:
- [Title](file.md) — hook. Rules (feedback/user) go in the Rules block at the top. - Do not save what the repo already records (code structure, git history, checked-in docs).
References
references/layout.md— the index layout this skill converges on, the load limits and how they were measured, and what counts as "finished".
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.

