Claude Code Memory

Claude Code memory is how Claude keeps what it learned from one session to the next. Each session starts with a fresh context window. Two things carry knowledge across. CLAUDE.md files hold the instructions you write, and auto memory holds the notes Claude writes for itself. Both load at the start of every conversation.

Who Writes Each Kind Of Memory?

You write CLAUDE.md. Claude writes auto memory, based on your corrections and preferences. Both load in every session, but only the first 200 lines or 25KB of auto memory's index load at the start.

Claude treats both as context. They are not rules it is forced to obey. To block an action no matter what Claude decides, use a PreToolUse hook instead.

Where Do Your Instruction Files Go?

Each place has its own reach:

Claude loads them in order, from the broadest to the most specific. The files are joined together, so none of them replaces another. Files in the folders above where you start Claude load at launch, while files in subfolders load only when Claude needs them.

How Do I Start My First Instruction File?

Run `/init` in your project. Claude looks through your code and writes a starting file with the build commands, test steps and habits it finds. If you already have a CLAUDE.md, `/init` suggests changes instead of writing over it.

What Should Go In My Instruction File?

Put in the facts Claude needs in every session. Good examples are build commands, code style, project layout and "always do X" rules. A good time to add a line is when Claude makes the same mistake a second time.

Keep each file under 200 lines. Write rules that Claude can check. "Run `npm test` before committing" works better than "Test your changes." If two rules say opposite things, Claude may pick either one.

A long, step by step process belongs somewhere else. A skill loads only when a task needs it, and our guide to what goes in CLAUDE.md and what goes in a skill shows how to split them. For the timing side, see when each one loads.

You can also leave notes for people. Claude Code strips out HTML block comments, such as `<!-- maintainer notes -->`, before the file reaches Claude.

How Do I Pull Other Files Into My Instructions?

Write `@` and then the path, as in `@path/to/import`. This example line comes from the docs:

See @README for project overview and @package.json for available npm commands for this project.

A relative path starts from the file that holds the import. Imported files can import other files, up to four hops deep. To name a path without importing it, wrap it in backticks.

What Does Auto Memory Save?

Claude saves four kinds of notes for itself:

Claude skips anything it can work out from the code, such as file paths or bug fixes. It also skips what your CLAUDE.md already says.

When you tell Claude to remember something, like "always use pnpm, not npm," it saves that to auto memory. To put it in CLAUDE.md instead, ask Claude directly to add it there. You will see a message such as "Saved 2 memories" or "Recalled 2 memories" when Claude writes or reads its notes.

Where Does Auto Memory Live?

Each project gets its own folder at `~/.claude/projects/<project>/memory/`. All the worktrees and subfolders of one repo share that folder. The notes stay on your machine and are not shared with other machines or cloud sessions.

The folder holds a `MEMORY.md` index and one topic file for each memory. Only the first 200 lines or 25KB of `MEMORY.md` load when a conversation starts. Claude reads the topic files later, when it needs them.

To keep the notes somewhere else, set `autoMemoryDirectory` in your settings. The path must be absolute or start with `~/`.

{
  "autoMemoryDirectory": "~/my-custom-memory-dir"
}

How Do I Turn Auto Memory Off?

Auto memory is on by default in local sessions. To turn it off, open `/memory` and use the auto memory toggle. That saves `autoMemoryEnabled` to your user settings in `~/.claude/settings.json`.

To turn it off for one project, put this in that project's settings:

{
  "autoMemoryEnabled": false
}

You can also set `CLAUDE_CODE_DISABLE_AUTO_MEMORY=1` as an environment variable.

How Do I See And Edit My Memory?

Type `/memory` in a session. It lists your CLAUDE.md, your CLAUDE.local.md and your other memory files. It can also open the auto memory folder. Pick any file to open it in your editor.

The auto memory files are plain markdown, so you can edit or delete them at any time. To have Claude check your instruction files for old or conflicting rules, run `/doctor prompt-audit`. That command needs Claude Code v2.1.283 or later.

Which Plugins Help With Memory?

These plugins add more ways to keep and find what you learned:

The deja-vu docs give this install command:

claude plugin marketplace add vshulcz/deja-vu && claude plugin install deja-vu@deja-vu

FAQ

Do Subagents Get My Auto Memory?

They do not. The main conversation's auto memory isn't loaded into subagents. A fork is the one exception, because it inherits the parent conversation.

Can My Team Share Auto Memory?

It stays on one machine. To share rules with your team, put them in the project's CLAUDE.md and commit it.

Can Claude Use AGENTS Files Instead?

It can. Claude can read a repo's `AGENTS.md` files in place of CLAUDE.md.

Do Added Folders Load Their Instructions?

It does not by default. To load CLAUDE.md files from a folder you add, start Claude like this:

CLAUDE_CODE_ADDITIONAL_DIRECTORIES_CLAUDE_MD=1 claude --add-dir ../shared-config
Ad Sponsor this spot. Reach developers who pick skills