MEMORY.md in Claude Code: auto memory explained
What MEMORY.md is in Claude Code, where auto memory lives on disk, the 200-line load limit, how to edit or turn it off, and what belongs in CLAUDE.md instead.
MEMORY.md is the index file of Claude Code’s auto memory, the notes Claude writes for itself about you and your project. It lives at ~/.claude/projects/<project>/memory/MEMORY.md, one directory per git repository, and Claude creates and updates it as it works. While auto memory is on, the first 200 lines or 25KB of the index load at the start of every session. CLAUDE.md is the instruction file you write yourself. Anthropic covers both on its memory page, and the changelog dates auto memory to v2.1.59.
Below are the folder on disk, a memory file as Claude Code writes it today, and a routine for reviewing what Claude saved.
MEMORY.md and CLAUDE.md side by side
This table is based on Anthropic’s comparison table, with a row added for where each file lives:
CLAUDE.md files |
Auto memory | |
|---|---|---|
| Who writes it | You | Claude |
| What it contains | Instructions and rules | Learnings and patterns |
| Scope | Project, user or organization | Per repository, shared across worktrees |
| Where it lives | Your repository, ~/.claude/ or a managed policy path |
~/.claude/projects/<project>/memory/ |
| Loaded into | Every session | Sessions with auto memory on, up to the index’s load limit |
| Use for | Coding standards, workflows, project architecture | Your preferences, corrections you give Claude, project context Claude cannot derive from the code |
A CLAUDE.md that loads at launch arrives whole up to 4 MiB. Subdirectory files and path-scoped rules load on demand and are cut at a per-file limit, 40,000 characters on a 200K context window (troubleshooting). Claude weighs both kinds of file as context, so a rule that must always hold belongs in a permission rule or a hook. What to put in CLAUDE.md covers the instruction side.
Where auto memory lives on disk
Each project gets a directory at ~/.claude/projects/<project>/memory/. Claude Code derives <project> from the git repository, so every worktree and subdirectory of one repository shares a single memory directory, a change that arrived in v2.1.63. Outside a git repository, the project root is used (storage location).
The folder name is a path with every character other than letters and digits replaced by a dash, the rule Anthropic gives for transcripts on its sessions page. On the Windows machine we checked, the memory folder carried the repository root’s path in that form. For a repository called bakery-orders:
| System | Repository path | Memory directory |
|---|---|---|
| macOS | /Users/you/code/bakery-orders |
~/.claude/projects/-Users-you-code-bakery-orders/memory/ |
| Windows | C:\Users\you\code\bakery-orders |
%USERPROFILE%\.claude\projects\C--Users-you-code-bakery-orders\memory\ |
Transcripts follow the directory you launched Claude in, so the two share one <project> folder only when you launch at the repository root. A session started in bakery-orders/api/ or in a linked worktree writes its transcripts to a folder named after that path and its memory to the repository’s folder.
With CLAUDE_CONFIG_DIR set, every ~/.claude path moves under that directory, projects/ and its memory included. Adding CLAUDE_CODE_PROJECT_DIR_NAME (v2.1.234 or later) fixes the <project> name, so every project launched with that config directory shares one memory folder.
Auto memory is machine-local, and a second laptop or a cloud session starts with an empty directory. The retention sweep that deletes old transcripts leaves the memory files in place.
Moving the directory with autoMemoryDirectory
autoMemoryDirectory points auto memory at another folder, given as an absolute path or one starting with ~/. Claude Code reads it from any settings scope, so a value in ~/.claude/settings.json sends every project to that one folder. For one project, put a project-specific path in that project’s .claude/settings.local.json:
{
"autoMemoryDirectory": "~/agent-memory/bakery-orders"
}
From project settings files, Claude Code honours it under the workspace trust rule it applies to hooks. With permissions.blockReadsOutsideWorkingDirectories on, a directory chosen by a repository-supplied settings file is neither read nor written.
A memory directory, laid out
The directory holds one index and one topic file per memory, each named by Claude, as in Anthropic’s example tree. An invented directory for bakery-orders:
~/.claude/projects/-Users-you-code-bakery-orders/memory/
MEMORY.md
user_role.md
feedback_order_tests.md
project_holiday_freeze.md
reference_bug_tracker.md
The index keeps one line per memory, a link to the file followed by a short summary:
- [Role](user_role.md): backend developer, new to the React front end
- [Order tests](feedback_order_tests.md): run `pnpm test:orders` before the full suite
- [Holiday freeze](project_holiday_freeze.md): no deploys 20 Dec to 2 Jan, agreed with ops
- [Bug tracker](reference_bug_tracker.md): order bugs live in the Linear project ORD
The indexes we found on disk separate the link from the summary with a long dash, where this example uses a colon, and some open with a heading line.
Anthropic’s documentation names two frontmatter fields in a topic file: type, the kind of memory, and modified, an ISO 8601 timestamp Claude Code stamps on every write. Files written by Claude Code 2.1.292, the version we checked on 28 November 2026, carry more than that. The file opens with name and description, followed by a nested metadata block that holds type and modified with two more fields. With invented values, a topic file looks like this:
---
name: order-tests-first
description: "Run the order tests before the full suite"
metadata:
node_type: memory
type: feedback
originSessionId: 00000000-0000-0000-0000-000000000000
modified: 2026-11-20T14:02:11.000Z
---
Run `pnpm test:orders` first when a change touches `src/orders/`.
The user stopped a nine-minute full run on 20 November to ask for it.
Only type and modified are documented, so a later release can change the rest.
The four kinds of memory
The type field takes one of four values:
| Type | What Claude saves under it |
|---|---|
user |
Your role, expertise and working preferences |
feedback |
Corrections you give and approaches you confirm |
project |
Ongoing work, deadlines and decisions Claude cannot find in the code or git history |
reference |
Where to find information outside the project |
Claude leaves out anything it can derive from the codebase, along with anything your CLAUDE.md files already say, and plenty of sessions save nothing.
What loads at session start
The first 200 lines or the first 25KB of MEMORY.md load when a session starts, whichever comes first (how it works). The 25KB cap arrived in v2.1.83. Lines past the cut stay out of the starting context. Topic files cost nothing at startup: Claude opens them with its ordinary file tools when a task calls for one, and the interface shows “Saved 2 memories” or “Recalled 2 memories” when that happens.
Claude Code measures the index after every write and reminds Claude to compact it near a limit. A write that goes over still succeeds, and Claude Code returns an error telling Claude to rewrite the index (errors reference). Since v2.1.211 the warning counts only what loads, leaving frontmatter and HTML comments out.
Subagents start without the main conversation’s auto memory, apart from a fork. A subagent can keep its own through the memory field in its definition (subagent docs). Its user scope writes under ~/.claude/agent-memory/, and its project scope writes under .claude/agent-memory/, which you can commit and share. A local scope uses .claude/agent-memory-local/ and stays out of git.
Viewing and editing memory
Everything in the directory is plain Markdown. In the terminal, /memory lists your CLAUDE.md and CLAUDE.local.md files with an option to open the memory folder, and the auto memory toggle sits on the same screen (view and edit with /memory). In VS Code, the Customize section has a Memory entry holding the toggle and the saved memories, and it can reveal their folders in your file manager. That entry needs v2.1.274, and editing or deleting a memory inside the dialog needs v2.1.275 (VS Code docs). Anthropic’s desktop page describes no memory view, so desktop users open the folder from a file manager.
When you change a memory, change both places it lives. The index line loads every session and the topic file loads only on demand, so a fact corrected in the topic file alone keeps arriving in its old form through the index. Delete a memory by removing the topic file and its index line together.
Asking Claude to “remember” something saves it to auto memory, and “add this to CLAUDE.md” writes to the instruction file instead. Anthropic documents no setting that stops Claude saving one kind of thing. Delete the unwanted memory, and move a fact you want kept into CLAUDE.md, since Claude skips facts your CLAUDE.md files already state.
claude purge deletes a project’s transcripts and auto memory after asking for confirmation, and leaves scratchpads and pasted images in the temp directory. Before v2.1.288 it was claude project purge (clear local data).
A memory review, and promoting entries to CLAUDE.md
Claude adds to memory as it works, and nothing in Claude Code reviews the result for you. Once a month, or before a large piece of work:
- Open the index through
/memoryor the folder. - Read each line and decide whether it still holds.
- Move anything your whole team should follow into
CLAUDE.md. Ask Claude to add it there, or edit the file yourself, then delete the topic file and its index line so the fact lives in one place. - Fix wrong entries in both places, and delete entries for finished work.
- Keep the index well inside the load limit.
Auto memory never reaches a teammate’s machine, so a correction helps nobody else until it reaches CLAUDE.md.
Turning auto memory off
Auto memory is on by default in local sessions, and sessions in a self-hosted environment start with it off (enable or disable auto memory).
| To | Do this |
|---|---|
| Turn it off everywhere | Use the toggle in /memory, which writes autoMemoryEnabled to ~/.claude/settings.json |
| Turn it off for one project | Set "autoMemoryEnabled": false in that project’s settings |
| Turn it off for one shell | Set CLAUDE_CODE_DISABLE_AUTO_MEMORY=1 before starting claude |
| Run a script without it | claude -p --bare, which turns auto memory off entirely (v2.1.81) |
In a background session, or one another Claude Code session started, the toggle can turn memory off and cannot turn it back on, so switch it on from a session you start in a terminal. Subagent memory stops along with auto memory.
Where each fact belongs
The files you write load in order: a managed policy CLAUDE.md, then ~/.claude/CLAUDE.md and ~/.claude/rules/, then the project’s CLAUDE.md, .claude/rules/ and CLAUDE.local.md. From v2.1.277, Claude Code reads a repository’s AGENTS.md when no CLAUDE.md or CLAUDE.local.md sits on the path (AGENTS.md). Auto memory loads beside them as a separate source. Anthropic warns that Claude may pick either of two contradictory instructions, and the docs say nothing about how a memory ranks against one, so remove whichever side has gone stale.
| Fact | Put it in | Why |
|---|---|---|
| Build, test and lint commands | Project CLAUDE.md or AGENTS.md |
Everyone needs them in full every session |
| A convention that departs from the default, such as money in integer cents | Project CLAUDE.md |
A team rule, reviewed in pull requests |
| A rule for one folder or file type | .claude/rules/ with paths |
Loads only when Claude works there |
| Your role and how you like changes explained in this repository | Auto memory, user |
Claude learns it from you |
| A correction you gave twice | Auto memory at first, then CLAUDE.md at your next review |
Teammates see only what reaches CLAUDE.md |
| A deadline or a decision from a meeting | Auto memory, project, or your team’s tracker |
Goes stale, and the index line stays cheap |
| Where the dashboards and issue tracker live | Auto memory, reference |
A pointer, read when needed |
| Your sandbox URL | CLAUDE.local.md |
Personal, and kept to one checkout |
| Secrets and keys | Neither | Both are plaintext and end up in transcripts |
| Anything that must never happen | A permission deny rule or hook | Neither file is enforced |
The CLAUDE.md generator drafts the instruction file from a form. Syncing CLAUDE.md between machines covers carrying instruction files, and memory through autoMemoryDirectory, to another computer.
Other coding agents
Codex pairs AGENTS.md with memories that are off by default, and Gemini CLI’s memory tool writes facts into GEMINI.md files. GitHub hosts Copilot Memory, where a memory lapses 90 days after it is created unless Copilot confirms it again. Giving AI agents persistent memory compares them in full.
Agent memory as notes in a Jotura vault
Jotura keeps agent memory as Markdown notes in a vault, a folder of .md files on your disk, through the jotura command-line tool that ships with the desktop app. With the Jotura skills installed, the agent runs the memory loop on its own. It loads the memories relevant to a task when the task starts and searches past decisions before proposing an approach. Once something is settled it writes one note per memory under Memory/, and a reversed decision gets marked superseded and linked to its replacement.
The desktop app’s Agent Memory tab lays every memory out on a timeline, and an edit you make there reaches the next session. Claude Code and Codex read the same notes once both have the skills. Jotura Sync carries the vault between your computers, end-to-end encrypted, for £4 a month or £40 a year with no free trial (pricing). The app is free on Mac, Windows, Linux and Android, and there is no iPhone or iPad app.
Jotura is closed source, and the agent needs shell access because Jotura has no MCP server. Claude Code’s auto memory keeps running beside the vault notes. Jotura for agents shows the setup, and the agent command reference documents what the agent runs.
Frequently asked questions
What is MEMORY.md in Claude Code?
MEMORY.md is the index of Claude Code’s auto memory, kept at ~/.claude/projects/<project>/memory/MEMORY.md. Claude writes it, one line per memory, and keeps the detail in topic files beside it. Its opening section loads at the start of every session in that repository.
Where is the Claude Code memory file on Windows?
Under %USERPROFILE%\.claude\projects\, in a folder named after the repository path with every character other than letters and digits turned into a dash. A repository at C:\Users\you\code\shop gets C--Users-you-code-shop\memory\MEMORY.md.
What is the difference between MEMORY.md and CLAUDE.md?
CLAUDE.md holds instructions you write, often committed to git for your team, and loads every session. MEMORY.md indexes what Claude has learned from working with you and stays on the machine that wrote it.
Why did Claude forget something saved in MEMORY.md?
Only the first 200 lines or 25KB of the index load at session start, so check whether the entry sits past that point, then shorten the index to one line per memory. Check too that auto memory is still on.
How do I turn off Claude Code auto memory?
Use the auto memory toggle in /memory, or set CLAUDE_CODE_DISABLE_AUTO_MEMORY=1 for one shell.
Which Claude Code version has auto memory?
Auto memory arrived in v2.1.59. Run claude --version to see yours.
Does auto memory sync between machines?
No. Anthropic describes auto memory as machine-local. Pointing autoMemoryDirectory at a synced folder carries the files, with conflict copies when two machines write at once.