Skip to content

CODEOWNERS and coding agents: make the right person review the right files

A CODEOWNERS file maps paths to reviewers. With agents writing changes, it is the safest way to make sure sensitive files get an owner’s review.

Published by Contextingo.

GitHub’s CODEOWNERS file assigns people or teams to paths. When a pull request changes a path, the owners are requested as reviewers, and branch protection can require their approval.

An example

# .github/CODEOWNERS
*                 @acme/maintainers
/infra/           @acme/platform
/src/payments/    @acme/payments
*.sql             @acme/data

The last matching pattern wins, so put general rules first and specific ones after.

Why it helps with agents

  • An agent may touch files it was not asked to. The owners of those files are asked to review.
  • Sensitive areas, such as payments and infrastructure, always get an informed reviewer.
  • Reviewers see changes in their area without scanning every pull request.

To make it work

  1. Use teams, not single people, so a holiday does not block merges.
  2. Turn on “Require review from Code Owners” in branch protection.
  3. Keep the file current. A path nobody owns has no safeguard.

See branch protection for agent pull requests.

Questions

Good to know.

Where does the file live?

In the repository root, in `docs/`, or in `.github/`.

Does it work on other hosts?

GitHub and GitLab both support code owners, with different syntax details.

Nothing learned is lost. Nothing unchecked is done.