Back to Claude Code hub
INTERMEDIATEsnapshot-basedVerified 2026-03-31core

Context and Memory

How Claude Code builds working context and persistent memory

Understand the difference between session context, CLAUDE.md instructions, MEMORY.md indexing, and relevance-based memory recall.

Session context and persistent memory are different systems

Claude Code separates working context from persistent memory. Session context is what the current turn sees immediately. Memory is what can survive into future conversations.

That distinction matters because not every useful fact belongs in a persistent store.

  • Git status and current date are session context.
  • Discovered CLAUDE.md instructions are session context.
  • Typed memory files are long-lived persistence.

CLAUDE.md is loaded as user-level operating guidance

Claude Code walks for CLAUDE.md-style instruction files unless the relevant environment or mode settings disable that behavior.

Those instructions are treated as collaboration guidance for the current project, not as a generic profile for all future conversations.

  • Bare mode changes discovery behavior.
  • Explicit add-dir behavior is treated differently from automatic discovery.
  • Loaded CLAUDE.md content is cached for the session.

MEMORY.md is an index, not the memory itself

The memory system expects a file-based directory with a special entrypoint file called MEMORY.md.

MEMORY.md is intentionally kept concise and acts as an index into richer topic files rather than a dumping ground for long notes.

  • Memory files have typed frontmatter.
  • The index has size limits and truncation warnings.
  • The system encourages semantic organization rather than chronological dumping.
A useful rule: use plans and tasks for current work, and reserve memory for things that should matter in future conversations.

Relevant memories are selected, not blindly loaded

Claude Code scans memory headers and then uses a side-query to select only the memories likely to help with the current user request.

This keeps memory recall selective instead of flooding the conversation with every saved fact.

  • Selection is capped to a small number of high-confidence files.
  • Already-surfaced memories are filtered to avoid waste.
  • Tool reference memories can be deprioritized if the tool is already active in the session.

Learn next

These guides are adjacent to the current topic and make the learning path easier to follow.