the writing ai & claude code 10 min

Claude Code Memory: What Persists and How to Fix Stale Notes

Each Claude Code session starts fresh. CLAUDE.md and auto memory carry over, but auto memory goes stale. A persistence checklist and a cleanup routine.

Line-art note cards pinned to a board, one crumpled, with a magnifying glass and an eraser

Claude Code forgets the conversation and keeps the notes. Per the official memory docs, every session begins with a fresh context window, and two mechanisms carry knowledge across: CLAUDE.md files you write and auto memory Claude writes itself. Auto memory is the one that rots. It loads only the first 200 lines or 25KB, it is shared across worktrees in a repository, and the docs treat it as context rather than enforced configuration. What follows is a persistence checklist, a look inside the memory folder, a way to fix stale or contradictory notes, and a weekly review routine.

What persists between sessions

The conversation doesn't. Close a session, restart the terminal, open a new one: you get a fresh context window every time. What comes back is whatever the two memory mechanisms reload at the start. The commands reference is explicit that /clear starts fresh on a new task while keeping project memory, and that /resume returns to an earlier conversation. So clearing the screen and clearing memory are different acts.

Here is the checklist I'd work from. It is built from the official memory, skills and commands pages. It isn't the result of my own testing, and the one third-party row is labelled as such.

ItemRestart or new sessionChange of worktree, same repository
Conversation contextGone. /resume can return to an earlier conversationNot carried over
Committed project CLAUDE.mdLoaded at the startPresent in that checkout, loaded at the start
Gitignored CLAUDE.local.mdLoaded at the startOnly exists in the worktree where you created it
Auto memoryLoaded at the start, first 200 lines or 25KBShared, because it is per repository
Index entries past the cut-offOn disk, not injected at startup (third-party description)Same
Path-scoped rules for a sibling worktreeNot applicableStart Claude Code in that worktree or move the session there with /cd
Project skillsLoadedOn v2.1.277 or later, a linked worktree with no .claude/skills at its root loads the main checkout's project skills
A hard block on an actionNot memory at allUse a PreToolUse hook

Notice that "restart" and "new session" collapse into one row. For memory purposes they behave the same: fresh window, files reloaded. The only thing that separates them is whether you choose to /resume an old conversation.

CLAUDE.md and auto memory have different jobs

The split is simple. CLAUDE.md holds instructions you write. Auto memory holds notes Claude writes based on your corrections and preferences. The docs describe the first as instructions and rules, the second as learnings and patterns, and they recommend auto memory for your preferences, corrections you give Claude, and project context Claude can't derive from the code.

Both are loaded at the start of every conversation. And both are context, not enforcement. That matters more than anything else on this page. If a note says "never touch the billing module" and the stakes are real, a note is the wrong tool. The docs say to block an action regardless of what Claude decides, you use a PreToolUse hook instead.

Some practical consequences:

  • Put coding standards, build commands and project layout in CLAUDE.md, where you can review them in a pull request.
  • Let auto memory hold the small, personal, learned stuff: how you like diffs presented, which test command you actually use.
  • Keep each CLAUDE.md under 200 lines. The docs say longer files consume more context and reduce adherence.
  • Subagents can maintain their own auto memory too, so a note you can't find might live in a place you haven't looked.

How you structure CLAUDE.md for a team of clients is a different question, and I've covered it in CLAUDE.md for agencies. This post is about the other half: the notes nobody reviews.

Inspect the memory index and topic files

Start by looking. Run /memory and open the auto memory folder, then sort by date modified. That is the cleanup entry point described by roughworks.ca, and it works because old files are the likeliest to be wrong.

Third-party write-ups describe the layout like this: a MEMORY.md index at ~/.claude/projects/<project>/memory/MEMORY.md, plus topic files that Claude reads on demand. Vectorize says only the first 200 lines or 25KB of that index load at startup. (That matches the limit in the official comparison table.) Treat the folder layout as something to confirm on your own machine, because the official page I'm citing is where the load limit comes from, not the directory structure.

The silent failure

This is the bit that bites. As a project piles up entries, the index grows past 200 lines and older pointers fall out of the loaded window. The topic files still exist. Claude can still read them if it knows about them. But if the index line pointing to one has scrolled out, it may never surface when you need it. A mem0 post goes further, claiming retrieval is capped at a 200-line index and five files per turn. That's a vendor describing its own competitor's design (and selling a replacement), so I'd hold it loosely.

Roughworks also says each note records its kind in a type field in the frontmatter, and that the docs list four kinds. I can't give you the four from the sources here, so open a file and read the field yourself.

To check what's actually in play for the instruction side, run /context in a session and look at the list under Memory files. If a CLAUDE.md you expect isn't listed, it didn't load. Simple as that.

Fix stale or contradictory notes

Stale notes come in a few flavours:

  • Finished work: a note about a launched page or a closed bug. That is history, and git already has it.
  • Duplicates: two notes on one topic, which also bloat the index.
  • Contradictions: one note says you use PostgreSQL, a newer one says you migrated.
  • Dead references: a note names a file path that no longer exists.

The docs are blunt about contradictions in instruction files: if two instructions contradict each other, Claude may pick one arbitrarily. The docs say that about CLAUDE.md, not auto memory. But I'd assume the same risk applies to a folder of notes that disagree, because nothing suggests otherwise. That's my inference, not documented behaviour.

Use the audit for instruction files

