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.md or ./.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.md on macOS, /etc/claude-code/CLAUDE.md on Linux, C:\Program Files\ClaudeCode\CLAUDE.md on Windows.
  • Auto memory: ~/.claude/projects/<project>/memory/, with MEMORY.md as 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.

  1. Write it into CLAUDE.md. When Claude makes the same mistake twice, the fix is a line in the file that loads whole. /init drafts a first one from your codebase.
  2. Scope it with rules. An instruction for one part of the code goes in .claude/rules/ with paths, so it loads only there.
  3. Make procedures skills. A multi-step routine loads only when it’s needed, not in every session.
  4. Enforce with hooks. A PreToolUse hook blocks an action whatever Claude decides. A SessionStart hook can load context on every start, including after compaction.
  5. Write a handoff note when you stop mid-task. The template keeps it to the state of one task.
  6. 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.

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 init

Give Claude Code a long-term memory walks through the setup, and How agents use it explains the briefing and when agents save.

All posts