CODEOWNERS & Review Policy: Who Reviews What, and Who Owns Nothing
Last updated:
A CODEOWNERS file is a GitHub file that routes review requests: each line pairs a path pattern with the users, teams or emails GitHub will ask to review a pull request that touches matching paths. That one sentence is the whole mechanism — CODEOWNERS decides who gets asked, not who must approve. This article works through the semantics people get wrong (last match wins, patterns with no owner, the directory cascade), the coverage question that actually matters — which files nobody owns — and the pairing with branch protection that turns routed requests into enforced reviews. The CODEOWNERS & Review Policy Auditor checks a file, and an optional git ls-files list, in your browser.
What CODEOWNERS does — and what it does not do
The file lives in the repository root, in docs/ or in .github/, and GitHub reads the first one it finds in that order. Each non-comment line is a pattern, then one or more owners: an individual like @alice, a team like @acme/docs-team, or an email address. Open a pull request that changes a matching path and GitHub adds those owners as requested reviewers — a notification and a name in the sidebar. Nothing more happens automatically.
What CODEOWNERS does not do is enforce anything. It does not require the requested review to happen, does not stop the author merging their own change, and does not check that the named team still exists. Enforcement lives somewhere else entirely — branch protection — which is why a repository can have a beautiful CODEOWNERS file and still land completely unreviewed code. Treating the file as the policy, rather than as the routing table the policy uses, is the foundational mistake.
Last match wins, and the other semantics people get wrong
When several patterns match a path, only the last one in the file applies. That single rule explains most CODEOWNERS surprises: the broad rule at the top is a fallback, the specific rules belong below it, and an identical pattern written twice makes the earlier line dead text — it looks authoritative and does nothing. The sample below shows it twice over: docs/ is assigned first to a team and then to an individual, so the team line never fires; and the legacy/ line names no owner at all, which GitHub treats as a syntax error and ignores — except that the line still wins its paths, so legacy/old.js ends up owned by nobody, not even by the catch-all above it.
The other traps are quieter. Patterns follow the gitignore format with two CODEOWNERS differences: negation does not work, so !pattern excludes nothing, and a pattern that matches a directory assigns everything inside it. A pattern containing a slash is anchored to the repository root; one without a slash matches a name at any depth, which is why *.lock catches lockfiles in every folder. Owners must be real shapes — @user, @org/team or an email with a dotted domain — so not-an-owner and alice@example in the sample request reviews from nobody. The demo file scores 83 out of 100 against its 12-path list in the auditor: seven findings, 11 of 12 files owned. 
Coverage thinking: the files nobody owns are the risk
A CODEOWNERS file is usually reviewed as a list of rules, but the risk sits in the complement: the files no rule claims. Those files get no requested reviewer, and on a busy repository “no requested reviewer” means the change is read by whoever happens to notice it — or by no one. The way to see them is mechanical: take the repository’s real file list (git ls-files), find the last matching rule for every path, and list the paths whose winning rule names no owner — or does not exist. In the demo that list has exactly one entry, legacy/old.js, and it took a broken rule to produce it; in real repositories the usual cause is simpler — a new top-level directory nobody added a rule for.
Coverage is a percentage with a story: 11 of 12 files owned is 91.7%, and the missing 8.3% matters more than the number suggests when it concentrates in the wrong places. Rank the unowned files by what they are. An unowned README is an inconvenience; an unowned workflow file under .github/workflows/, an unowned lockfile, an unowned migration or an unowned .env file is a change class that can alter how the software is built, what it depends on, what its database looks like or which secrets it loads — reviewed by nobody in particular. The auditor flags exactly those four classes separately, because “92% covered” hides them.
CODEOWNERS plus branch protection: routing is not enforcement
The pair that actually works is CODEOWNERS for routing and branch protection for enforcement. In the protected-branch settings, “Require a pull request before merging” stops direct pushes, “Require approvals” sets how many approvals a change needs, and “Require review from Code Owners” makes at least one of those approvals come from an owner of the changed paths. Only then does the routing table have teeth: the right people are asked, and the merge waits until one of them answers.
Two settings deserve a second look while you are there. “Dismiss stale pull request approvals when new commits are pushed” closes the approve-then-amend gap, where the reviewed code is not the merged code. And administrators bypassing protection — common on small repositories — quietly re-opens the unreviewed path for exactly the people whose changes are hardest to challenge. None of this is visible in the CODEOWNERS file itself, which is the honest limit of any file audit: the auditor can prove the routing table is sound, never that the enforcement around it is switched on.
Teams over individuals: the bus factor of a review request
An owner can be a person, and sometimes should be — a personal project, a prototype, one specialist’s corner. But every individual owner is a single point of failure with a calendar: holidays, illness, a new job. The request still routes, politely, to someone who will never answer it, and the team learns to merge around the blockage or wait out the absence. A team owner fails softer: the request lands on a group, anyone on it can review, and membership can change without editing the file.
The sharp version of this is the high-risk path with a single individual owner. In the sample, db/migrations/ belongs to @carol alone: every schema change waits for one person, and if Carol leaves, the routing points at a ghost until someone notices. The fix is boring — add the team as co-owner, keep the individual if their eye is genuinely the point — and it is exactly the kind of finding an audit should surface, because no one re-reads a working CODEOWNERS file looking for it. Mixed files, teams for the load-bearing paths and individuals for personal corners, are healthy; the auditor notes the mix as information, not as an error.
Keeping the file alive as teams change
CODEOWNERS rots in predictable ways: teams are renamed and the old name silently owns things forever, directories are added and never get a rule, a duplicate line creeps in during a merge and shadows the rule below it. The countermeasure is a rhythm, not a rewrite: re-run the audit whenever a top-level directory appears, when a team is created or dissolved, and on a schedule — quarterly is enough for most repositories — with a fresh git ls-files list each time, because a stale list certifies coverage of a repository that no longer exists.
Run yours with the CODEOWNERS & Review Policy Auditor: paste the file, add the file list, and read the score — 100 for the cleaned-up version of the sample below — the findings grouped by severity, and the coverage table that names the winning rule for every file. It runs entirely in your browser, because a CODEOWNERS file plus a full file list is a map of your repository and its responsible people, and that map should not be uploaded to be checked. It belongs to the same family as the GitHub Actions Workflow Auditor: the workflow decides what runs with your secrets, CODEOWNERS decides who watches it change — audit both files, then check the branch protection that gives them force.
The sample: a CODEOWNERS file with planted problems
# Demo CODEOWNERS — deliberately broken
* @acme/platform
docs/ @acme/docs-team
docs/ @alice
src/ @bob not-an-owner
.github/workflows/ @acme/platform
db/migrations/ @carol
*.lock @acme/platform
legacy/
README.md alice@example
mobile/ @acme/mobile-team