Memory System
Claude Code persists information between sessions using a file-based memory system in ~/.claude/. It uses 4 typed memory categories and an index file (MEMORY.md) that is always loaded into context.
Memory types
User
· Role, preferences, knowledge levelExample: "Is a data scientist, new to React. Explain frontend concepts via backend analogues."
When to save: When you learn about the user's background, goals, or working style.
Feedback
· Corrections and validated approachesExample: "Don't mock the database in tests. A previous incident showed mock/prod divergence breaks migrations."
When to save: When the user corrects an approach OR confirms a non-obvious choice worked.
Project
· Ongoing work, deadlines, incidentsExample: "Merge freeze begins 2026-03-05 for mobile release cut. Flag non-critical PRs after that date."
When to save: When you learn who is doing what, why, or by when. Relative dates are converted to absolute.
Reference
· Pointers to external systemsExample: "Pipeline bugs are tracked in Linear project INGEST."
When to save: When you learn about resources in external tools (Linear, Grafana, Slack channels, etc.).
File structure
Each memory is stored as a separate markdown file with YAML frontmatter. MEMORY.md is the index.
~/.claude/projects/<slug>/memory/
├── MEMORY.md # index, max 200 lines / 25KB
├── user_role.md
├── feedback_testing.md
└── reference_tools.md