How to use the CODEOWNERS generator
- In Default owners for everything (*), enter the people or teams who review any file not covered by a later rule, for example
acme/maintainers. Leave it blank to skip the*rule. - In Rules, write one line per pattern: the pattern, a space, then one or more owners separated by spaces.
- Add
# commentlines if you want headings; they are copied as they are. - Copy or download the file, save it as
CODEOWNERSin.github/, and commit it to your default branch.
What it does and when to use it
A CODEOWNERS file tells GitHub who is responsible for which parts of a repository. When a pull request touches a matching file, the owners are added as reviewers automatically. It suits teams where payments code needs the payments team and docs changes need a writer, and solo maintainers who want one reviewer always requested.
The file is one piece of a tidy repository. The pull request template generator shapes what reviewers see, the CONTRIBUTING.md generator explains the review process to newcomers, and the GitHub Actions generator adds the automated checks that run beside the human review.
How it works
Each owner is checked in turn. A name with no @ gets one (asha becomes @asha, acme/docs-team becomes @acme/docs-team). Names that already start with @ and email addresses are left untouched. Default owners may be separated by spaces or commas.
The tool warns about two problems but still writes the line, so you can see it and fix it:
- a pattern starting with
!or containing[ ], which GitHub’s code owners syntax does not support; - a pattern with no owner, which removes ownership for that path and is usually a slip.
Worked examples
The sample rules give this file body:
# Default owners
* @acme/maintainers
/docs/ @acme/docs-team
*.js @asha
/src/payments/ @asha @ravi
/.github/ @acme/platform
Mistakes flagged. With no default owner and the rules !secret.txt bob, docs/ dev@example.com and /vendor/, the email stays as typed, while the warnings say “CODEOWNERS does not support ! negation or [ ] character ranges.” and that /vendor/ has no owner.
Mixed input. Default owners @octo-org/web lead-dev become * @octo-org/web @lead-dev.
Limits and tips
- The tool cannot check that users or teams exist or have write access.
- Rules are kept in the order you type them; it does not sort or merge them.
- Patterns follow .gitignore style, with exceptions:
/docs/matches the top-level folder only, whiledocs/matches a docs folder anywhere.
Frequently asked questions
Where do I save the CODEOWNERS file?
Which rule wins when two patterns match a file?
How do I make code owners required reviewers?
Can I use an email address instead of a username?
Why does my team not get review requests?
How do we know nothing is uploaded? Test it yourself on the privacy proof page.