Claude Code auto memory: what it stores, where, and how to turn it off
Claude Code can take notes for itself. This is called auto memory. Claude writes the notes while you work, and a short index of them loads at the start of the next session.
This page covers what it stores, where the files are, what loads, and how to turn it on or off. Every statement about Claude Code comes from the official memory page, linked at the end.
What auto memory stores
Claude saves four kinds of notes for itself. It records the kind in a type field in the frontmatter of each memory file:
- user
- Your role, expertise and working preferences.
- feedback
- Corrections you give Claude and approaches you confirm.
- project
- Ongoing work, deadlines and decisions that Claude cannot derive from the code or git history.
- reference
- Where to find information outside the project, such as an issue tracker or a dashboard.
Claude skips anything it can derive from the codebase, such as architecture, file paths or debugging fixes. It also skips anything your CLAUDE.md files already say. It does not save something in every session: it decides whether the information would help in a future conversation.
When you ask Claude to remember something, for example "always use pnpm, not npm", it saves that to auto memory. To put an instruction into CLAUDE.md instead, say so, as in "add this to CLAUDE.md", or edit the file yourself.
When Claude writes a memory file that begins with YAML frontmatter, Claude Code records the write time in a modified field as an ISO 8601 timestamp. It shows how current a fact is, to you and to Claude.
Where it lives
Each project gets its own memory directory at ~/.claude/projects/<project>/memory/. The <project> part is derived from the git repository, so all worktrees and subdirectories of one repository share one directory. Outside a git repository, the project root is used.
MEMORY.md # index, one line per memory, loaded at session start
user_role.md # one memory
feedback_testing.md # one memory
... # other topic files Claude creates- The files stay on your machine. The reference calls auto memory machine-local: files are not shared across machines or cloud environments.
- They are plain Markdown. You can read, edit or delete them at any time.
- They stay until someone changes them. Claude Code deletes old session transcripts after the
cleanupPeriodDaysperiod, but it excludes the memory files from that sweep. - You can move the folder. Set
autoMemoryDirectoryin a settings file. The value must be an absolute path or start with~/. It is read from any settings scope: user, project, local, policy, or--settings.
{
"autoMemoryDirectory": "~/my-custom-memory-dir"
}A project settings file that sets autoMemoryDirectory follows the same workspace trust rule as hooks in settings files. While permissions.blockReadsOutsideWorkingDirectories is on, Claude Code loads no auto memory from a directory that a repository-supplied settings file chooses, and saves none to it.
If you set CLAUDE_CODE_PROJECT_DIR_NAME next to CLAUDE_CONFIG_DIR, Claude Code uses that name as the project directory under <config dir>/projects/, whichever repository you start it in. Projects started with that config directory then share one auto memory directory. This needs v2.1.234 or later.
What loads at the start
While auto memory is on, the first 200 lines or 25 KB of MEMORY.md, whichever comes first, load at session start. Claude keeps the index short by moving detail into separate topic files.
- Topic files do not load at startup. Claude reads them on demand with its normal file tools, when it needs the information.
- The limit applies only to MEMORY.md. After Claude writes to it, Claude Code measures the file against the 200-line and 25 KB limits. Near a limit, it reminds Claude to shorten the file. Over a limit, the write still works, but Claude Code returns an error telling Claude to rewrite the index, because everything past the limit is dropped on the next load.
- Subagents start without it. The main conversation's auto memory is not loaded into subagents. A fork is the exception. A subagent's own auto memory, enabled with its
memoryfield, is a separate directory. - You see when it is used. Messages such as "Saved 2 memories" or "Recalled 2 memories" in the interface mean Claude is writing to or reading from the memory directory.
Turn it on or off
Auto memory is on by default in local sessions. A session in a self-hosted environment runs with it off by default, except in Claude Tag sessions. Four ways to change that:
- Run
/memoryand use the auto memory toggle. It savesautoMemoryEnabledto your user settings at~/.claude/settings.json. - Set
autoMemoryEnabledin one project's settings to turn it off for that project only:
{
"autoMemoryEnabled": false
}- Set the environment variable
CLAUDE_CODE_DISABLE_AUTO_MEMORY=1to turn it off for sessions that see the variable.
CLAUDE_CODE_DISABLE_AUTO_MEMORY=1 claudeIn a background session, and in a session that another Claude Code session started (for example when Claude runs claude through its Bash tool), the toggle turns auto memory off but not back on. To turn it on again, run claude directly in your terminal and use the /memory toggle there.
The /memory command
/memory lists your CLAUDE.md, CLAUDE.local.md and other memory file locations across user and project scopes. The list includes user and project CLAUDE.md entries for files that do not exist yet. It also lets you toggle auto memory and open the auto memory folder. Select a file to open it in your editor. Selecting one that does not exist yet creates it first.
To see what Claude has saved, run /memory and select the auto memory folder. Everything in it is plain Markdown.
Auto memory and CLAUDE.md
- Who writes it
- CLAUDE.md: you. Auto memory: Claude.
- What it contains
- CLAUDE.md: instructions and rules. Auto memory: learnings and patterns.
- Scope
- CLAUDE.md: project, user or organization. Auto memory: per repository, shared across worktrees.
- Loaded into
- CLAUDE.md: every session. Auto memory: sessions with auto memory on, up to the first 200 lines or 25 KB of MEMORY.md.
The reference says Claude treats both as context, not as enforced configuration. To block an action whatever Claude decides, it points to a PreToolUse hook. If your CLAUDE.md grows long, see CLAUDE.md too long.
When you need it across machines, teammates or tools
Auto memory answers one question well: what should Claude Code remember about you and this repository on this computer? It does not cover three other cases:
- Another machine. The files are machine-local, so a laptop and a desktop each build their own set.
- A teammate. What Claude learned from your corrections sits in your home directory, not in theirs.
- Another tool. The notes sit in Claude Code's own folder and are written for Claude Code.
Each tool remembers something, but each one only for itself. cachly keeps lessons in one place that several tools and several people can read, so a fix found once is known to every AI that works on the project. It runs next to auto memory: cachly does not change the auto memory settings. Details: one memory for Claude Code, Cursor and Copilot and shared memory for a team.
Sources
- Claude Code docs: How Claude remembers your project (auto memory, storage location, limits, settings, environment variable, /memory)
- Claude Code docs: Subagent configuration (subagent memory, linked from the memory page)
Checked against the official docs on .
More: CLAUDE.md too long · Which tool reads which rules file · Lost context after /compact · All docs