Published on , Aurélien Vandaële

How Claude Code memory works: what I leave in auto memory, and what broke

Claude Code has two memories. CLAUDE.md, which you write, holds the rules. Auto memory, which Claude writes itself, keeps your corrections and a project's decisions in ~/.claude/projects/<project>/memory/: a MEMORY.md index loaded at the start of every session, and one file per note, read only when needed. My rule: memory keeps what only applies to one project. As soon as a note applies to all my projects, or has to reach a subagent, I move it into a file I write.

The problem: what you correct in a session is lost

Every session starts with an empty context. If you tell Claude, halfway through a conversation, that this project must never commit without your approval, the instruction goes away when the session ends. The next day, it does it again.

CLAUDE.md solves part of this, but you have to remember to write it. Auto memory covers the rest: when you correct Claude or confirm an approach, it records the fact for later sessions, without you opening a file.

How it works

According to the official documentation, each note carries a type in its header: user (your role, your preferences), feedback (your corrections and the approaches you confirmed), project (decisions and ongoing work the code does not show) and reference (where to find information outside the project). Claude does not save what it can read back from the code, nor what your CLAUDE.md already says.

~/.claude/projects/<project>/memory/
├── MEMORY.md                 # the index, one line per note, loaded at startup
├── lean-agent-pipeline.md    # one note
├── pipeline-third-round.md   # another one
└── ...
  • The index is capped: only the first 200 lines or 25KB of MEMORY.md are loaded. The notes themselves are read on demand. My largest index is 82 lines.
  • Memory stays on the machine. It is shared across the worktrees of one repository, but not between two computers.
  • Every note is dated: Claude Code adds a modified field on each write, which lets you judge whether the fact still holds.
  • `/memory` lists your CLAUDE.md and memory files, turns auto memory on or off and opens its folder. For a single project, "autoMemoryEnabled": false in its settings turns it off.

To choose where an instruction goes, the wording is enough: “remember that” goes to auto memory, “add this to CLAUDE.md” goes to the file you review.

What my 119 notes contain

I counted: 119 notes across 24 project folders. 57 are of type project, 43 feedback, 13 reference, 5 user. Half of them are decisions, not preferences. Every note follows the same format: the fact, then a Why line (what happened) and a How to apply line (what to do next time).

  • A correction that was costing a lot. On October 6, I stopped a fix loop that was burning more than 130,000 tokens per agent. The note sets what follows: code agents on Sonnet, reviewer on Opus, and only critical or important findings get a fix round.
  • An exception to a global rule. My global CLAUDE.md caps fixing at two rounds. On ResellStats, a note allows a third round without asking me, if the fix is a few lines with an obvious test. It comes from a session where two tasks hit that cap on tiny fixes.
  • The opposite exception. My global CLAUDE.md says to commit without asking once everything is green. On two client engagements, a note says the reverse: no commit without my approval for that specific commit. The project note wins, and that is exactly its job.
  • An outdated document. On one of my apps, the brief mixed two versions of the product. A note says which sections to ignore and which to follow. Without it, every session reread the brief and went back to the old version.

What broke

Memory follows the repository's path, not the project. The memory folder's name comes from where the repository sits. The ResellStats code moved folders twice: there are now three memory folders for the same app. At the last move, on October 21, eight notes were copied over. The ten notes from the location before that never were. The Sentry MCP server, declared for the old path, vanished from sessions too; I reinstalled it at user scope the next day.

A rename creates two copies that drift apart. Another app changed name, and folder, on November 11. Twelve notes went into the new folder, the old one stayed in place, and both kept receiving writes. Today the new copy has one more note and two more recent ones. A session opened in the old folder reads outdated decisions.

Memory does not reach subagents. The documentation says so: the main conversation's memory is not loaded into a subagent. On August 12, four subagents ran their checks in the background, then handed back saying they were waiting for the result. Nothing was produced, roughly 600,000 tokens lost. The lesson was saved to memory, but the subagents were the ones who needed it. It is now the first rule of each of the three agents in my chain, as I explain in the post on the postmortem loop.

A note stays true until something contradicts it. Nothing makes a note expire on its own: a decision taken the following week does not touch it. So I have the date of each decision written out, in the note and in its index line, on top of the modified field. A session that reads two contradicting notes knows which one is more recent.

How to start

  • Run /memory in a project you have been working on for a while, and open the memory folder. Read MEMORY.md: it is what Claude knows about you at every startup.
  • Delete what is wrong and merge duplicates. They are plain Markdown files.
  • Before moving or renaming a repository, copy its memory/ folder to the new one, then delete the old one so you do not end up with two versions. If you move a repository often, the autoMemoryDirectory setting pins where memory lives; I do not use it yet.
  • Promote a note when it grows: into ~/.claude/CLAUDE.md if it applies everywhere (what I put in mine), into an agent's file if a subagent must know it, into a hook if it must apply no matter what. Memory and CLAUDE.md remain context: Claude reads them, nothing forces it to follow them.

Article written with the help of AI, from my daily practice and my projects.

The whole notebook