The Auto-Memory System — Teaching Claude to Remember
Every session with an AI assistant starts from zero. The preference you expressed last Thursday, the architecture decision you made with Claude two weeks ago, the correction you gave when Claude recommended the wrong library — all of it is gone. You re-establish context from scratch, every time.
The auto-memory system changes this. It is a file-based persistence layer that survives across sessions. At the start of every conversation, Claude reads a memory index. The memories in that index shape how Claude understands your project, your role, and your working preferences before you type the first message.
Where Memories Live
The memory directory is at:
The <project-hash> is a deterministic hash of your project's absolute path. If you always open Claude Code from the same directory, you always get the same memory directory. If you open it from a different path, you get a different memory context.
The directory structure:
MEMORY.md is the index. It is the only file guaranteed to be read at session start. Every other file is referenced from the index and loaded on demand. Keep the index under 200 lines — lines beyond 200 are truncated.
The Four Memory Types
Each memory file has a type field in its frontmatter. The type determines how the memory is used:
user — Who you are and how you work. Role, expertise level, domain background, working preferences. Used to tailor explanations and recommendations to your specific context.
Example of a useful user memory:
feedback — Corrections and validated approaches. What Claude got wrong and how to avoid it. What unusual approaches were confirmed to work.
Structure for feedback memories: Lead with the rule, then Why: (the reason), then How to apply: (when it triggers).
project — Ongoing context, decisions, and constraints that change over time. Current initiatives, architectural decisions, deadlines, stakeholder constraints.
Structure: Lead with the fact, then Why: (motivation), then How to apply: (how it shapes recommendations).
reference — Pointers to external systems and where to find authoritative information.
What Makes a Good Memory vs a Bad Memory
Not everything worth knowing belongs in memory. The most important distinction: memory is for what is true across sessions, not what is true for this session.
Good candidates for memory:
- Your role and expertise (user type)
- Corrections you have given before that you will need to give again (feedback type)
- Architectural decisions with rationale (project type)
- Where to find external information (reference type)
- Non-obvious project constraints (project type)
Bad candidates for memory (do not save these):
- Code patterns, conventions, file paths — derivable by reading the code
- Git history —
git logis authoritative - In-progress work from the current session — that's task state, not memory
- Debugging solutions — the fix is in the code; the commit message has the context
- PR lists or activity summaries — too ephemeral; only the surprising part is worth keeping
When in doubt: if Claude can find it by reading the current project state, do not put it in memory. Memory is for context that is not in the code.
The MEMORY.md Index
MEMORY.md is the file that loads at every session start. It must be concise — 200 lines maximum, one line per memory entry.
Format: - [Title](file.md) — one-line hook
The one-line hook is what Claude reads to decide whether to load the full memory file. Make it specific. "User profile" is not a hook — it tells Claude nothing about whether the file is relevant to the current task. "Python backend engineer, new to Next.js; frame frontend in Python terms" tells Claude to load this file when working on frontend tasks.
Writing a Memory File
Every memory file uses the same frontmatter format:
For feedback and project memories, use the structured format:
feedback format:
project format:
The Why: and How to apply: lines serve a specific purpose: they let Claude make judgment calls about edge cases instead of blindly following the rule. "Never touch the auth middleware" is a rule. "Never touch the auth middleware because the compliance audit uses a snapshot from the 15th and any change invalidates it" is a rule with context that lets Claude handle exceptions intelligently.
Updating and Removing Stale Memories
Memories decay. An architectural decision made 6 months ago may have been reversed. A project deadline that was "next Thursday" is now past. A constraint that applied to the MVP may not apply to v2.
Signs a memory is stale:
- It references relative dates ("next Thursday", "this sprint") that have passed
- It describes work that is now complete
- It mentions constraints that no longer apply
- It conflicts with what you observe in the current codebase
When Claude uses a stale memory, it will make recommendations based on incorrect context. This is worse than no memory — it is confidently wrong.
Updating a memory: Find the file, edit the content, update the description in MEMORY.md if the hook changes. No special command needed.
Removing a memory: Delete the file, remove its line from MEMORY.md. Clean memory is better than cluttered memory.
Rule: Before acting on a recalled memory, verify it against current state. "The memory says X file exists" is not the same as "X file exists now." File paths, function names, and architectural decisions should be verified before recommending based on them.
Memory and the Other Intelligence Layers
Memory integrates with two other components of the intelligence layer:
learning-from-experience uses the memory directory to store solved patterns. When you solve a novel problem, the pattern is stored as pattern_<domain>_<keyword>.md and indexed in MEMORY.md. These patterns are then searchable in future sessions. Lesson 10 covers this in full.
task-intake reads memory at the start of every task. When it searches for relevant patterns, it is searching the memory directory. When it announces "Found 2 relevant patterns," it found them in memory files that were stored by previous learning-from-experience invocations.
The three components form a loop: task-intake reads memory → work completes → learning-from-experience writes to memory → next session's task-intake finds the pattern. Each completed task improves future sessions.
Practical: Your First Memory File
After finishing lesson 2 (installing Superpowers), write your first user memory:
- Create
~/.claude/projects/<your-project-hash>/memory/user_profile.md:
- Create
~/.claude/projects/<your-project-hash>/memory/MEMORY.md:
- Start a new Claude Code session and observe how it greets you differently.
The difference is subtle at first — Claude's initial assessment and question framing will reflect what it knows about you. Over time, as you add feedback and project memories, the difference becomes substantial.
Key Takeaway
The auto-memory system is a file-based layer at ~/.claude/projects/<hash>/memory/. MEMORY.md is the session-loaded index — keep it under 200 lines. Four memory types: user (who you are), feedback (corrections and validated approaches), project (ongoing context and decisions), reference (where to find external information). Good memories are non-derivable from the current codebase, session-independent facts. Bad memories are code patterns, current task state, and anything git log can tell you. Verify memories against current state before acting on them. Remove stale memories aggressively.