Memory Hierarchy

claude-code has five distinct memory systems operating at three scopes. This is not one memory system — it is a layered hierarchy where each level serves a different purpose, persistence, and access pattern.

The Five Systems

# System Who Writes It Scope Persistence
1 CLAUDE.md User Global + Project Permanent until user edits
2 auto-memory Claude Project Permanent, consolidated by auto-dream
3 Session memory Claude Session Per-session transcript
4 Team memory Agents Team Shared across teammate-tool agents
5 Agent memory Agent Per-agent Private to each spawned agent

Three Scopes

Scope What Lives Here Loaded When
Global ~/.claude/CLAUDE.md, global rules Every session
Project ./CLAUDE.md, .claude/rules/*.md, ~/.claude/projects/<slug>/memory/ When entering project directory
Session Conversation transcript, tool results, compacted context Current session only

Loading Order

The system prompt is assembled from six layers on every query turn (not just session start). CLAUDE.md is reloaded every turn and supports up to 40,000 characters:

  1. ~/.claude/CLAUDE.md (global user rules)
  2. ./CLAUDE.md (project root)
  3. .claude/rules/*.md (modular rules, alphabetical)
  4. ~/.claude/projects/<slug>/memory/MEMORY.md (auto-memory index, first 200 lines only)
  5. system-reminders (40+ behavioral injections at tool boundaries)
  6. Session context (conversation history, tool results)

The Three-Layer Auto-Memory Architecture

Within the auto-memory system, a three-layer hierarchy exists:

auto-dream is the garbage collector for this hierarchy.

Key Design Decision

The memory system deliberately rejects embeddings and vector search. Claude calls ls(), reasons about relevance from filenames, then reads selected files. See grep-over-rag.

Key Claims

Sources