Intermediate11 min
Claude Code Memory — How It Stores Context and How to Control It
Learn how Claude Code manages context across a session and between sessions — from conversation history and auto-compaction to CLAUDE.md, the /memory command, and strategies for long-running work.
Quick Reference
- →Conversation context = everything in the current session (messages, file reads, tool results)
- →CLAUDE.md = persistent project knowledge loaded into every conversation
- →/memory command stores small notes that persist across sessions
- →Auto-compact kicks in when context approaches the token limit
- →After compaction, Claude loses fine detail but keeps the big picture
- →/compact manually triggers compaction to reclaim context space
- →Tasks (TodoWrite) track progress within a session — not persisted across sessions
- →For multi-session work, commit often and leave clear git messages
The Three Types of 'Memory' in Claude Code
When people say 'Claude Code memory,' they could mean three very different things. Understanding the distinction is key to working effectively across sessions.
| Type | Scope | Persists? | You Control It? |
|---|---|---|---|
| Conversation context | Current session only | No — gone when you close the session | Partially — /compact, message length |
| CLAUDE.md files | Every session in this project | Yes — stored as files in your repo | Yes — you edit them directly |
| /memory notes | All future sessions | Yes — stored in ~/.claude/ | Yes — /memory add/remove |
The mental model
Think of it like human memory: conversation context is your working memory (limited, fades), CLAUDE.md is your notebook (written down, always available), and /memory is your personal notes app (small facts you want to remember everywhere).