How to Give Claude Memory: CLAUDE.md and Auto Memory
How do you give Claude memory? In Claude Code, memory lives in text files that load at the start of every session: CLAUDE.md files, where you write rules and decisions, and auto memory, where Claude notes what it learns from your corrections. Anthropic recommends keeping each file under 200 lines and keeping both current.
Why does Claude "forget" between sessions?
Because, as Anthropic's documentation puts it, "each Claude Code session begins with a fresh context window" [1]. What you explained yesterday isn't there today unless it's written somewhere Claude reads when it starts.
That's the whole idea: Claude's memory isn't a mysterious faculty, it's a file. Anthropic's engineering guide calls it "structured note-taking, or agentic memory": the agent writes notes that persist outside the context window and loads them back later [2].
This article covers Claude Code. The Claude chat app has its own options, which we don't cover here.
What two kinds of memory does Claude Code have?
The official documentation distinguishes two systems, and both load at the start of every conversation [1]:
- CLAUDE.md: you write it. Instructions and rules: how you work, what you don't want it to do, which words you use.
- Auto memory: Claude writes it. Learnings and patterns: your role, the corrections you gave, the work in progress.
One important nuance: Claude treats both "as context, not enforced configuration" [1]. If something must always hold, the documentation points to another mechanism (hooks). For everything else, the more specific and concise your instructions, the more consistently Claude follows them.
| CLAUDE.md | Auto memory | |
|---|---|---|
| Who writes it | You | Claude |
| What it contains | Instructions and rules | Learnings and patterns |
| Scope | Project, user or organization | Per repository |
| How much loads | The whole file, every session | First 200 lines or 25KB, every session |
| Where it lives | ~/.claude/CLAUDE.md, ./CLAUDE.md, ./CLAUDE.local.md | ~/.claude/projects/<project>/memory/ |
Table source: Claude Code memory documentation [1].
Where do I put my CLAUDE.md?
It depends on who it's for [1]:
~/.claude/CLAUDE.md— your personal preferences, across all your projects../CLAUDE.mdor./.claude/CLAUDE.md— a project's rules, shared with your team../CLAUDE.local.md— your personal notes for one project; add it to.gitignoreso it isn't committed.
Claude Code reads the CLAUDE.md files in the folder where you start the session and in every folder above it, and concatenates them rather than letting one override another; the file closest to where you are is read last [1].
If you don't know where to start, the /init command generates a first CLAUDE.md by looking at your project; if one already exists, it suggests improvements instead of overwriting it [1].
What goes in CLAUDE.md, and what stays out?
Write what Claude can't guess: how you name things, which decisions you've already made, which steps you always follow, what must not be touched. Leave out what Claude already knows or can read for itself.
Anthropic gives the measure: under 200 lines per file, because "longer files consume more context and reduce adherence" [1]. If it has grown too long:
How does auto memory work?
As you work, Claude saves four kinds of notes [1]: user (your role and preferences), feedback (corrections you give and approaches you confirm), project (ongoing work, deadlines and decisions that can't be derived from the code) and reference (where information lives outside the project).
They're stored in ~/.claude/projects/<project>/memory/, with a MEMORY.md index — one line per memory, loaded every session — and one file per topic [1]. Claude doesn't save something every session: it decides whether the information would help in a future conversation, and skips anything your CLAUDE.md files already say [1].
It's on by default in local sessions. To toggle it, open /memory in a session [1].
Why does memory need maintenance too?
Because what it describes changes. Anthropic's data team measured this in another setting: with documentation nobody updated, their analytics accuracy drifted from ~95% to ~65% over a month [3]. That's Anthropic's measurement on its own data, not on personal memory, but the lesson carries over: a stale rule nobody reviewed still loads in every session.
Three simple habits:
- Read your index once a week and delete what's resolved.
- Correct in the file, not just in the chat. A correction in the chat is lost; in CLAUDE.md, it stays.
- One rule, one place. If the same instruction lives in two files, sooner or later they contradict each other.
Frequently asked questions
Does Claude remember previous conversations?
Where does the CLAUDE.md file go?
How long can CLAUDE.md be?
What is Claude Code auto memory?
Sources
- Anthropic — "How Claude remembers your project," Claude Code documentation, accessed December 2, 2026. https://code.claude.com/docs/en/memory
- Anthropic — "Effective context engineering for AI agents," Anthropic Engineering, September 29, 2025. https://www.anthropic.com/engineering/effective-context-engineering-for-ai-agents
- Anthropic — "How Anthropic enables self-service data analytics with Claude," Claude blog, June 3, 2026. https://claude.com/blog/how-anthropic-enables-self-service-data-analytics-with-claude