CODEOWNERS File Builder

Generate a GitHub CODEOWNERS file assigning reviewers by directory

Map file path patterns to GitHub users and teams and generate a valid CODEOWNERS file that auto-assigns the right reviewers on every pull request, with validation for the @owner syntax, last-match-wins ordering, and a default catch-all rule.

Where does the CODEOWNERS file go?

GitHub looks for it in the repository root, in the .github directory, or in the docs directory. Most teams use .github/CODEOWNERS. Only one location is used, with .github taking priority if several exist.

A CODEOWNERS file tells GitHub which people or teams should automatically review changes to specific parts of a repository. This builder maps path patterns to owners, validates the @owner syntax, and emits a correctly ordered file that auto-requests the right reviewers on every pull request.

How it works

CODEOWNERS uses gitignore-style path patterns followed by one or more owners:

  1. Each line is pattern @owner1 @owner2, where owners are GitHub usernames (@alice), teams (@org/team), or member emails.
  2. GitHub evaluates rules top to bottom and applies last-match-wins — the final matching line decides ownership — so general rules go first and specific ones last.
  3. A * pattern acts as a default catch-all so no file is left without a reviewer.

The tool warns when an owner is missing its @, when a team has no org/ prefix, or when a rule has no owners at all.

Tips and notes

  • Put the broad * default at the top and narrow rules below it so specificity wins.
  • Directory patterns should end with / to match everything inside, e.g. /src/api/.
  • Teams must be written as @org/team-name and the team must have write access to the repo.
  • Enable the “Require review from Code Owners” branch-protection rule to make owners’ approval mandatory.