CODEOWNERS File Generator

Create a CODEOWNERS file row by row: a file-path pattern on the left, one or more owners on the right. The generator validates that each owner is a @username, @org/team, or email, warns about common mistakes, and emits the file in the order these systems expect — general rules first, specific rules last, since the last match wins. Works for GitHub, GitLab, and Bitbucket.

CODEOWNERS

How to use the CODEOWNERS File Generator

Each rule pairs a path pattern with the people or teams responsible for matching files. Put broad rules — such as a catch-all * — near the top and narrow rules below them; the file is read top to bottom and the last matching line decides ownership, so the most specific pattern must come last. List multiple owners separated by spaces, each one a @user, an @org/team, or an email address.

The generated file goes at .github/CODEOWNERS, CODEOWNERS in the repo root, or docs/CODEOWNERS on GitHub; GitLab and Bitbucket look in similar locations. Once committed, owners are requested for review automatically when a pull or merge request touches files they own. Warnings below the output flag owners missing an @ and patterns that look malformed.

How CODEOWNERS works

A CODEOWNERS file declares who owns which parts of a repository. Each non-comment line is a path pattern followed by one or more owners. When someone opens a pull or merge request, the platform finds the files it changes, matches them against the patterns, and automatically requests review from the owners — and, if branch protection requires owner approval, blocks the merge until they sign off.

The pattern syntax follows gitignore rules: * matches anything, / anchors to the repository root, a trailing / matches a directory, and ** spans directories. Owners are GitHub or GitLab usernames and teams prefixed with @ (for example @octocat or @acme/backend), or plain email addresses for users whose commit email the platform recognises. A line with a pattern and no owners explicitly removes ownership inherited from a broader rule above it.

The single rule that trips people up is precedence: the last matching pattern wins, not the most specific one. So a general line like * @acme/maintainers belongs at the top, and a targeted line like /infra/ @acme/platform belongs below it, so that changes under infra/ route to the platform team rather than the catch-all. Ordering the file from broad to narrow is what makes ownership behave the way you expect.

Common use cases

  • Automatic review routing. Request the right team's review the moment a PR touches their code.
  • Enforcing sign-off. Pair with branch protection so owners must approve changes to critical paths.
  • Onboarding a monorepo. Map each top-level directory to the team that maintains it.
  • Documenting ownership. Give a clear, version-controlled record of who is responsible for what.

Frequently asked questions

Which line wins when several patterns match?

The last matching line in the file, reading top to bottom — not the most specific pattern. That is why a catch-all belongs near the top and targeted directory rules belong below it. This generator keeps the rules in the order you enter them so you control precedence.

Where do I put the file?

On GitHub it can live in the repository root, in .github/, or in docs/ — whichever it finds first applies. GitLab reads CODEOWNERS from the root, .gitlab/, or docs/. Commit it to the default branch (and any protected branches) for it to take effect.

What is a valid owner?

A GitHub or GitLab user or team prefixed with @, such as @alice or @acme/backend, or an email address that matches a user account. Plain names without @ are not valid owners, and the generator warns when it sees one.

Can a path have no owner?

Yes. A pattern with no owners after it removes the ownership a broader rule above would otherwise assign, which is useful for carving an exception out of a catch-all rule.

Does it work for GitLab and Bitbucket too?

Yes. All three use the same pattern-then-owners format. Minor differences exist — GitLab supports optional section headers in [brackets] — but the core file this tool generates is valid on each platform.
Embed this tool on your site

Free to embed, no attribution required (but appreciated). Paste this where you want the tool to appear: