← Back to Journal
Answers

How to Give Claude Memory: CLAUDE.md and Auto Memory

Daniela Salgado · Published

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.mdAuto memory
Who writes itYouClaude
What it containsInstructions and rulesLearnings and patterns
ScopeProject, user or organizationPer repository
How much loadsThe whole file, every sessionFirst 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.md or ./.claude/CLAUDE.md — a project's rules, shared with your team.
  • ./CLAUDE.local.md — your personal notes for one project; add it to .gitignore so 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:

  • Split it with imports. A CLAUDE.md can pull in other files with @path/to/file, up to four hops deep. It organizes, but it doesn't save context: imported files load along with it [1].
  • Move specifics into rules or skills. Path-scoped rules and skills load only when needed, not every session [1].

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:

  1. Read your index once a week and delete what's resolved.
  2. Correct in the file, not just in the chat. A correction in the chat is lost; in CLAUDE.md, it stays.
  3. 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?
In Claude Code, each session begins with a fresh context window. What carries over between sessions is files: the CLAUDE.md files you write and the auto memory Claude writes. Both load at the start of every conversation.
Where does the CLAUDE.md file go?
In ~/.claude/CLAUDE.md for your preferences across all projects, in ./CLAUDE.md or ./.claude/CLAUDE.md for a project shared with your team, and in ./CLAUDE.local.md for personal notes on a project that stay out of the repository.
How long can CLAUDE.md be?
Anthropic recommends under 200 lines per file: longer files consume more context and reduce adherence. Instructions that apply to only part of the work belong in rules or skills that load when needed.
What is Claude Code auto memory?
Notes Claude writes on its own about your role, your corrections, ongoing work and where to find information. They are stored in ~/.claude/projects/<project>/memory/ with a MEMORY.md index, and can be toggled from /memory.

Sources

  1. Anthropic — "How Claude remembers your project," Claude Code documentation, accessed December 2, 2026. https://code.claude.com/docs/en/memory
  2. Anthropic — "Effective context engineering for AI agents," Anthropic Engineering, September 29, 2025. https://www.anthropic.com/engineering/effective-context-engineering-for-ai-agents
  3. 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