Topic 5 of 5 · 4 min read
Keeping memory files short and current
Goal: Review a proposed memory-file diff and decide which additions to keep, shorten, move to a skill or reject to keep the file small and accurate.
Treat a memory file like code: give it an owner and a size budget, review every change in a pull request, and prune it on a schedule, because files only grow unless someone says no.
Check yourself · 1 of 3
An agent proposes adding a 40-line procedure for adding a payment provider to the root memory file. What is the best response?
Why it matters
Every rule added today is read on every run for as long as it stays. Small additions feel free, but they add up: after a year the file is long, contradictory and half wrong. Some tools also cut off or warn on large files. Codex, for example, stops reading project instructions at a default limit of 32 KiB. Past the budget, rules are lost or diluted without any error.
Agents can also propose edits to their own memory ("I will remember to use pnpm"). This is useful, but an agent adds readily and rarely removes. Its additions need the same review as human ones.
A routine that works
- Set a budget. A number you can check: for example "root file under 150 lines". When a new line goes in, an old one goes out or moves.
- Name an owner. One person or team is responsible for the file, as with a
CODEOWNERSentry. No owner, no pruning. - Review changes in the PR. For each added line ask four questions: Is it true now? Can the agent not infer it? Does a tool already enforce it? Is it needed on every task?
- Route by the answer.
- True and needed always: keep, in as few words as possible.
- Needed for one kind of task: move to a skill, a path-scoped rule or a nested file.
- Long explanation: move to a doc and leave a pointer.
- Enforceable by a tool: add the check, drop the sentence.
- A one-off fix or a guess: reject.
- Prune on a schedule. Each quarter, or each release, run every listed command and delete what fails.
Before and after
A proposed diff:
## Testing
- Run one test: `pnpm vitest run <path>`
+- Tests are important and should always be written carefully.
+- When the checkout bug on 2026-11-04 happened, we found the cart total used floats. Always use cents.
+- To add a payment provider: (40 lines of steps)
Review: reject the first line (vague). Shorten the second to "Money is integer cents, never float." Move the third to docs/add-provider.md or a skill and point to it. The file grows by one line, not forty-two.
What goes wrong
- Append-only memory. Nobody removes anything, so the file bloats.
- Incident diaries. Notes about one bug that never help again.
- Unreviewed agent edits. The agent writes a wrong assumption into the file, and every later session trusts it.
- No owner. Everyone assumes someone else prunes.
Examples
Reviewing an agent-proposed edit
The agent proposes: "Remember: the user prefers tabs, uses pnpm, the build once failed on 2026-10-02 because of a missing env var, and the deploy script lives in scripts/deploy.sh."
Keep: Package manager: pnpm. Check .editorconfig for tabs instead of writing it. Reject the incident note. Keep the deploy path only if it is not obvious from the repo.
A quarterly prune
Run each documented command in a clean checkout. Two fail: npm run build:all (renamed) and make seed (removed). Fix the first, delete the second. Then delete two lines that duplicate linter rules. The file shrinks by 12 lines and every command works.
Key points
- Set a checkable size budget for the file, because past the tool's limit rules are silently lost.
- Give the file an owner and review every change in a pull request.
- For each added line ask whether it is true, not inferable, not tool-enforced and needed on every task.
- Move task-specific procedures to skills or nested files and long explanations to docs with a pointer.
- Prune on a schedule by running every listed command and removing what fails.
Common mistakes
- Accepting agent-proposed memory edits without reading them.
- Adding a line after every incident, so the file becomes a diary.
- Having no owner, so no one prunes.
- Letting the file grow past the tool's size limit without noticing.
Check yourself · 2 of 3
Which practice most reliably stops a memory file from growing without limit?
Check yourself · 3 of 3
During review you find a line that says to run npm run build:all, but that script no longer exists. What should you do?
Practice items, not counted towards your mastery.
Start here
- AGENTS.md (opens in a new tab)DocsFree
The open format, what to put in the file and which agents read it.
- How Claude remembers your project (Claude Code docs) (opens in a new tab)DocsFree
How CLAUDE.md, AGENTS.md, imports and path-scoped rules load, and how to troubleshoot ignored files.
- Custom instructions with AGENTS.md (OpenAI Codex docs) (opens in a new tab)DocsFree
How Codex discovers AGENTS.md files from global to nested, and its 32 KiB default size limit.
More for this topic
- Best practices for Claude Code (Claude Code docs) (opens in a new tab)DocsFree
Advice on what to put in CLAUDE.md, keeping it short and giving the agent ways to verify its work.