Claude Code memory is a set of Markdown files that Claude Code loads into every new session, so that what Claude knows about a project carries over from one session to the next: CLAUDE.md files that you write, and auto memory notes that Claude writes for itself. See How Claude remembers your project in the Claude Code documentation. This note describes Claude Code 2.1.337.
What problem does it solve?
You use Claude Code on my-app/, a small web API for orders, managed with uv. Every session starts with an empty context, the conversation that Claude can see. On Monday you tell Claude that the order tests need the database, so it has to run docker compose up -d db before uv run pytest. On Tuesday you start a new session. Claude runs the tests without the database, they fail, and you explain it again.
Memory saves you from repeating yourself. Claude Code keeps two kinds of memory, and loads both when a session starts, before your first message:
CLAUDE.mdfiles hold instructions that you write, such as build commands and conventions.- Auto memory holds notes that Claude writes while it works, such as the corrections you give it.
How do I give Claude instructions?
Create CLAUDE.md in my-app/ and commit it, so everyone who uses Claude Code on the project gets it:
# my-app
A small web API for orders, managed with uv.
- Run the tests with `uv run pytest`.
You can also type /init in a session, and Claude writes a first version from what it finds in the code. Claude Code looks for instruction files in several places, and loads every one it finds instead of choosing one:
~/.claude/CLAUDE.mdin your home folder, for your own preferences in all projects.CLAUDE.mdor.claude/CLAUDE.mdin the project, for the team. Claude Code loads the one in the folder where you start it, and the ones in every folder above it.CLAUDE.local.mdin the project, for your own notes about this project. Add it to.gitignore.CLAUDE.mdin a subfolder, such assrc/CLAUDE.md. It loads only once Claude reads or edits a file in that subfolder.
An organization can also install a managed CLAUDE.md for every user of a machine. See Choose where to put CLAUDE.md files.
A CLAUDE.md can include another file with an import, a line such as @docs/testing.md. The imported file loads with the CLAUDE.md, so an import organizes a long file but doesn't make it cost less context. The documentation suggests keeping each CLAUDE.md under 200 lines. Instructions that matter only for some files can move to Claude Code rules, which load only when Claude works on those files.
How does auto memory work?
Auto memory is on by default. When you correct Claude, or ask it to remember something, Claude may save a note. A session in my-app/ got this request:
Remember this for future sessions: the order tests need the database running, so start it with docker compose up -d db before you run the tests.
Claude wrote two files to the project's auto memory folder, ~/.claude/projects/<project>/memory/. Claude Code derives <project> from the path of the Git repository, so all worktrees and subfolders of my-app/ share one folder. The first file is a topic file, which holds one note:
---
name: order-tests-need-db
description: "my-app order tests require the database container; run `docker compose up -d db` before `uv run pytest`"
metadata:
node_type: memory
type: project
originSessionId: 5d214b6b-28aa-48e0-994d-b84f1daa0553
modified: 2026-12-04T23:04:46.135Z
---
In my-app, the order tests (`tests/test_orders.py`) need the database running. Start it with `docker compose up -d db` before running the tests (`uv run pytest`).
**Why:** The order tests hit a real database, so they fail when the `db` service isn't up. CLAUDE.md only says `uv run pytest` and leaves this step out.
**How to apply:** Before running the test suite in my-app, especially the order tests, run `docker compose up -d db` first.
The second is MEMORY.md, the index of the folder, with one line for each note:
- [Order tests need the DB](order-tests-need-db.md) — run `docker compose up -d db` before `uv run pytest` in my-app
Claude wrote name, description, and type. Claude Code added the other fields, including modified, the time of the write in UTC, so that you and Claude can tell how old a note is. The type is one of four kinds:
user: your role, expertise, and preferences.feedback: corrections you give, and approaches you confirm.project: ongoing work and decisions that the code and Git history don't show.reference: where to find information outside the project, such as a dashboard.
Claude decides what is worth keeping. It skips what it can find in the code or in a CLAUDE.md, and not every session saves something.
When the next session starts, Claude Code loads MEMORY.md, but not the topic files, as Figure 1 shows. Asked, without using tools, what to do before the order tests and where it learned that, a new session answered:
Start the database before running the tests. In `my-app`, run:
docker compose up -d db
uv run pytest
From your auto-memory index file, `MEMORY.md`, which was loaded at the start of this
session. [...] I only saw the one-line entry in that index; I didn't open the full note
it points to (`order-tests-need-db.md`).
How do I see what Claude remembers?
- Type
/memoryin a session. It lists yourCLAUDE.mdfiles and opens any of them in your editor. It also opens the auto memory folder, and turns auto memory on or off. - Run
/context alland look under Memory files for the files that loaded when the session started. - Edit the files directly. Memory files are plain Markdown, so you can change or delete them like any other file.
To turn auto memory off for one project, add "autoMemoryEnabled": false to its .claude/settings.json. See Enable or disable auto memory.
How do the two kinds of memory compare?
CLAUDE.md |
Auto memory | |
|---|---|---|
| Who writes it | You, or Claude when you ask it to | Claude |
| Where it lives | In the project, usually committed to Git | In your home folder |
| Who gets it | Everyone who uses Claude Code on the project | Only you, on this machine |
| What loads at the start | The whole file | The first 200 lines or 25 KB of MEMORY.md |
| Use it for | Commands, conventions, and layout that every task needs | Your preferences, and corrections that the code doesn't show |
What should I watch out for?
- Auto memory stays on your machine. Your teammates, your other computers, and cloud sessions don't get it. The session that saved the database note pointed this out itself, and offered to add the step to
CLAUDE.md. Put anything the whole team needs inCLAUDE.md, either by asking Claude to "add this to CLAUDE.md" or by editing the file yourself. - Only the start of
MEMORY.mdloads. Claude Code loads the first 200 lines or 25 KB, whichever comes first, and drops the rest. In a test with a 250-line index, Claude knew an entry on line 150 but not one on line 230, and Claude Code told it that50 of 250 lines were cut off. Claude Code also reminds Claude to shorten the index when it nears the limit. If you editMEMORY.mdyourself, keep one short line per note. - Memories go stale. A note records what was true when Claude saved it. If you move the database to a different service, the note still says
docker compose up -d db, and Claude may still follow it. Open the folder with/memoryfrom time to time, and fix or delete notes that are out of date. Themodifiedfield shows when each one was written. - Nothing here is enforced. Claude Code gives
CLAUDE.mdto Claude as a user message after the system prompt, not as part of it, and auto memory is context in the same way. Claude usually follows both, but less reliably when instructions are vague or contradict each other. For a step that must happen every time, use a hook. CLAUDE.local.mdexists in one worktree only. Git ignores it, so a new Git worktree ofmy-app/starts without it. Keep personal instructions in~/.claude/CLAUDE.mdif they apply to all your projects, or let auto memory keep them, since every worktree of a repository shares one memory folder.- A
CLAUDE.mdhidesAGENTS.md. Many repositories keep instructions for other coding agents inAGENTS.md. Since version 2.1.277, Claude Code reads it, but only when there is noCLAUDE.md,.claude/CLAUDE.md, orCLAUDE.local.mdin the folder where you start it or above. Adding aCLAUDE.local.mdfor yourself is enough to turnAGENTS.mdoff. Put the line@AGENTS.mdat the top of yourCLAUDE.mdto import it, or set Project instructions toclaude-md-and-agents-mdin/config. See AGENTS.md.
Which should I use?
Use both, for different things. Write CLAUDE.md yourself, and keep it to what a new teammate would need in every session: the build and test commands, the conventions, and where things live. Leave auto memory on for what is personal or still changing, and look through it with /memory every few weeks. When a note turns out to matter for everyone, like the database step for my-app/, move it to CLAUDE.md and delete the note.