Back to Blog
claude-codememoryhow-toclaude-mdcontext

Claude Code Memory: Keep Context Across Sessions (CLAUDE.md)

How Claude Code memory works: CLAUDE.md holds the rules you write, auto memory holds notes Claude writes. Both load every session. Where they live and which to use.

C
Crewly Team
4 min read
Share

Table of Contents

Claude Code memory works through two things that load at the start of every session. CLAUDE.md holds instructions you write. Auto memory holds notes Claude writes itself from your corrections. A new session starts with an empty context window, so anything else you said is not there. claude --continue or claude --resume reopens an old conversation, but only CLAUDE.md and auto memory carry into a fresh one.

CLAUDE.md filesAuto memory
Who writes itYouClaude
What it holdsInstructions and rulesLearnings and patterns
ScopeProject, user or organizationPer repository, shared across worktrees
LoadedEvery sessionEvery session (first 200 lines or 25KB)

Source: Claude Code's memory documentation, read on 9 October 2026. Claude treats both as context, not as enforced configuration.

What carries over into a new session: CLAUDE.md and auto memoryWhat carries over into a new session: CLAUDE.md and auto memory

CLAUDE.md: the rules you repeat

  • Keep it under 200 lines. Longer files use more context and reduce adherence. Rules for part of the codebase go in .claude/rules/, which load only when Claude works with matching files.
  • Imports organize, they do not shrink. Files pulled in with @path/to/file load at launch too.
  • Be specific. The more concise and specific the instruction, the more consistently Claude follows it.

Auto memory: notes Claude writes

Each project gets ~/.claude/projects/<project>/memory/, with a MEMORY.md index and one file per topic.

  • Machine-local. All worktrees of the same git repository share it; other machines do not.
  • The index has a limit. Only the first 200 lines or 25KB of MEMORY.md load. Keep one line per entry, detail in topic files.
  • You can read and change it. The files are plain Markdown. /memory lists them and holds the on/off toggle.

How to choose

You want to...Use
Fix the build and test commands, conventions, off-limits foldersCLAUDE.md
Have Claude remember a correction you made onceAuto memory
Apply a rule to only some foldersA file in .claude/rules/
Share rules with teammatesCommit the project CLAUDE.md (auto memory stays on your machine)
Make sure something never happensA PreToolUse hook, not memory
Share what several agents learn on one projectCrewly remember and recall (below)

Five-minute setup

  1. Write a short CLAUDE.md at the project root: build command, test command, conventions, off-limits folders.
  2. Run /memory and check CLAUDE.md is listed and auto memory is on.
  3. Correct Claude once in plain words, such as "we run tests with the check script, not test", then look in the memory folder for the saved note.
  4. After a week, open MEMORY.md, delete stale lines and merge duplicates.

When you run several agents

CLAUDE.md and auto memory assume one person and one session. Crewly, the open-source tool we make, adds two skills for a team of agents. remember stores a note with scope agent (personal) or project (shared by every agent on the project). recall searches the saved notes. A new decision can name the old one with --supersedes, so agents stop treating the old one as current. This does not replace CLAUDE.md. Setup: How to run multiple agents in Claude Code.

FAQ

Does Claude Code remember things between sessions?

Yes, through two mechanisms: CLAUDE.md files you write and auto memory Claude writes. Both load at the start of every new conversation. Only they carry into a fresh session; claude --continue or --resume reopens an old conversation instead.

Where does Claude Code store auto memory?

In ~/.claude/projects/<project>/memory/, with a MEMORY.md index. It is machine-local and shared by all worktrees of the same repository.

How big can MEMORY.md be?

The first 200 lines or 25KB load at the start of every conversation. Content beyond that does not, so keep one line per entry.

Sources

How Claude remembers your project, read on 9 October 2026. Crewly memory: the remember and recall skill definitions in the Crewly repository, checked on 9 October 2026.

Ready to orchestrate your AI team?

Get started with Crewly. Run multiple Claude Code, Codex, or Antigravity agents as a coordinated team.

curl -fsSL https://crewlyai.com/install.sh | bashRead the docs →

Open a new terminal and run:

crewly start

Want an AI team built and run for you instead? See For Business →

Related Articles