Auto memory in Claude Code: Claude remembers your habits on its own
TL;DR
Auto memory lets Claude Code take its own notes from your corrections and confirmations and read them in later sessions. Only MEMORY.md (200 lines or 25KB) loads each session; clean it regularly, never store secrets, and move shared conventions into CLAUDE.md.
For the fifth time you remind Claude Code to "use pnpm, not npm" or "don't run the e2e tests, they're slow". Each new session starts with an empty context, so it forgets. CLAUDE.md solves part of this, but you have to write it yourself. Auto memory is the other half: Claude takes its own notes from your corrections and confirmations and reads them back in later sessions. Understanding how it works lets you benefit without letting it bloat your token usage.
CLAUDE.md vs auto memory
| CLAUDE.md | Auto memory | |
|---|---|---|
| Who writes it | You | Claude |
| Contents | Instructions, rules | Learnings, habits, context |
| Scope | Project, user, organisation | Per repository, shared across worktrees |
| Loaded into | Every session | Every session (first 200 lines or 25KB of MEMORY.md) |
What does Claude remember?
Four kinds, recorded in a type field in each file's frontmatter:
user: your role, expertise and working preferences.feedback: corrections you give and approaches you confirm.project: ongoing work, deadlines and decisions not derivable from code or git.reference: where to find information outside the project (trackers, dashboards).
Claude skips anything derivable from the codebase (architecture, paths, bug fixes) and anything CLAUDE.md already says. It doesn't save something every session.
Where it's stored and how it loads
~/.claude/projects/<project>/memory/
├── MEMORY.md # index, one line per memory, loaded every session
├── user_role.md
├── feedback_testing.md
└── ...
- Only the first 200 lines or 25KB of
MEMORY.mdload at session start; anything beyond is dropped. Claude Code reminds Claude to shorten it near the limit. - Topic files are not preloaded; Claude reads them on demand with its file tools. That's a token-saving design: only the index occupies standing context.
- Memory is machine-local, not synced across machines, and isn't removed by the transcript cleanup sweep.
Turning it on, off and managing it
- On by default in local sessions. Open
/memoryto view, edit and toggle it (saved asautoMemoryEnabled). - Off for one project:
{"autoMemoryEnabled": false}in that project's settings; via environment:CLAUDE_CODE_DISABLE_AUTO_MEMORY=1. - Change the location with
autoMemoryDirectory(an absolute path or one starting with~/). - You can just say: "remember that this project deploys with script X" and Claude will save it.
Risks and caveats
- Memory is context, not law: Claude treats it as guidance; use hooks for must-haves.
- Wrong memory is worse than none: a stale note loads every session. Open
/memoryoccasionally to clean up. - Sensitive information: memory is plain text on disk; don't let Claude store tokens or passwords.
- Not shared with the team: shared team conventions belong in a committed CLAUDE.md, not auto memory.
How to apply it
- Dev: When you correct Claude on something recurring, add "remember this"; review
/memoryonce a month. - Tech Lead: Move notes from your memory that would help the whole team into the repo's CLAUDE.md.
- PM/Admin: For shared environments or sensitive data, consider disabling auto memory via managed settings.
Sources & references
- How Claude remembers your project — Claude Code Docs