/doctor prompt-audit checks instruction files for outdated or conflicting content and produces a report with proposed edits. Nothing in your files changes until you ask Claude to apply them. It requires Claude Code v2.1.283 or later. By default it covers your CLAUDE.md, CLAUDE.local.md and AGENTS.md files, plus the rules, skills, commands, subagents and output styles under .claude/ and ~/.claude/.

Read that list again. Auto memory notes aren't on it. So the audit tidies what you wrote, and the folder Claude wrote still needs a manual pass. Don't assume otherwise without checking on your version.

Correct, don't append

When a fact changes, fix the existing note and say it changed. Adding a second note that disagrees is how you manufacture a contradiction. Roughworks suggests an absolute date on every note and one fact per file, which keeps edits small. Dates matter because "yesterday's deploy bug" means nothing a week later.

There's a useful habit from the community too. A DEV Community write-up treats memory as a hint, not a source of truth: if a note names a file path, check that it exists before acting on it. That is a practice, not a product feature. But it is cheap, and it catches the dead-reference problem before it costs you an hour.

About Auto Dream

Some third-party sources describe an Auto Dream process that runs during idle periods or after a session closes, merging duplicates and replacing contradicted entries. Vectorize says it may trigger; Milvus calls it a background cleanup and describes memory as four layers. The official memory page doesn't mention Auto Dream, and I wouldn't promise four universal layers to anyone. Check whether your install does any of this before you stop reviewing by hand. If you can't see it happening, assume it isn't.

Repository and worktree scope

The docs' comparison table says auto memory is per repository, shared across worktrees. Read the word shared carefully. If you run three worktrees of one repo, they draw on the same machine-local notes. A correction you give Claude in one worktree can show up in the others.

Terminal window beside a corkboard of pinned notes, one faded and curling, with an eraser and a fresh blank note beside it

That has a consequence people miss. A worktree is not a client-data boundary. If you juggle clients, don't treat separate worktrees as separate memories. Different repositories get different auto memory; branches of one repository don't. And anything confidential shouldn't be sitting in a notes folder in the first place.

The instruction side behaves differently, and it trips people up:

  • A gitignored CLAUDE.local.md only exists in the worktree where you created it. To share personal instructions across worktrees, import a file from your home directory. Imports can recurse, with a maximum depth of four hops.
  • Path-scoped rules only load for files in a sibling git worktree if you start Claude Code in that worktree or move the session there with /cd.
  • On v2.1.277 or later, a linked worktree with no .claude/skills at its root loads the main checkout's project skills instead.

So one layer is shared (auto memory), one is per checkout (local instructions, committed files), and one has its own fallback rule (skills). Which is awkward. The practical fix is to keep personal preferences in your home directory, keep project facts in committed files, and let auto memory carry only what you'd be happy for any worktree of that repo to see.

If the notes ever need to live somewhere else, roughworks says you can set autoMemoryDirectory in settings.json to an absolute path or one starting with ~/. That is from a secondary source, so confirm it against the current docs before relying on it.

A weekly memory review

Review on a schedule, because nobody does it when it's optional. The five-step cleanup below comes from roughworks.ca. I've kept their steps and added my own notes in brackets.

  1. Open the folder with /memory and sort by date modified.
  2. Delete the finished. A note about a launched page or a closed bug is history.
  3. Merge duplicates. Two notes on one topic become one, and the index loses a line.
  4. Rewrite incidents as rules. Keep the one sentence the next session needs, and the date. Drop the story.
  5. Check the claims that matter against reality. For any note a session is about to act on, look at the repository or the live system first.

Roughworks says you can ask Claude to do the first four, which is sensible. But review what it proposes before it deletes anything, because a note you no longer recognise might be the one rule holding something up. (I'd add that deleting is cheaper than being wrong, so when in doubt for finished work, delete.)

Then run /doctor prompt-audit on a version that supports it, read the report, and tell Claude to apply only the edits you agree with. If a CLAUDE.md line has gone stale, you can also leave a block-level HTML comment next to it for maintainers. Those comments are stripped before the content is injected into Claude's context, so they cost nothing at load time.

Fit the review into a fixed slot. I'd tie it to whatever end-of-week routine you already have, such as the one in my daily founder workflow. And if you want the surrounding set-up rather than just the memory piece, the Claude Code workflow page covers how the parts fit together.

FAQ

Does `/clear` delete auto memory?

No. The commands reference says /clear starts fresh on a new task while keeping project memory. It clears the conversation, not the notes or your CLAUDE.md files.

Can I move the auto memory folder?

A secondary source, roughworks.ca, says you can set autoMemoryDirectory in settings.json to an absolute path or one starting with ~/. I haven't seen that in the official excerpt, so check the current settings reference first.

Do Managed Agents memory stores or Claude Tag share this memory?

No, they're separate products with their own rules. Managed Agents memory stores are workspace-scoped, with a maximum of 8 stores per session. Managed Agents itself is in beta. Claude Tag keeps memory by channel, not by person.

Can a subagent have its own memory?

Yes. The memory docs say subagents can also maintain their own auto memory, and they point to the subagent configuration page for the details. If a note seems to have vanished, check whether a subagent wrote it rather than the main session.

The sharpest caveat is this: auto memory is a notes folder, not a rulebook. It loads only the first 200 lines or 25KB, it is shared across every worktree of a repository, and Claude treats it as context it may ignore. Prune it weekly, and put anything that must never happen in a hook.

this post in the tree

Need this done, not just read?

Discuss your website Book 30 minutes