Claude Code memory is a set of files read into each new session. There are two kinds, CLAUDE.md files that you write and auto memory that Claude writes for itself, and unless you resume the old conversation, nothing else carries over.

Anthropic's memory documentation opens with the reason: "Each Claude Code session begins with a fresh context window."

Leonard Shelby, in Christopher Nolan's 2000 film Memento, can't form new memories, and in Wikipedia's summary he gets by on "an elaborate system of photos, notes, and tattoos".

So what goes wrong for Leonard? He trusts whatever his notes say, and by the film's end he is, in that summary's words, "willing to lie to himself to be happy".

Keeping the notes true is the ongoing job for anyone whose coding agents remember things, and the section on what goes wrong shows how to check them.

What does Claude Code remember between sessions?

Claude Code remembers what is in two sets of files, CLAUDE.md files and auto memory, and the docs compare them row by row.

CLAUDE.md files Auto memory
Who writes it You Claude
What it contains Instructions and rules Learnings and patterns
Scope Project, user, or org Per repository, shared across worktrees
Loaded into Every session Every session (first 200 lines or 25KB)

Notice that the conversation is in neither column. So a decision you reached in yesterday's session exists today only if you put it in CLAUDE.md or Claude chose to save it.

Claude decides what goes into auto memory, so some sessions add nothing. The docs say "Claude doesn't save something every session", and that it skips what it can work out from the code.

A third input, text passed at launch with the --append-system-prompt flag, lasts only for the session it starts.

Where do the files live?

Instruction files load from four scopes, and a session reads all that apply.

Scope Location Who sees it
Managed policy A system path such as /etc/claude-code/CLAUDE.md on Linux Everyone in the organization
User ~/.claude/CLAUDE.md You, in every project
Project ./CLAUDE.md or ./.claude/CLAUDE.md The team, through source control
Local ./CLAUDE.local.md You, in this project

Files above the working directory load at launch, and the docs add that "Files in subdirectories load on demand." A repository that already has an AGENTS.md for other tools works too, since Claude Code can read it as the project instructions.

Auto memory sits outside the repository, in ~/.claude/projects/<project>/memory/. A MEMORY.md file indexes the directory, with one topic file for each memory.

A Claude Code session reads from three sources. CLAUDE.md files, written by you, load at launch from the managed, user, project and local scopes. Auto memory, a MEMORY.md index with topic files that Claude Code writes as it works, also loads at launch. Context passed on the command line lasts for that session only.
Instruction files above the working directory load at launch, and auto memory loads the first 200 lines of its index.

Now, files in your home directory stay on your machine, and the docs say so: "Auto memory is machine-local." What Claude learned on your laptop is absent from a cloud session and from a colleague's checkout, so anything the team needs belongs in the project file.

How much of it gets loaded?

For auto memory, only the top of the index gets loaded. "The first 200 lines of MEMORY.md, or the first 25KB, whichever comes first, are loaded at the start of every conversation", and the topic files are read when Claude decides it needs them.

Instruction files that load at launch come in whole, "as long as the file is 4 MiB or smaller", and files that load on demand are cut off at 40,000 characters in a session with a 200K context window. But the number to aim for is far lower, since the docs ask you to "target under 200 lines per CLAUDE.md file."

Why so short? The docs' reason is that "Longer files consume more context and reduce adherence."

Which instructions are worth one of those 200 lines is the subject of my CLAUDE.md guide.

Is memory a rule or a suggestion?

Memory is a suggestion. The docs say of both file types that "Claude treats them as context, not enforced configuration", and I'd read that sentence before any other on the docs page.

CLAUDE.md reaches the model as an ordinary message. The docs say "CLAUDE.md content is delivered as a user message after the system prompt, not as part of the system prompt itself", so an instruction there competes with everything else in the window, and they warn that when two instructions conflict "Claude may pick one arbitrarily."

For something that must never happen, the docs say to use a PreToolUse hook, which blocks the action before it runs. A memory file is the right place for how the team works and the wrong place for a guarantee.

My Claude Code hooks guide builds that hook and shows the edit it blocked, along with five setups where the same guard let the edit through.

What survives a long session?

The project-root CLAUDE.md does. When a session fills its window and is compacted, "Project-root CLAUDE.md survives compaction: after /compact, Claude re-reads it from disk and re-injects it into the session."

An instruction given only in conversation has no such protection, which is the failure short-term memory for agents works through. The reload itself has had bugs, and the changelog entry for version 2.1.311 on October 26 reads "Fixed Claude seeing stale MEMORY.md and CLAUDE.md content right after automatic compaction when those files were edited earlier in the session".

What goes wrong with it?

Stale notes go wrong, because a note is trusted. Nolan said of Memento's audiences, in an interview the Wikipedia article quotes, that they had spent the film looking at a captioned photograph and "they still prefer to trust that image" after the film had shown it to be unreliable.

A model reading MEMORY.md is in the same position. Say a line reads "this project uses npm": Claude will keep running npm after the project has moved to pnpm.

So how do you catch a stale note? For auto memory the docs give each file a modified date and say "The timestamp shows how current the fact is, both to you and to Claude when it reads the memory back."

/context all shows which files a session loaded and /memory opens them for editing, and for the instruction files /doctor prompt-audit has Claude look for "references to files or commands that don't exist, and files that contradict each other."

That audit ran on an AGENTS.md with two stale lines and one rule about a paused merge queue, and it flagged only the two the repository could contradict.

I managed the writers at Mem0, which sells a memory layer for agents, and I wrote its setup guide for adding memory to Claude Code, so weigh what follows accordingly. For one developer on one machine, I think the two file types are enough.

The two file types fall short for a team, since auto memory stays on one machine, and for anyone who also uses other coding tools, which coding agent memory compares.

A subagent starts with its own fresh window and can be given a separate memory directory. How these files sit beside other kinds of agent memory is the subject of AI memory management.

FAQ

Does Claude Code remember previous conversations?

No, unless you resume one. A new session starts with a fresh context window, and only CLAUDE.md files and auto memory carry over.

Where does Claude Code store memory?

Instruction files live in the project and in ~/.claude/. Auto memory lives in ~/.claude/projects/<project>/memory/ on the machine where it was written.

Can I turn auto memory off?

Yes. Open /memory and use the toggle, or set autoMemoryEnabled to false in the project's settings.