memory-trim
Skill2 starsChanged 24 days agoMITView on GitHub
Measures the agent's memory index (MEMORY.md) against what Claude Code loads, lists the rules past the cut, and rebuilds it as one short line per rule, most important first. Fixes "the agent ignores a rule I wrote, as if it never saw it." Use when the agent breaks a rule that is in its memory, when Claude Code warns at session start that MEMORY.md was only partly loaded, or when the index nears 200 lines. Also on /memory-trim.
In this repository102 other files it gives its agents.
- access-levelsSkill
- agent-failuresSkill
- agent-guardSkill
- agent-hooksSkill
- agent-limitsSkill
- agent-loopSkill
- agent-patternsSkill
- agent-wikiSkill
- ai-in-businessSkill
- answer-checksSkill
- ask-firstSkill
- automate-questionsSkill
- batch-judgeSkill
- big-archiveSkill
- brief-partsSkill
- bug-triageSkill
- build-an-evalSkill
- calls-to-keepSkill
- checkpointsSkill
- check-waysSkill
- claude-md-rulesSkill
- code-mapSkill
- command-guardSkill
- compact-safelySkill
- context-rulesSkill
- corrected-twiceSkill
- count-checkSkill
- data-leaksSkill
- day-gateSkill
- disprove-findingsSkill
- dogfood-firstSkill
- done-testSkill
- draft-only-mailSkill
- drift-checkSkill
- fail-closedSkill
- failed-readsSkill
- faster-sameSkill
- first-messageSkill
- fix-reviewSkill
- handoff-noteSkill
- handoff-rulesSkill
- hard-problemsSkill
- harness-starterSkill
- hidden-text-checkSkill
- hooks-to-addSkill
- injection-guardsSkill
- inventory-firstSkill
- keys-and-agentsSkill
- live-checkSkill
- lock-on-failureSkill
- long-videosSkill
- mcp-partsSkill
- memory-queueSkill
- memory-sourcesSkill
- night-alarmSkill
- objectorSkill
- old-code-judgeSkill
- one-task-gateSkill
- past-green-testsSkill
- phone-rulesSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
1 rule. About 0 are common, 1 is distinctive, and 0 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.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 26
Never delete a rule to make room.
≈ “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
Memory trim
The agent ignored a rule you wrote. Maybe it never saw it. Claude Code loads only the start of the memory index, so the newest rules at the end are the first to go. This skill counts what loads, shows what was cut, and rebuilds the index so every rule fits.
The principles
- A rule that was not loaded cannot be followed. Check that it loaded before asking why it was broken.
- One short line per rule in the index. The detail lives in topic files that open only when needed.
- The cut always comes from the end. Put what matters most at the top.
Steps
- Find the index: run /memory and open the auto memory folder. If the session opened with a warning that MEMORY.md was only partly loaded, copy it word for word.
- Count it:
wc -l -c MEMORY.md. Claude Code loads the first 200 lines or about 25 KB, whichever comes first. To find where the bytes run out, runhead -N MEMORY.md | wc -cfor a few values of N. - List every line past the cut by title. These are the rules the agent never saw.
- Rewrite each entry as one line: the title, the link to its topic file and a hook of a few words, well under 200 characters. Move any longer detail into the topic file.
- Order the lines by what a miss would cost, every-session rules first. A new entry goes where its weight puts it, not at the bottom.
- Show the before and after counts and the new order, and ask "Write it like this?" Copy or commit the old file first. Write only after a yes.
- Count again and leave room under the limit. In a fresh session, check that the warning is gone. If it is not, report the line where it still cuts.
Rules
- Shorter wording alone is usually not enough. In the real case, cutting every hook to 60 characters still left the index past the cut. The detail has to move out.
- Never delete a rule to make room. Move its detail and keep its line.
- Report every count with the command behind it, and call a limit inferred when it was.
- The worked example is scripts/memory-cut-2026-10-28.md, summed up in scripts/PROOF.md: 205 lines, 24 cut from line 182, among them "Run autonomously" and "Quota stop is 98%". It shows which rules did not load, not what the agent did differently because of it, the exact byte limit (about 25.5 KB, inferred) or that other tools cut the same way.
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.

