Claude Code memory: what it keeps, and where
Claude Code remembers between sessions through CLAUDE.md, which you write, and auto memory, which it writes. Where each lives, its limits, how to add more.
On this page
Claude Code memory is two sets of Markdown files that load at the start of every session. CLAUDE.md holds the instructions you write, in your repository or in ~/.claude, and loads whole. Auto memory holds notes Claude writes for itself, in ~/.claude/projects/<project>/memory/, and only the first 200 lines or 25KB of its MEMORY.md index load. Everything else in a session, the conversation itself, is gone when you start a new one. Both kinds of memory are context Claude reads, not rules it must obey, and auto memory stays on the machine that wrote it.
This page is the short answer and a map of the longer ones. It is from Claude Code’s memory documentation, checked on 27 November 2026. These details change between versions, so check the linked page if yours behaves differently.
| Who writes it | Where it lives | When it loads | Limit | |
|---|---|---|---|---|
CLAUDE.md |
You | ./CLAUDE.md or ./.claude/CLAUDE.md, ~/.claude/CLAUDE.md, a managed file for your organization |
Whole, at the start of every session | Aim for under 200 lines; a file over 4 MiB is skipped |
CLAUDE.local.md |
You | ./CLAUDE.local.md, kept out of git |
With CLAUDE.md |
As CLAUDE.md |
.claude/rules/ |
You | ./.claude/rules/*.md, ~/.claude/rules/ |
At launch, or with paths, when Claude touches a matching file |
A per-file limit for rules that load on demand |
| Auto memory | Claude | ~/.claude/projects/<project>/memory/, one folder per repository |
The first 200 lines or 25KB of MEMORY.md; each note when Claude needs it |
The index past that point isn’t loaded |
AGENTS.md |
You | ./AGENTS.md |
By default only when no CLAUDE.md or CLAUDE.local.md is found |
As CLAUDE.md |
| Session transcripts | Claude Code | Local transcript files | Only when you resume with --continue or --resume |
Deleted after 30 days by default |
What Claude Code remembers between sessions
Each Claude Code session starts with a fresh context window. What carries over is only what is written to a file that loads again.
Your instructions. Every CLAUDE.md and CLAUDE.local.md in your working folder and the folders above it loads at launch. Those in subfolders load once Claude reads or edits a file there. .claude/rules/ files without paths load at launch too. The docs’ advice is to put here what you’d otherwise explain again: build commands, conventions, project layout, “always do X” rules.
Claude’s own notes. Auto memory is on by default in local sessions. Claude saves four kinds of note: who you are and how you work, corrections you gave it, ongoing work it can’t read from the code, and where to find things outside the project. It skips what the code or your CLAUDE.md already say. When you ask Claude to “remember” something, it goes here.
Not the conversation. What you said, what was tried, what failed: none of it reaches the next session unless it was written down. You can reopen an old conversation with claude --continue or claude --resume, which is going back to that session rather than remembering it. When to resume and when to start fresh with a handoff note covers that choice.
Where Claude Code’s memory files are
- Project instructions:
./CLAUDE.mdor./.claude/CLAUDE.md, committed and shared with your team. - Your instructions for every project:
~/.claude/CLAUDE.md, and rules in~/.claude/rules/. - Your instructions for one project:
./CLAUDE.local.md. Add it to.gitignore. - Organization instructions:
/Library/Application Support/ClaudeCode/CLAUDE.mdon macOS,/etc/claude-code/CLAUDE.mdon Linux,C:\Program Files\ClaudeCode\CLAUDE.mdon Windows. - Auto memory:
~/.claude/projects/<project>/memory/, withMEMORY.mdas the index and one file per memory. The folder is named from the git repository, so every worktree and subfolder of one repository shares it.
Run /memory to see the list, open any file, open the auto memory folder or turn auto memory off. Run /context all to see which instruction files loaded, under Memory files. CLAUDE.md vs MEMORY.md vs AGENTS.md says what belongs in each.
The limits of Claude Code memory
It is advice, not enforcement. The docs say both kinds of memory are context, “not enforced configuration”. A rule that must never be broken needs a hook or a deny rule. Why your AI agent keeps reverting your fix shows the difference.
A long CLAUDE.md is followed less well. The docs’ target is under 200 lines per file, because “longer files consume more context and reduce adherence”. Imports with @path don’t help: imported files load in full. Your CLAUDE.md is too long sorts what to move out.
The auto memory index has a ceiling. Only the first 200 lines or 25KB of MEMORY.md load. Claude Code tells Claude to shorten the index as it nears the limit, and anything past it is dropped on the next load.
Auto memory stays on one machine. The docs say its files “are not shared across machines or cloud environments”. You can point it somewhere else with the autoMemoryDirectory setting, and sync that folder yourself.
It belongs to Claude Code. Codex, Cursor and Gemini CLI can read a shared AGENTS.md, but not what Claude learned. Cursor memories vs rules lays out what each agent keeps, and AGENTS.md shares rules, not memory what crosses between them.
Compaction loses chat-only instructions. When a long session is summarized, the root CLAUDE.md is read again from disk, but rules you only said in the chat may be lost. Why Claude Code forgets after compaction explains what survives.
Subagents start without it. The main conversation’s auto memory isn’t loaded into subagents, except a fork, which inherits the conversation.
How to give Claude Code more memory
Start with what’s built in, and add a layer only when one of the limits above is the one you keep hitting.
- Write it into
CLAUDE.md. When Claude makes the same mistake twice, the fix is a line in the file that loads whole./initdrafts a first one from your codebase. - Scope it with rules. An instruction for one part of the code goes in
.claude/rules/withpaths, so it loads only there. - Make procedures skills. A multi-step routine loads only when it’s needed, not in every session.
- Enforce with hooks. A
PreToolUsehook blocks an action whatever Claude decides. ASessionStarthook can load context on every start, including after compaction. - Write a handoff note when you stop mid-task. The template keeps it to the state of one task.
- Add a memory server when you use several agents, work across many projects or need decisions with a history. Claude Code memory: built in, or a server? is the test for whether you need one, and What is an MCP memory server? what one is.
Every guide on Claude Code memory
Each of these answers one question in full.
- Claude Code memory: built in, or a server?: when
CLAUDE.mdand auto memory are enough, and when a memory server over MCP earns its place. - CLAUDE.md vs MEMORY.md vs AGENTS.md: who writes each file, where it lives, when it loads, and why
CLAUDE.local.mdcan stopAGENTS.mdloading. - Your CLAUDE.md is too long: what to move out: sort every line into a rule, a procedure, a hard limit, a decision or a fact.
- Why Claude Code forgets after compaction: what a compaction summary keeps, what it drops, and how to steer it.
- Claude Code session handoff: a template: a file the next session reads first, and when to use
--resumeinstead. - AGENTS.md in Claude Code: why it isn’t loading: when Claude Code reads
AGENTS.md, how to check, and the fix for each reason it doesn’t. - Cursor memories vs rules: what each agent keeps: Claude Code’s memory beside Cursor’s, Codex’s and Gemini CLI’s.
- AGENTS.md shares rules, not memory: giving Claude Code and Cursor the same rules, and why their memories stay apart.
- claude-mem alternatives: capture vs curate: recording every Claude Code session, or keeping notes on purpose.
- Obsidian with Claude Code: MCP, CLI or skills?: three ways to give Claude Code your Obsidian vault.
- Types of AI agent memory, mapped to code: working, procedural, semantic and episodic memory, as the files Claude Code uses.
Where Memorinth fits
Memorinth is a memory server for the part Claude Code keeps per machine and per tool: what was learned and decided. It’s a folder of Markdown notes, your cortex, that Claude Code, Codex, Cursor and Gemini CLI all read and write over MCP. Agents search it with search_memory instead of loading it whole, and a session-start hook gives Claude Code a briefing of current decisions, facts and recent memories. It leaves your CLAUDE.md alone: instructions stay there, and What goes where draws the line.
If the built-in memory covers you, keep it. If not, install the CLI and run:
$ memorinth initGive Claude Code a long-term memory walks through the setup, and How agents use it explains the briefing and when agents save.