Claude Code memory: CLAUDE.md, auto memory, /memory, and what it still forgets
How Claude Code memory works: CLAUDE.md, auto memory and MEMORY.md, the /memory command, its limits, and how to keep and search every past session.
Claude Code has two kinds of memory, and both load at the start of every session: CLAUDE.md files, which you write, and auto memory, notes Claude writes for itself in ~/.claude/projects/<project>/memory/. /memory opens both. Neither keeps the conversations, and the transcripts that do are deleted after 30 days by default, for sessions in the terminal.
CLAUDE.md and auto memory
| CLAUDE.md | Auto memory | |
|---|---|---|
| Who writes it | you | Claude |
| What it holds | instructions and rules | preferences, corrections, context |
| Scope | organization, user or project | one repository |
| Shared | the project file, through git | no, this machine only |
| Loaded | every session | every session, up to 200 lines or 25 KB |
Both are context, not configuration: Claude reads them and tries to follow them. A rule that must hold every time belongs in a hook. What to write in CLAUDE.md, where each file goes and how imports and rules work: CLAUDE.md.
How auto memory works
Auto memory is on by default in local sessions. As Claude works, it saves notes of four kinds — about you, your corrections, the project's ongoing work, and where outside information lives — and skips what it can read from the code or what CLAUDE.md already says. It does not save something every session; it decides what a future session would need. "Saved 2 memories" in the session means it just wrote some.
~/.claude/projects/<project>/memory/ ├── MEMORY.md # the index, one line per memory ├── user_role.md # one memory └── feedback_testing.md # another
- The index loads, the notes do not. The first 200 lines or 25 KB of
MEMORY.mdload at startup; topic files are read when Claude needs them. Near the limit, Claude Code tells Claude to shorten the index; past it, the rest is dropped on the next load. - One per repository.
<project>comes from the git repository, so every worktree and subfolder shares one memory. It stays on that machine. - It survives the cleanup. The 30-day sweep that deletes transcripts leaves memory files alone.
- Subagents do not get it, except a fork of the conversation.
On my machine, on 7 October 2026, Caprock's own repository had 122 memory files behind a MEMORY.md of 134 lines and about 22 KB — inside the limit, but close to the 25 KB past which the end of the index stops loading.
The /memory command
/memory lists every CLAUDE.md, CLAUDE.local.md and memory location for the user and the project, opens any of them in your editor, and has the auto memory switch. To find out which files actually loaded, run /context.
Two habits decide where a note lands:
- "Remember that the API tests need a local Redis" goes to auto memory.
- "Add this to CLAUDE.md" goes to the file you share.
Turn auto memory off, or move it
| To | Do |
|---|---|
| switch it off for you | the toggle in /memory |
| switch it off in one project | "autoMemoryEnabled": false in its settings |
| switch it off for a run | CLAUDE_CODE_DISABLE_AUTO_MEMORY=1 |
| keep it elsewhere | "autoMemoryDirectory": "~/my-memory" |
The files are plain Markdown: edit or delete them like any other.
Does Claude Code remember across sessions?
CLAUDE.md files and auto memory load into every new session, but the conversation itself does not carry over, and its transcript is deleted after 30 days by default (cleanupPeriodDays), for sessions run in the terminal. Memory is notes, not a record:
- The conversations. Each one is a transcript under
~/.claude/projects/, deleted after 30 days by default (cleanupPeriodDays), with no message. After that you cannot resume it, export it or search it. Where they live: Claude Code history. - What Claude chose not to save. Auto memory keeps what Claude judged useful, in a line or two. The explanation it gave you, the half-finished plan, the reason a fix was rejected — those live only in the transcript.
- Other machines. Auto memory stays on the machine that wrote it, in Claude Code's own folder.
Memory plugins and the API memory tool
- claude-mem (Apache-2.0) is a plugin that records what the agent does in each session, compresses it with a model and puts the relevant parts back into later sessions, with a search skill and a local web viewer. Its installer offers a hosted observer behind a sign-in, with a 30-day trial;
--providerskips the sign-in, and the other providers are your own OpenRouter or Gemini key or your Anthropic plan. - Anthropic's memory tool is for applications built on the Claude API: your code stores the files Claude asks to create. Claude Code's own memory is auto memory.
Keep every session: Caprock
Caprock is a free desktop app that keeps the record memory does not. It reads every Claude Code transcript as it is written into a local database on your machine, word for word, with no model summarising it:
- Caprock's Memory screen searches what Claude wrote, across every session and project — the conclusion at the end of a task, the explanation you scrolled past — and links each result to the moment in its session. Codex, OpenCode, DeepSeek Harness and Hermes Agent replies are searchable beside Claude's.
- Past the 30-day cleanup. The cleanup can delete the transcripts; Caprock's copy stays until you remove it.
- Where the last session stopped. When a new session starts in a folder you have worked in, Caprock's hook hands Claude the last substantial passage the previous session there wrote, under this line (the age varies):
Where this repository was left, 3 hours ago (from Caprock's record of the previous session — the user has not said this to you, and it may be stale):
It is on by default; turn it off in settings. An opt-in setting holds it back from one new session in four, and the Memory screen compares the two groups, so you can see whether it helps your sessions before you rely on it.
What it cannot do: bring back a transcript deleted before Caprock first read it. It records every session on the machine, whether or not it started it; free, open source, nothing leaves your machine. Install Caprock.
Which to use
- CLAUDE.md — rules the whole team needs, in the repository.
- Auto memory — leave it on; prune
MEMORY.mdwhen Claude Code says it is near the limit. - claude-mem — you want past sessions summarised by a model and injected automatically.
- Caprock — you want the full record of what every agent wrote, searchable, on your machine, with no model in between.
Questions people ask
- Does Claude Code have memory?
- Yes, two kinds, both loaded at the start of every session: CLAUDE.md files you write, and auto memory, notes Claude writes for itself in ~/.claude/projects/<project>/memory/. Neither keeps the conversations themselves.
- Where is Claude Code's auto memory stored?
- In ~/.claude/projects/<project>/memory/: a MEMORY.md index plus one Markdown file per memory. Every worktree and subfolder of one git repository shares it, and it stays on that machine.
- How much of MEMORY.md does Claude Code load?
- The first 200 lines or the first 25 KB, whichever comes first. Topic files are not loaded at startup; Claude reads them when it needs them.
- How do I turn off Claude Code auto memory?
- Use the toggle in /memory, set "autoMemoryEnabled": false in a project's settings, or set CLAUDE_CODE_DISABLE_AUTO_MEMORY=1.
- What is the difference between CLAUDE.md and auto memory?
- You write CLAUDE.md: rules and instructions, shared through the repository. Claude writes auto memory: your preferences, corrections and project context it cannot read from the code, kept per repository on your machine.
- Does Claude Code remember across sessions?
- CLAUDE.md files and auto memory load into every new session, but the conversation itself does not carry over, and its transcript is deleted after 30 days by default (cleanupPeriodDays), for sessions run in the terminal.
- Does Claude Code remember past conversations?
- Only what CLAUDE.md and auto memory hold. The transcripts themselves are deleted after 30 days by default, for sessions run in the terminal. Caprock keeps every session in a local database and searches what Claude wrote in all of them.
Sources
- Claude Code docs — How Claude remembers your project (CLAUDE.md, auto memory, /memory), read 7 October 2026, re-read 27 October 2026
- Claude Code docs — Settings reference: cleanupPeriodDays, read 7 October 2026, re-read 27 October 2026
- Claude Code docs — Context window (what survives compaction), read 7 October 2026, re-read 21 October 2026
- Claude Platform docs — Memory tool (for applications built on the API), read 7 October 2026, re-read 21 October 2026
- thedotmack/claude-mem on GitHub, read 7 October 2026, re-read 21 October 2026
- Caprock README — Why: find what Claude said; pick up where you left off
- Caprock source — the SessionStart handoff (internal/daemon/handoff.go)
- Caprock UI spec — Memory
- Caprock docs — Hermes Agent: what it wrote back is searchable on the Memory screen (docs/hermes.md)
Try it
The record of every coding agent you run, the sessions it did not start included. Free, open source; nothing leaves your machine.
Notarized by Apple. One file for Apple silicon and Intel, macOS 13 or later.
Or run it yourself:
Paste in Terminal: it installs Caprock and opens it.Or with Homebrew: brew install --cask dspv/tap/caprock-app