Your Agent Rules Are Drifting Apart
AGENTS.md, CLAUDE.md and .cursor/rules usually start as the same file and quietly become three. The fix is not better discipline, it is deleting two of them.
Open a repo that three people have worked on with three different agents and you will usually find three rule files. AGENTS.md, CLAUDE.md, .cursor/rules/*.mdc. They started as the same document. Six months later they disagree.
The version I keep meeting: CLAUDE.md says to use bun and never npm install, because mixing package managers had already broken the lockfile once. AGENTS.md, in the same repo, still contains a copy-pasted example that begins with npm install. Whichever file your tool happened to read decides whether the agent respects the constraint.
Nobody decided to create that contradiction. It accumulated one hasty commit at a time, and it is the most common failure of the whole agent-rules idea.
The mechanism, so you can stop doing it
Every agent vendor wants its own file. So the obvious move is to write the rules once and copy them into each file. That works for about two weeks.
After that, each copy gets edited on a different schedule. A rule learned during a Claude Code session lands in CLAUDE.md. A Cursor-specific fix lands in .cursor/rules. The files never get diffed against each other, so the drift is invisible until an agent does something you explicitly forbade in a file it did not read.
The deeper problem is what duplicated rules do to authority. When an agent sees a 400-line rule file of which 60 lines are about this project and the rest is generic advice, nothing in it reads as more important than anything else. Your hard-won constraint competes for attention with “prefer descriptive variable names”.
One file, and the others point at it
The fix is structural, not procedural: pick one file as the source of truth and make the other two shims.
There is a real mechanism to lean on here. Claude Code reads CLAUDE.md. Cursor reads .cursor/rules/. Codex and a growing list of other tools read AGENTS.md, and the convention has been adopted widely enough that this is no longer a bet on one vendor. So the arrangement that survives contact with a team is:
AGENTS.mdholds the actual rules.CLAUDE.mdis a couple of lines pointing at it..cursor/rules/*.mdcholds at most what genuinely only applies to Cursor.
A shim is not a link, it is an instruction, because nothing guarantees an agent follows a file it was told to read. Keep the pointer concrete and short:
Read AGENTS.md at the repo root and follow it.
Only Cursor-specific things belong in .cursor/rules/; everythinggeneral lives in AGENTS.md.Three consequences worth knowing before you do this. Rules get read more often, because they are in the file every tool opens. Rules get updated more often, because there is one place to edit. And the inevitable drift becomes a single visible diff, instead of three parallel ones.
Keep it small enough to survive truncation
Rule files are context, and context competes with the code the agent is actually working on. When a rules file is too long, the failure is not an error message. It is silent partial compliance: the agent follows what fit.
The practical version of that: put the three or four constraints that cause outages or data loss at the very top, and push anything advisory to the bottom. If a rule would not change your behaviour during a code review, it does not belong above a rule that prevents a destructive command.
This is also why “with a large context window you can just include everything” does not hold up. The ranking within the file is still yours to decide.
A rule has to be breakable
The test I use before adding a line to AGENTS.md: could an agent violate this in a way I could point at in a diff?
“Write clean code” fails the test. There is no diff that clearly breaks it, which means it does nothing except dilute the file. “Never run prisma db push against anything but your local database, use prisma migrate deploy” passes the test. You can see the violation in one line of shell history.
That distinction is why the useful rules are almost always hyper-specific and slightly unfashionable. They encode one incident:
- Package manager. One install command. Say which, and say what happens to the lockfile if anyone uses another.
- Migration path. The exact commands for local and for production, because
db pushandmigrate deployboth look reasonable to a model that has not been told the difference. - Environment variables. Validate them at boot and fail loudly, so a missing key surfaces when the process starts instead of when a user clicks a button.
- Where business logic lives. If your app keeps it in
src/domain/and the agent’s training data says route handlers, you will get route handlers until you say otherwise.
None of that is clever. It is just the project’s implicit decisions, written down, in one file.
What I do when I inherit a repo
Twenty minutes, in this order.
Read all the rule files and diff them mentally for contradictions. Whichever is most complete becomes AGENTS.md. Move anything real out of the other two, leave a pointer behind, and delete the rest.
Then cut it to a screen. Not because long files are unpublishable, but because the top of the file is the only part every tool is guaranteed to read.
Then add the one rule from last week’s incident, and stop.
If you want a starting point rather than a blank file, the AGENTS.md for a Next.js SaaS and the Prisma-specific set are the two I copy from most often. The review checklist is the other half of the loop: rules shape what gets written, the checklist catches what got written anyway.