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/CLAUDE.md` holds your personal preferences for all of your projects.
- `./CLAUDE.md` or `./.claude/CLAUDE.md` holds the team's instructions for one project, and you share it through source control.
- `./CLAUDE.local.md` holds your own notes for one project. Add it to your `.gitignore`.
- A managed policy file holds rules for a whole company. On Linux and WSL, it lives at `/etc/claude-code/CLAUDE.md`.
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:
- A user note covers your role, your skills and how you like to work.
- A feedback note covers corrections you give and approaches you confirm.
- A project note covers ongoing work, deadlines and decisions that Claude can't get from the code or the git history.
- A reference note says where to find things outside the project, such as an issue tracker.
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:
- claude-md-management audits your CLAUDE.md files. Its `/revise-claude-md` command updates CLAUDE.md with what you learned in the session.
- remember sums up your conversations in daily logs. It can also write a handoff note, so the next session picks up where you stopped.
- pensyve connects Claude Code to a memory store through MCP. Saving and recall depend on the agent following its steps and on the MCP server being up.
- deja-vu recalls your past sessions from every coding agent on your machine. It brings an MCP server, a `deja-history` skill and a `/deja` command.
- episodic-memory lets Claude search your past conversations by meaning. It covers Claude Code, Codex, Cursor, opencode and Oh My Pi.
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