A change to AGENTS.md changes how every AI agent in the repo behaves, for every developer, on the next request. It is closer to a change in CI configuration than to a change in the README. Most teams still protect it like the README, which is to say, they do not.
Here is why that matters more than it did a year ago, and the three layers of protection that exist today. Vendor behaviour was checked against the docs on 5 December 2026.
What changed: the reviewer reads the pull request's own rules
GitHub's changelog of 17 July 2026: "Custom instructions are now read from the head branch of the pull request instead of the base branch."
The reason is sensible. You can now test a change to your review instructions in the pull request that makes it. The side effect is that a pull request can carry its own instructions for the tool reviewing it. Add a line to AGENTS.md saying generated files need no review, and the review of that same pull request follows it.
The coding agents were always like this. Claude Code, Codex and Cursor read whatever instruction files are in the branch you have checked out. Pull a colleague's branch and their AGENTS.md is steering your agent, including any line that tells it to run a command.
None of this is a vulnerability in the tools. It is what instruction files are for. It does mean they belong on the list of files where a second pair of eyes is required.
Layer 1: CODEOWNERS for the instruction files
GitHub's CODEOWNERS file assigns reviewers by path. Put it in .github/, the repo root or docs/. A starting set of entries:
# AI instruction files
**/AGENTS.md @your-org/platform
**/CLAUDE.md @your-org/platform
**/GEMINI.md @your-org/platform
/.claude/ @your-org/platform
/.cursor/rules/ @your-org/platform
/.github/copilot-instructions.md @your-org/platform
/.github/instructions/ @your-org/platformThree details from GitHub's docs that decide whether this works:
- CODEOWNERS alone only requests a review. To make it binding, switch on "Require review from Code Owners" in the branch protection rule or ruleset for your main branch.
- Review requests use the CODEOWNERS file "from the base branch of the pull request". A pull request cannot remove its own reviewers by editing the file. This is the opposite of how Copilot reads instructions, and it is what makes CODEOWNERS a real control.
- Add a line for the CODEOWNERS file itself. Otherwise anyone can change who owns the instruction files in the pull request before.
Pick owners who know what the tools do with these files. A reviewer who does not know that a new CLAUDE.md can switch off AGENTS.md for Claude Code will approve exactly that.
Layer 2: rules a developer cannot switch off
Repo files can be edited by anyone with write access. Two vendors offer a layer above the repo for rules that must hold regardless.
Cursor Team Rules. On Team and Enterprise plans, admins write rules in the dashboard and mark each as required or optional. Per Cursor's help page, enforced rules "can't be turned off" in a member's settings, and when rules conflict the order is Team Rules, then Project Rules, then User Rules. A line in a repo cannot override an enforced team rule.
Claude Code managed CLAUDE.md. A file IT deploys to a system path (/Library/Application Support/ClaudeCode/CLAUDE.md on macOS, /etc/claude-code/CLAUDE.md on Linux). Developers cannot exclude it with claudeMdExcludes. Anthropic's docs are careful about what it is: "Use the file for guidance, and enforce rules with managed settings such as permissions.deny."
That sentence is the honest summary of the whole category. Instructions steer a model. They do not bind it. Anything that must never happen, such as reading .env or pushing to main, belongs in permissions and branch protection, with the instruction file as the explanation.
Copilot's organization instructions are the weak one here. They rank below repository instructions in GitHub's precedence order, and they do not apply in local editor sessions at all. We went through each vendor's company-level feature in one set of rules for the whole company.
Layer 3: a check that reads the files the way the tools do
A human reviewer catches a line that says "skip the tests". A human reviewer does not catch a rule file saved with the wrong extension, or an AGENTS.md that just crossed the size at which Codex cuts it. Those changes look fine in a diff and break loading without an error.
That part is mechanical, so give it to CI. We wrote up the checks, with shell you can copy, in five checks to run on every pull request.
The short version
| Risk | Control |
|---|---|
| Anyone can rewrite the agent's rules | CODEOWNERS on instruction files, with required code owner review |
| A repo overrides a company rule | Cursor enforced Team Rules, Claude Code managed CLAUDE.md |
| An agent does the forbidden thing anyway | Permissions and branch protection, not instructions |
| A change silently stops a tool loading the files | A loading check in CI |
If you want the last row without maintaining it yourself, that is what contextarch for teams does: a pull request check that knows the loading rules of six tools and writes the reason on the file that broke them, plus one report across every repo showing which tool loads what. It runs in your own CI and connects to nothing, which tends to matter to the same people who care about CODEOWNERS. $299 a year for one company.
Start with layer 1 either way. It is seven lines and one checkbox, and it turns your instruction files from text anyone can edit into configuration someone owns.