AGENTS.md shares rules, not memory
Share one AGENTS.md between Claude Code, Cursor and Codex to give them the same rules. What each agent learned stays behind unless they share a memory store.
On this page
To share memory between Claude Code and Cursor, split the job in two. Your rules travel in one file: Cursor reads both AGENTS.md and CLAUDE.md from the project root, and Claude Code reads AGENTS.md when there is no CLAUDE.md, or through an @AGENTS.md import when there is. What each agent learned while working does not travel that way. Claude Code keeps its auto memory in a folder on your machine that Cursor never reads. For that part you need a store both agents can read and write, such as an MCP memory server.
This is as of November 2026, from each tool’s own documentation, linked below. Claude Code memory: what it keeps, and where maps everything Claude Code remembers, and every guide on it.
| Reads by default | AGENTS.md? |
CLAUDE.md? |
What it learns goes to | |
|---|---|---|---|---|
| Claude Code | CLAUDE.md |
Yes, when there’s no CLAUDE.md |
Yes | Auto memory in ~/.claude/projects/<project>/memory/, machine-local |
| Cursor | AGENTS.md, CLAUDE.md, .cursor/rules/ |
Yes, root and subfolders | Yes, at the root, every conversation | Not described in its rules docs |
| Codex | AGENTS.md (AGENTS.override.md first) |
Yes | Only if you add it as a fallback name | Not covered by its AGENTS.md docs |
| Gemini CLI | GEMINI.md |
Only if you name it in context.fileName |
Only if you name it | GEMINI.md files and a private per-project folder |
Which file each tool reads
Claude Code reads CLAUDE.md. Its memory docs say it reads AGENTS.md “only when you have no CLAUDE.md in your working directory or above it”. A CLAUDE.local.md counts too, so adding one quietly stops Claude Code reading your AGENTS.md. Reading AGENTS.md directly needs v2.1.277 or later. To have it read both files, set Project instructions to claude-md-and-agents-md in /config.
Cursor reads both. Its rules help page says to put an AGENTS.md in the project root and that Cursor reads a root CLAUDE.md “the same way it reads AGENTS.md”. A CLAUDE.md is applied to every conversation, whatever its alwaysApply setting. Its rules docs add that nested AGENTS.md files in subfolders are read too. For rules that apply only sometimes, Cursor has its own .cursor/rules/ folder of .mdc files.
Codex reads AGENTS.md. Per its AGENTS.md guide, it walks from the project root down to the current folder and takes at most one file per folder: AGENTS.override.md, then AGENTS.md, then any fallback names you list. It stops adding files once they reach 32 KiB in total, unless you raise project_doc_max_bytes.
Gemini CLI reads GEMINI.md. Its context file docs say to set context.fileName in settings.json to read other names, AGENTS.md included.
How do I sync CLAUDE.md and AGENTS.md?
Keep AGENTS.md as the one real file and point the others at it. Three ways, from simplest:
-
AGENTS.mdonly, noCLAUDE.md. Claude Code, Cursor and Codex all read it as is. Gemini CLI needs one setting (below). -
A
CLAUDE.mdthat imports it. Use this when Claude Code needs something the others shouldn’t see. Claude Code expands the import, then reads what follows. This is the route Claude Code’s docs recommend:CLAUDE.md@AGENTS.md ## Claude Code only Use plan mode for changes under src/billing/.One catch: Cursor reads this
CLAUDE.mdas well asAGENTS.md, and its help page doesn’t say it expands@imports. Keep anything you don’t want Cursor to see out of theCLAUDE.md. -
A symlink,
ln -s AGENTS.md CLAUDE.md. Claude Code’s docs advise against it if anyone on the project uses Windows: making a symlink there needs Administrator rights or Developer Mode, and Git checks a committed symlink out as a one-line text file unlesscore.symlinksis on.
Whichever you pick, run /context all in your next Claude Code session and check the file is listed under Memory files.
Does Codex read CLAUDE.md?
Not by default. Add it as a fallback name in ~/.codex/config.toml:
project_doc_fallback_filenames = ["CLAUDE.md"]Codex checks fallback names after AGENTS.md in each folder and takes one file per folder, so this helps in a repository that has a CLAUDE.md and no AGENTS.md. If you control the repository, an AGENTS.md is simpler.
Make Gemini CLI read AGENTS.md
List the names in ~/.gemini/settings.json:
{
"context": {
"fileName": ["AGENTS.md", "GEMINI.md"]
}
}Why what an agent learned doesn’t travel
AGENTS.md holds what you wrote down before the session. Memory is what the agent works out during it: the cause of a bug that took an hour, the library you tried and dropped, the test that needs a local Redis. Each tool keeps that in its own place.
- Claude Code’s auto memory lives in
~/.claude/projects/<project>/memory/, with aMEMORY.mdindex of which the first 200 lines or 25 KB load each session. The docs say plainly: “Auto memory is machine-local.” No other tool reads it. - Gemini CLI saves memories by editing Markdown files: shared instructions into the repository’s
GEMINI.md, private notes into a per-project folder, personal preferences into~/.gemini/GEMINI.md(memory docs). Only the first of those is a file another tool could be told to read.
So a correction you gave Claude Code on Monday is not something Cursor knows on Tuesday, even when both read the same AGENTS.md.
Can agents just write what they learn into AGENTS.md?
They can, and for a few stable lines it works. Tell every agent “when you learn something about this project worth keeping, add a line to AGENTS.md”, and the next session of any tool reads it.
It stops working as the file grows. AGENTS.md loads whole into every session of every tool, relevant or not, and Codex stops reading at 32 KiB by default. Nothing marks which line is stale, who wrote it or why. And instructions get mixed with half-finished notes, so you review a diff to your project’s rules every time an agent learns something.
Share what agents learn with one memory store
A memory server that every tool connects to over MCP keeps learnings out of AGENTS.md and still shared. Each agent searches it when it needs something and saves to it as it works, so only what’s relevant enters the context.
Memorinth is one. It keeps memories, decisions and facts as Markdown files in one cortex on your disk. memorinth setup claude-code, setup cursor, setup codex and setup gemini connect each tool to the same cortex, with a session-start hook that hands it a briefing of current decisions, facts and recent memories. Every note records which agent wrote it, such as source: agent:cursor, and all writes go through one engine on your computer, so two agents saving at once don’t collide. It doesn’t touch your AGENTS.md: rules stay there, and what agents learn goes to the cortex.
It isn’t always worth it. If you use one tool, or your agents only need the same rules, a shared AGENTS.md is enough and needs nothing installed. A memory layer earns its place when you switch tools on the same project and are tired of re-explaining what the last one found. The trade-off is covered in more detail in Claude Code memory: built in, or a server?.
Next step
Put your rules in AGENTS.md today. To share what your agents learn too, run memorinth init, which connects every agent it finds to one cortex, and see Memory for Cursor, Codex and other MCP clients for each tool’s setup. What goes where explains which note type to use for what, and How agents use it what the briefing holds.