Memory between Claude Code sessions: CLAUDE.md, auto memory, MCP servers and transcript recall

Published · Updated

Claude Code does not remember anything between sessions. Every session starts with an empty context window, and whatever looks like memory was put there by one of a handful of mechanisms. They split into curated notes, which are short facts that someone or something wrote down, and recall over raw history, which means searching what was actually said. Most people end up wanting a bit of both.

If you want the quick routing: team rules go in a committed CLAUDE.md; what Claude learned about you and a repo is auto memory, on by default; a fact store Claude edits through tools is the MCP memory server; automatic capture and compression of every session is claude-mem or mem0; and finding what was said or run in an old session is transcript search, covered near the end.

Side by side

CLAUDE.mdAuto memoryMCP memory serverclaude-memmem0
What is storedInstructions you writeNotes Claude writesKnowledge graph: entities, relations, observationsCompressed observations and summaries of session activityMemories for user, session and agent state
Where./CLAUDE.md, ~/.claude/CLAUDE.md~/.claude/projects/<project>/memory/JSONL file, memory.jsonl by default, set by MEMORY_FILE_PATHSQLite at ~/.claude-mem/claude-mem.db, plus Chroma for vectorsNot stated in the README
Who can read itProject file: anyone with the repoAnyone with your account on that machineAnyone with the fileAnyone with your account; opt-in cloud sync and TeamBrainDepends on library, self-hosted server or cloud platform
Survives machine lossProject file: yes, via git. User file: noNo: machine-localOnly if you back up the fileOnly if backed up, or via opt-in cloud syncDepends on deployment
SearchableLoaded in full, no searchLoaded at start; plain markdown you can grepsearch_nodes over names, types and observationsYes: SQLite FTS5 and Chroma, through three MCP toolsYes, via its retrieval
Shared with a teamYes, through version controlNoNot by design; clients can share one fileOptional TeamBrainSelf-hosted server aimed at teams
CostFree; uses context every sessionFree; uses context every sessionFreeFree software; the observer agent needs an LLM (see below)Free library; needs an LLM key; hosted tier is paid

CLAUDE.md

Per the official memory documentation, CLAUDE.md files are instructions you write. They load every session and can sit at user, project or organization scope. A project file is shared through version control, and an organization can deploy a managed one. The docs suggest keeping each file under about 200 lines, since longer files cost context and reduce adherence.

It is context, not enforcement. The docs say Claude treats it as context, and a PreToolUse hook is the tool for rules that must hold. Build commands, conventions and "never do X in this repo" belong here; history does not.

Auto memory

Auto memory is notes Claude writes itself from your corrections and preferences, stored per repository at ~/.claude/projects/<project>/memory/. All worktrees of a repo share one directory. Only the first 200 lines or 25KB of MEMORY.md load at the start of each conversation, and detail lives in topic files. The files are plain markdown, and the docs say auto memory is machine-local: it is not shared across machines or cloud environments.

You can toggle it from /memory or with autoMemoryEnabled in settings, and relocate it with autoMemoryDirectory. The retention sweep does not delete it. It suits preferences, small corrections and repo quirks, and it is weak for anything you need on a second machine or a teammate needs.

The MCP memory server

The reference memory server is described in its README as "a basic implementation of persistent memory using a local knowledge graph". It exposes tools such as create_entities, add_observations, search_nodes and read_graph, and keeps everything in one JSONL file. The README advises setting MEMORY_FILE_PATH to an absolute path you own, since files under node_modules can be deleted when the server updates or the npx cache clears.

It is small and transparent, with no model in the loop. Claude decides what to write, which is also the limit: the graph is only as good as what the model chose to record, and nothing captures what actually happened.

claude-mem

According to the claude-mem README, hooks hand each tool call to a local worker, and a second "observer" agent writes observations and summaries into ~/.claude-mem. Search is staged through three MCP tools: search, timeline and get_observations. It is Apache 2.0 licensed, and content in <private> tags is not stored.

Read the cost section closely. The observer needs a provider: its own, your OpenRouter or Gemini key, or your Anthropic plan. The README describes a 30-day free trial for the first option that requires a payment method, then a fall-back to your Anthropic plan unless you subscribe. Anonymous analytics are on by default and can be disabled. It works with several agents beyond Claude Code, and cloud sync to cmem.ai and the shared TeamBrain workspace are optional. You get automatic, compressed memory, and you pay with an LLM pass over your activity and summaries that are lossy by design.

mem0

The mem0 README describes a memory layer for user, session and agent state, offered as a Python library, a self-hosted server run with Docker, and a hosted Cloud Platform. It requires an LLM; the default is OpenAI's gpt-5-mini, with text-embedding-3-small for embeddings, and other models are supported. The license is Apache 2.0.

It is aimed mostly at applications that remember their users, not at a developer's coding sessions. The README covers agent skills for Claude Code, but it has no turnkey session-capture setup, so using it for coding memory means assembling the integration yourself. It does not state its storage layout or pricing; check the project's pages.

Transcript recall

The raw transcripts at ~/.claude/projects/ are a fifth kind of memory, and the only one that records what was actually said and run. You can search them with grep, as in searching past conversations. They are deleted after 30 days by default (details), they live on one machine, and they are large. A curated note cannot stand in for them when you need the exact command or the reason for a decision, and when /compact drops detail the transcript on disk still has it, as this guide explains.

Choosing

Start with CLAUDE.md and auto memory, which cost nothing and need no setup, and add another layer only for a specific gap.

If you work on several machines, you need something that leaves the machine: commit shared rules to the repo, and use synced storage for the rest. If teammates repeat each other's mistakes, try the project CLAUDE.md first, and reach for a shared store only when the knowledge is too big or too situational. If you want recall without writing notes, the options are claude-mem-style capture, which brings a model pass and lossy summaries, or raw-history search.

Do not stack all of them. Everything injected at session start is re-sent with every request, so more memory is not free.

Sealkeep as the raw-history option

Sealkeep seals your Claude Code and Codex session files, uploads them to your own bucket, and makes them searchable with sealkeep search <query> --content. After sealkeep mcp install, the agent can search the vault itself. The index syncs across your machines as ciphertext, so history survives losing a laptop if you have your recovery phrase, and within a project, team mode shares context between invited accounts.

It does not write curated facts, summarize, or replace CLAUDE.md, and it has no knowledge graph. Recalled text is labelled untrusted historical data and should be checked against Git. The encryption format has not been independently audited. It is free with your own storage; Team is $9 per seat per month, per Sealkeep's llms.txt.

FAQ

Does auto memory survive a new laptop?

No. The docs say it is not shared across machines. Copy ~/.claude/projects/<project>/memory/ yourself, or set autoMemoryDirectory to a path you sync.

Is the MCP memory server production-ready?

Its README calls it a basic implementation and makes no production claim either way. For anything important, set MEMORY_FILE_PATH and back the file up.

Do I need claude-mem or mem0 if I use CLAUDE.md?

Only if you have a gap CLAUDE.md does not fill, such as automatic capture. Both need an LLM, which is a cost and a place your activity is sent.

See also: all guides.