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:
- Each line is
pattern @owner1 @owner2, where owners are GitHub usernames (@alice), teams (@org/team), or member emails. - 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.
- 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-nameand the team must have write access to the repo. - Enable the “Require review from Code Owners” branch-protection rule to make owners’ approval mandatory.