Tell Your Agent Who Owns the Code

Coding agents can pick up on whose code they think they're working in, and in Anthropic's tests with Claude Fable 5.2, that changed how much the model tidied up as it went. Anthropic wrote it up in their prompting guide, in a section called Say who owns the code.
Let's take a look at what they found, and how to use it.
What Anthropic found
In Anthropic's testing on small coding tasks, the model tended to add to the existing structure when the prompt said nothing about ownership, or presented the codebase as someone else's. It did that even when it meant duplicating code that was already there. When the prompt said the codebase was the model's own, it often consolidated the duplicated code, and sometimes made related fixes nobody had asked for.
The difference was big. Without an ownership sentence, the model pulled duplicated code into one shared function in under 10% of runs. With it, that went up to about 75%.
Saying that, these are one vendor's tests, on one model, on small tasks. Your agent might not react the same way, so treat the numbers as a reason to try it on your own work.
Say it in your rules file, on purpose
If you want your agent to improve the structure as it works, put an ownership line in the rules file it reads at the start of every session, like AGENTS.md or CLAUDE.md. Improving Your AI Agent, One Rule at a Time covers setting one up, if you haven't got one yet.
Here's Anthropic's sentence:
You are the owner and long-term maintainer of this codebase, and its design is up to you.Now, the obvious thing to do is add that line and keep it in check with a scope rule, like "No drive-by refactors, renames or cleanups". Anthropic tested that too. With the scope rule earlier in the same prompt, the model still consolidated duplicated code in more than half of runs, so the scope rule didn't cancel the ownership sentence.
So it's better to pick one. If you want the agent to tidy as it goes, include the sentence. For a narrow change and nothing else, leave it out, as Anthropic recommends when the code is yours and you want it changed as little as possible, and say in the task that the change should be small.
Back it up with CODEOWNERS
A rules file is context for the agent, and nothing enforces it (Claude Code's docs say as much about CLAUDE.md). For the paths where a mistake really hurts, like auth and billing, you want a person to check the change before it merges.
On GitHub, that's what a CODEOWNERS file is for. GitLab and Bitbucket Data Center have their own versions with slightly different rules, but we'll use GitHub's here.
Add a CODEOWNERS file
Create a file called CODEOWNERS in your repository's .github/ folder, and give each sensitive path an owner:
/auth/ @acme/security
/billing/ @acme/payments
/AGENTS.md @acme/platform
/.github/ @acme/platformWhen anyone (or any agent) opens a pull request that touches one of these paths, GitHub automatically requests a review from its owners (for a draft, that happens once it's marked ready for review). The last two lines cover the agent's rules file and the .github/ folder, which holds CODEOWNERS itself, and GitHub recommends giving that file an owner.
Behind the scenes, a pull request uses the CODEOWNERS file from its base branch (the branch it'll merge into). So if an agent edits CODEOWNERS in its own pull request, that doesn't change who's asked to review it.
Make the review required
On its own, CODEOWNERS only requests a review, so it won't stop an agent editing a file, or a pull request merging without that review. To make it count, add a branch protection rule for your main branch (or edit the one you've got), select Require a pull request before merging, then Require review from Code Owners (a ruleset can do the same). Once that's on, a pull request that changes an owned path can't merge until one of its owners approves it.
There are a few things to check while you're in there. Branch protection doesn't apply to admins by default, so if your agent's token has admin rights, turn on Do not allow bypassing the above settings too. Owners also need write access to the repository or GitHub won't assign them, and on GitHub's free plans, code owners only work in public repositories.
Tell the agent too
CODEOWNERS and branch protection only kick in once the agent pushes its change. To steer the agent before then, say the same thing in its rules file:
Changes under auth/ and billing/ need a review from the team that owns them before
they can merge. Keep changes there to what the task needs, and list each one in your summary.That gives the agent a chance to keep those changes small. I'd still expect it to slip now and then, especially with the ownership sentence in there too, since Anthropic's scope rule didn't fully hold against it.
Read the diff
The ownership sentence has a cost. In Anthropic's tests, output tokens went up by about 70 to 80%, and the model made changes nobody had asked for, many of them new tests and documentation. And in some runs, it changed how an existing feature behaves (eek).
A few extra tests are usually fine, but a change to how a feature behaves isn't something you want to find out about later. You might not hear about it from the agent, either, because in Anthropic's tests, the model's closing PR summary often left out small changes. Anthropic recommends reviewing the diff as well as the summary.
Here's a quick way to see every file a branch touched:
git diff --stat main...HEAD
The three dots compare your branch with the point where it split from main, so you only see the branch's own changes, and a file you didn't expect stands out straight away. Then read the full diff (The AI Code Review Problem Nobody Talks About covers what to look for).
Try it on your own tasks first
Before you make the ownership sentence a default, try two or three of your own tasks with it and without it, and compare the diffs and what each run cost. Keep it if the tidier code is worth the extra tokens and the extra reading.
I'd set up the CODEOWNERS file and the required review either way. It only takes a few minutes, and it covers your auth and billing code whichever way you go with the sentence.