Learning center

When should a CODEOWNERS path have no owner?

Leave a path unowned when a broad pattern hands it to a team that cannot judge it and another check covers the path. Write the bare pattern after the broad line and say why in a comment. Under required code owner review, any writer's approval then satisfies that path, so keep it off code whose mistakes are expensive.

What an empty line does#

A CODEOWNERS line normally names a pattern and one or more owners. A line with a pattern and no owners is also valid, and GitHub's own example uses one to carve a subdirectory out of a team's area:

/apps/ @octocat
/apps/github

The documentation explains the effect: "@octocat owns any file in the /apps directory in the root of your repository except for the /apps/github subdirectory, as its owners are left empty. Without an owner, changes to apps/github can be made with the approval of any user who has write access to the repository." About code owners: example file

Two consequences follow. Nobody is requested automatically for that path, so the author has to pick a reviewer. And the code owner requirement no longer applies there, although the ruleset's required number of approvals still does: a ruleset can require approvals "from people with write permissions in the repository or from a designated code owner." Require a pull request before merging

The empty line only works if it comes after the line it overrides, because the last matching line wins. Which CODEOWNERS line owns a file explains the ordering.

CPython's exclusions section#

CPython keeps its carve-outs together at the end of the file, under a heading that explains the placement: "Exclusions from .github/CODEOWNERS should go at the very end because the final matching pattern will take precedence." Its header gives the method: "To exclude a file from ownership, add a line with only the file." python/cpython .github/CODEOWNERS, read on 2026-11-23.

The clearest entry shows why a carve-out is sometimes needed. The standard library section assigns anything mail-related to the email team with a wildcard:

**/*mail*                     @python/email-team

That pattern also matches .mailmap, the Git file that maps contributor names and email addresses, which has nothing to do with the email package. The exclusions section removes it:

# Exclude .mailmap from being owned by @python/email-team
.mailmap

The same section excludes Lib/test/lazy_imports_all_exclude.txt, which the **/*import* line would otherwise assign to the import system's maintainers, and Doc/tools/removed-ids.txt, which sits inside the Doc/tools/ directory owned by the documentation tooling maintainers. Each exclusion carries a comment saying what it excludes, and the .mailmap one also names the team.

CPython's header also says that an entry "does not imply 'ownership', despite the name of the file," but that those listed "take an interest" and are added as reviewers. The exclusions therefore save maintainers from review requests they cannot act on.

A carve-out that makes a gap visible#

Grafana uses the empty line for the opposite purpose. Its API clients package has a catch-all owner, then an empty line for the generated clients directory, then one line per client:

/packages/grafana-api-clients/ @grafana/grafana-frontend-platform @grafana/grafana-frontend-navigation
/packages/grafana-api-clients/src/clients/rtkq/
/packages/grafana-api-clients/src/clients/rtkq/dashboard/ @grafana/dashboards-squad

The comment above says the empty line "removes the package catch-all so a new client dir with no matching line is left unowned (surfacing the gap in review) rather than being silently assigned" to the platform teams. grafana/grafana .github/CODEOWNERS, read on 2026-11-23. GitHub itself does not flag an unowned file, so the gap surfaces only if a reviewer or a tool notices that no team was requested.

A commented line is not an empty line#

CockroachDB hides some ownership lines from GitHub by prefixing them with #!, which keeps the line readable by its internal tooling while GitHub treats it as a comment. cockroachdb/cockroach .github/CODEOWNERS, read on 2026-11-23. One pair reads:

/.github/                    @cockroachdb/dev-inf
#!/.github/CODEOWNERS          @cockroachdb/unowned

Because GitHub skips the second line, .github/CODEOWNERS stays owned by @cockroachdb/dev-inf. A commented line removes nothing; the earlier match still applies. To make a path unowned for GitHub, the bare pattern has to be an active line.

What an unowned path does not catch#

An empty line removes the one review the owners would have given. No one checks that the person who approves understands the file, and no one is notified when it changes. If the path holds generated output, a check that regenerates the file and compares it with the commit is what catches a hand edit; owning generated and vendored files covers that case.

The friction it removes, and its price#

The benefit is fewer requests that a team approves without reading, like the email team being asked about .mailmap. Requests that a team cannot act on teach it to approve without looking, which weakens its review of the files it does own. The price is that a carve-out on the wrong path quietly lowers the bar there to "any writer."

Deciding on a carve-out#

Leave a path unowned when all three hold: a broader pattern catches it by accident or by layout, the matched team cannot judge changes to it, and either another check covers it or a wrong change is cheap to fix. Then:

  1. Add the bare pattern in a final exclusions section, below every line it overrides.
  2. Put a comment above it naming the file and the team it is taken from, as CPython does for .mailmap.
  3. Browse to the file in the repository and confirm its header no longer shows a code owner.

Do not carve out CI workflows, deployment configuration, authentication code or the CODEOWNERS file itself. Those paths need a named owner even when the default team is busy; give CODEOWNERS its own owner explains the last one.

One month of free code review.

New organizations get one calendar month of hosted code review for private and public GitHub repositories. No card or cloud connection required. Eligibility and fair-use terms.

Start free with GitHub

Related reading