{
  "id": "your-agent-rules-are-drifting-apart",
  "type": "blog",
  "url": "/blog/your-agent-rules-are-drifting-apart",
  "title": "Your Agent Rules Are Drifting Apart",
  "description": "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.",
  "author": "PasteCode",
  "published": "2026-09-16",
  "updated": "2026-09-16",
  "tags": [
    "AGENTS.md",
    "Cursor",
    "Claude Code",
    "Codex",
    "Review"
  ],
  "stack": [],
  "tools": [],
  "markdown": "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.\n\nThe 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.\n\nNobody 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.\n\n## The mechanism, so you can stop doing it\n\nEvery 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.\n\nAfter 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.\n\nThe 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\".\n\n## One file, and the others point at it\n\nThe fix is structural, not procedural: pick one file as the source of truth and make the other two shims.\n\nThere 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:\n\n- `AGENTS.md` holds the actual rules.\n- `CLAUDE.md` is a couple of lines pointing at it.\n- `.cursor/rules/*.mdc` holds at most what genuinely only applies to Cursor.\n\nA 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:\n\n```md title=\"CLAUDE.md\"\nRead AGENTS.md at the repo root and follow it.\n\nOnly Cursor-specific things belong in .cursor/rules/; everything\ngeneral lives in AGENTS.md.\n```\n\nThree 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.\n\n## Keep it small enough to survive truncation\n\nRule 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.\n\nThe 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.\n\nThis 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.\n\n## A rule has to be breakable\n\nThe 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?\n\n\"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.\n\nThat distinction is why the useful rules are almost always hyper-specific and slightly unfashionable. They encode one incident:\n\n- **Package manager.** One install command. Say which, and say what happens to the lockfile if anyone uses another.\n- **Migration path.** The exact commands for local and for production, because `db push` and `migrate deploy` both look reasonable to a model that has not been told the difference.\n- **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.\n- **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.\n\nNone of that is clever. It is just the project's implicit decisions, written down, in one file.\n\n## What I do when I inherit a repo\n\nTwenty minutes, in this order.\n\nRead 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.\n\nThen 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.\n\nThen add the one rule from last week's incident, and stop.\n\nIf you want a starting point rather than a blank file, the [AGENTS.md for a Next.js SaaS](/rules/agents-md-nextjs-saas) and the [Prisma-specific set](/rules/claude-code-rules-for-prisma-projects) are the two I copy from most often. The [review checklist](/checklists/review-ai-generated-nextjs-code) is the other half of the loop: rules shape what gets written, the checklist catches what got written anyway."
}