GitHub CODEOWNERS generator
Build a valid CODEOWNERS file with live validation: path patterns, users, teams, and presets for common repo layouts. Free, runs entirely in your browser.
Save as .github/CODEOWNERS (or repo root / docs/).
# CODEOWNERS — generated with https://diffwise.app/tools/codeowners-generator # Order matters: the LAST matching pattern takes precedence. * @org/eng /apps/web/ @org/frontend /apps/api/ @org/backend /packages/ @org/platform /.github/ @org/devops
How does a CODEOWNERS file work?
GitHub reads CODEOWNERS from .github/, the repo root, or docs/ (first match wins) on the branch being merged into. When a pull request touches a file, the owners of the last matching pattern are automatically requested as reviewers. With branch protection's "Require review from Code Owners" enabled, their approval becomes mandatory.
Key syntax rules this generator enforces:
- Order matters. Later patterns override earlier ones, so put your catch-all
*rule first and specific paths after it. - Owners must be
@username,@org/team-name, or an email address. Teams must have explicit write access to the repo. - Patterns follow gitignore-style globbing with a few differences: no escaping, and spaces in paths are not supported.
/docs/matches a directory anywhere it appears under that path; a leading/anchors to the repo root;**matches across directories.
Common CODEOWNERS mistakes
- Team without repo access. GitHub silently ignores owners that lack write permission. The file looks fine; nothing happens.
- Catch-all last instead of first. A trailing
*rule overrides every specific rule above it because last match wins. - One owner for everything. That person becomes the review bottleneck for the whole repo. Spread ownership by path, and let automation carry the first pass.
- Unowned critical paths. Auth, billing, and migration directories deserve explicit, security-conscious owners.
CODEOWNERS assigns the humans. What about the first pass?
CODEOWNERS routes pull requests to the right people, but those people still read every diff cold. Most teams pair ownership routing with an automated first pass: Diffwise reviews every PR with 40+ specialist agents (security, performance, conventions) minutes after it opens, so your code owners start from a triaged diff with findings pinned inline. See How to Automate Code Review on GitHub for the full setup.
Frequently asked questions
Where does the CODEOWNERS file go?
In .github/CODEOWNERS, the repository root, or docs/. GitHub checks those locations in that order and uses the first file it finds on the target branch of the pull request.
Why isn't my CODEOWNERS file working?
The usual causes: the owner team lacks explicit write access to the repo, the file is on the wrong branch (GitHub reads it from the branch being merged into), a later catch-all pattern overrides your specific rule, or the file exceeds 3 MB.
Can CODEOWNERS require an approval before merge?
Yes. Enable 'Require review from Code Owners' in branch protection rules or rulesets. Without it, owners are only auto-requested as reviewers; their approval is optional.
Does the order of rules matter in CODEOWNERS?
Yes, and it trips everyone up: the LAST matching pattern wins, the opposite of an if/else chain. Put broad catch-alls at the top and specific paths below them.
Is this generator free?
Yes. Free, no signup, fully client-side. Your paths and team names never leave your browser.