AGENTS.md, CLAUDE.md or memory: where should each kind of knowledge live?
Published · Updated · Checked against Claude Code 2.1.319
Put what every agent needs in AGENTS.md, put only the Claude-specific remainder in a CLAUDE.md that begins with @AGENTS.md, and let auto memory and old transcripts hold things that are neither rules nor project facts. The rest of this page is why that split works and where it breaks.
What Claude Code does with each file
Claude Code reads AGENTS.md natively from v2.1.277, and the memory docs are specific about when. With an AGENTS.md and no CLAUDE.md or CLAUDE.local.md in the working directory or above it, Claude reads the AGENTS.md. With both, it reads the CLAUDE.md files only. Your ~/.claude/CLAUDE.md, an organization's managed file and .claude/rules/ files do not count for that check.
That "only" is easy to trip over. On Claude Code 2.1.319, in a scratch git repo whose AGENTS.md held a made-up codeword, claude -p gave these results.
| Files in the repo | Did Claude return the codeword? |
|---|---|
AGENTS.md alone | Yes |
AGENTS.md plus a CLAUDE.md with unrelated text | No, it answered NONE |
AGENTS.md plus a CLAUDE.md containing @AGENTS.md | Yes |
So the import is the whole trick. It is also the docs' own recommendation for projects that have both files: keep AGENTS.md as the one file every tool shares, put @AGENTS.md at the top of CLAUDE.md, and add Claude-specific lines below.
There are two documented alternatives. A CLAUDE.md can be a symlink to AGENTS.md, which the docs advise against on Windows, since creating one needs Administrator rights or Developer Mode and Git checks a committed symlink out as plain text without core.symlinks. Or you can set Project instructions to claude-md-and-agents-md in /config, which loads both together. Most people never find that setting. Issue #96466 asks for loading AGENTS.md by default even when a CLAUDE.md exists, and it is open. The original request, #6235, ran to over 400 comments before it was closed.
There is one more caveat, and it has a history. The docs list sessions where native AGENTS.md support is unavailable, among them your first session after upgrading from v2.1.276 or earlier, and, before v2.1.281, some sessions on Amazon Bedrock or with telemetry disabled. A [Hacker News thread, "Claude Code reads AGENTS.md only when telemetry is on [fixed]"](https://news.ycombinator.com/item?id=49814947), covers that. In those sessions only CLAUDE.md loads, which is a real reason to keep the thin CLAUDE.md with the import.
What Codex does
Codex's AGENTS.md guide says it reads ~/.codex/AGENTS.md (or an AGENTS.override.md there), then walks from the project root to your directory, using at most one file per directory and concatenating them from the root down, so files closer to you come later and override. The combined size is capped by project_doc_max_bytes, which defaults to 32 KiB. If the cap is hit, Codex stops adding files.
The two tools therefore share a file format but not a size budget. The docs say Claude Code loads a CLAUDE.md in full unless it is over 4 MiB, while a 40 KB instruction file would hit Codex's default cap. That is another argument for the short file the docs recommend anyway.
Where each kind of knowledge goes
Sorting by who needs to know and how often it changes works better than sorting by tool.
Build and test commands, code style, the layout a newcomer cannot guess, and "never edit the generated folder" are instructions every agent needs. They go in AGENTS.md. They are reviewed in pull requests like any other file, which is what keeps them honest.
Anything that only makes sense inside one tool goes in that tool's file. For Claude Code that means .claude/rules/ with paths frontmatter for folder-specific rules, hook-related notes, and the names of your skills. Keep it below the @AGENTS.md line.
Things Claude learns about you, like a preferred test runner or a correction you made twice, are what auto memory is for. It is stored per repository under ~/.claude/projects/<project>/memory/, and the docs say it is machine-local. Do not put anything there that a teammate or a second machine needs. If a note matters to others, promote it into AGENTS.md through a pull request. How to audit what auto memory has written covers the cleanup.
What happened and why is the remaining category, and it belongs in neither file. "We rejected Postgres in September" is an event, and instruction files are a bad place for events because they grow and go stale. Keep those in the transcripts, and write a short decision note only for the ones that keep getting reopened (how). Both agents write session history to disk, though the folders differ (Claude Code, Codex).
A setup that holds up
Commit AGENTS.md. Commit a CLAUDE.md of this shape:
@AGENTS.md
## Claude Code
- Subagent and hook notes that other tools should not read.
Do not duplicate content between the two. A rule in both places will be updated in one of them. Keep any personal notes in CLAUDE.local.md only if you set Project instructions to claude-md-and-agents-md, because the docs say a CLAUDE.local.md otherwise stops Claude from reading AGENTS.md on its own.
Keeping history in one place
Sealkeep covers one slice of this: it seals and indexes the session files of Claude Code and Codex, so the "what happened" category is searchable across both with sealkeep search <query> --content. It does not read, write or merge AGENTS.md or CLAUDE.md, and it does not decide what is a rule. See memory between sessions for how it sits next to the other mechanisms, and /guides/ for the rest.
FAQ
Can I just symlink CLAUDE.md to AGENTS.md?
The docs allow it and note that Claude reads the content once. On Windows or in a repo that Windows users clone, use the @AGENTS.md import, because a committed symlink there can arrive as a one-line text file.
Does Codex read CLAUDE.md?
Not by default. Codex's documented discovery list is AGENTS.override.md, AGENTS.md, then names in project_doc_fallback_filenames, so you would have to add CLAUDE.md to that setting yourself.
Which wins if AGENTS.md and CLAUDE.md disagree?
In Claude Code with the import, both are in context and Claude may pick either, per the docs on conflicting instructions. Resolve it in the file, not by hoping about order.