CLAUDE.md vs MEMORY.md vs AGENTS.md
CLAUDE.md is the rules you write, MEMORY.md indexes the notes Claude writes, AGENTS.md is the rules file agents share. Who writes each, and when it loads.
On this page
CLAUDE.md vs MEMORY.md comes down to who writes it. CLAUDE.md is the file you write: rules for how to work in a project, loaded whole into every Claude Code session. MEMORY.md is the file Claude writes: the index of its auto memory, kept outside your repository in ~/.claude/projects/<project>/memory/, and only its first 200 lines or 25KB load. AGENTS.md is a third file, also yours, that many coding agents read. Claude Code reads it only when there is no CLAUDE.md, unless you change a setting.
What follows is from Claude Code’s memory documentation and each other tool’s own docs, as of November 2026. These details change between versions, so check the linked pages if yours behaves differently. Claude Code memory: what it keeps, and where maps everything Claude Code remembers, and every guide on it.
| CLAUDE.md | MEMORY.md | AGENTS.md | |
|---|---|---|---|
| Who writes it | You | Claude | You |
| Holds | Instructions and rules | A one-line index of Claude’s own notes | Instructions and rules |
| Lives in | ./CLAUDE.md or ./.claude/CLAUDE.md, ~/.claude/CLAUDE.md, CLAUDE.local.md |
~/.claude/projects/<project>/memory/ |
./AGENTS.md, and subfolders |
| In git | The project file, yes | No | Yes |
| Loaded | Whole, at the start of every session | First 200 lines or 25KB; the notes it lists are read when needed | By Claude Code only when no CLAUDE.md is found, by default |
| Size | Aim for under 200 lines; skipped over 4 MiB | Past the limit is not loaded | Codex stops adding files at 32 KiB in total |
| Read by other agents | Not by default | No | Codex, Cursor, Gemini CLI if configured, and many others |
CLAUDE.md: the rules you write
CLAUDE.md holds what you would otherwise explain again every session: build and test commands, code style, project layout, “always do X” rules. Claude Code reads it at the start of every session, and the docs suggest keeping each file under 200 lines, because longer files use more context and are followed less well.
It can live in four places, loaded from broadest to most specific:
- Managed policy, set by your organization for every user on the machine.
- User,
~/.claude/CLAUDE.md, your preferences for every project. - Project,
./CLAUDE.mdor./.claude/CLAUDE.md, shared with your team in git. - Local,
./CLAUDE.local.md, your own preferences for one project. Add it to.gitignore.
Files in the folders above where you start Claude Code load at launch. Files in subfolders load once Claude works on a file there. None of them override each other: they are joined, and the one closest to your working folder is read last. A CLAUDE.md can pull in other files with @path/to/file, up to four hops deep, but imported files still load in full, so imports tidy a long file without making it cheaper.
The project’s root CLAUDE.md is also re-read from disk after /compact, which is why rules that must survive compaction belong there.
MEMORY.md: the index Claude writes
MEMORY.md is not a file you put in your repository. It is the index of Claude Code’s auto memory, a folder of notes Claude keeps for itself. It sits in ~/.claude/projects/<project>/memory/, one folder per git repository, shared by all its worktrees, and it stays on your machine. The docs say these files are not shared across machines or cloud environments.
Each memory is its own Markdown file, and MEMORY.md lists them, one line each. Claude saves four kinds of note: who you are and how you like to work, corrections you gave it, ongoing project work it can’t read from the code, and where to find things outside the project. It skips what the code or your CLAUDE.md already says.
Only the first 200 lines or 25KB of MEMORY.md load at the start, whichever comes first. The notes it points to are read when Claude needs them. When the index nears its limit, Claude Code tells Claude to shorten it. Everything past the limit is dropped on the next load.
So the index is a table of contents, not the memory itself. Open it, edit it or turn auto memory off with /memory. When you ask Claude to “remember” something, it goes here. If you want it in CLAUDE.md instead, say “add this to CLAUDE.md”.
AGENTS.md: the rules file other agents share
AGENTS.md is an open format for guiding coding agents, now stewarded by the Agentic AI Foundation under the Linux Foundation. It’s plain Markdown with no required fields: the same kind of content as a CLAUDE.md, under a name many tools agree on.
Which tools read it, from their own docs:
- Codex reads
~/.codex/AGENTS.md, then eachAGENTS.mdfrom the project root down to your working folder, and stops adding them at 32 KiB in total (Codex docs). It reads aCLAUDE.mdonly if you add that name toproject_doc_fallback_filenames. - Cursor reads
AGENTS.mdin the project root and in subfolders (Cursor rules). - Gemini CLI reads
GEMINI.mdby default. Setcontext.fileNameto includeAGENTS.mdand it reads that too (Gemini CLI docs). - Claude Code reads it since v2.1.277, with one condition.
Does Claude Code read AGENTS.md?
Yes, but by default only when there is no CLAUDE.md, .claude/CLAUDE.md or CLAUDE.local.md in your working folder or any folder above it. If there is one, Claude reads your CLAUDE.md files and ignores AGENTS.md. Your ~/.claude/CLAUDE.md, a managed CLAUDE.md and .claude/rules/ don’t count for that check: they load alongside AGENTS.md.
The catch most people hit: CLAUDE.local.md counts. Add one to a project that relies on AGENTS.md, for a few personal notes, and Claude stops reading AGENTS.md for you.
You have three ways to have both:
- Import it. Put
@AGENTS.mdat the top of aCLAUDE.mdand Claude-only rules below it. This works on every version and every kind of session. - Change the setting. In
/config, set Project instructions toclaude-md-and-agents-md. Claude then reads each folder’sCLAUDE.mdfirst and itsAGENTS.mdafter. - Symlink it.
CLAUDE.mdpointing atAGENTS.md. The docs advise the import instead if anyone works on Windows, where a committed symlink can check out as a one-line text file.
To see what loaded, run /context all and look under Memory files, or open /memory. If it still isn’t loading, AGENTS.md in Claude Code: why it isn’t loading goes through each cause.
Which file gets what
The rule is short: rules go in a file you write, learnings go where an agent writes.
- A rule for Claude Code only goes in
CLAUDE.md. - A rule for every agent goes in
AGENTS.md, imported fromCLAUDE.mdif you keep both. - A personal rule for one project goes in
CLAUDE.local.md, with theAGENTS.mdcatch above in mind. - Something Claude learned about you or the work lands in auto memory, behind
MEMORY.md. When Claude keeps relearning the same rule there, move it intoCLAUDE.md, where it loads whole.
If you use only Claude Code on one machine, that is the whole system, and it needs nothing installed. Whether to add more is a different question, answered in Claude Code memory: built in, or a server?.
Where a shared memory fits
Three of the four rows above are instructions. Only MEMORY.md holds what was learned, and it belongs to Claude Code on one machine. Codex and Cursor can read your AGENTS.md, but not what Claude learned yesterday.
Memorinth is a fourth layer for that part. It’s a folder of Markdown notes, your cortex, that Claude Code, Codex, Cursor and Gemini CLI all read and write over MCP. Agents search it with search_memory instead of loading it whole, so it can grow without the start of each session growing too. Claude Code gets a briefing of current decisions, facts and recent memories from a session-start hook.
Connecting it doesn’t touch your CLAUDE.md or AGENTS.md. memorinth setup claude-code changes files in your home folder only: the MCP server, the hooks and two skills. For agents without hooks, you add one line to the instructions file they read, telling them to call wake_up first.
What goes where draws the line between instructions and knowledge in more detail. To connect Claude Code, see Give Claude Code a long-term memory. For Codex, Cursor and others, see Memory for Cursor, Codex and other MCP clients.