CODEOWNERS file example
A CODEOWNERS file maps paths to the people or teams who must review changes to them, and GitHub requests their review on every pull request that touches those paths. Save the example below as .github/CODEOWNERS, replace the teams and paths with yours, and turn on code owner reviews in your branch rules.
Updated
Files
# Each line is a file pattern followed by one or more owners.
# The last matching pattern takes precedence, so general rules go first.
# Default owners for everything in the repository.
* @acme/maintainers
# Application code
/apps/web/ @acme/frontend
/apps/api/ @acme/backend
/packages/ui/ @acme/design-system
# Database migrations need a backend review on top of the default.
/apps/api/migrations/ @acme/backend @acme/database
# Infrastructure and CI
/infra/ @acme/platform
/.github/workflows/ @acme/platform
Dockerfile @acme/platform
# Documentation
/docs/ @acme/docs
*.md @acme/docs
# Ownership rules change only with a maintainer's review.
/.github/CODEOWNERS @acme/maintainersSave with your agent
Run this command to add Sniptide to Claude Code in the current project. Open /mcp in Claude Code and sign in to Sniptide. Once the server shows as connected, use the prompt below to save a private copy in your library.
claude mcp add --scope local --transport http sniptide https://app.sniptide.com/api/mcpRead https://sniptide.com/templates/codeowners.json and use create_snippet to save its files as a private Sniptide snippet titled "CODEOWNERS file example". Keep the file names and contents from the JSON.How GitHub reads it
GitHub uses the first CODEOWNERS file it finds in .github/, the repository root or docs/, on the pull request's base branch. Each line is a pattern and its owners. When several patterns match a file, the last match wins. That is why the catch-all * comes first and specific folders follow. About code owners
Owners are @username, @org/team-name or an email address linked to a GitHub account. Each owner needs write access to the repository, and a team needs to be visible with write access. Open the file on GitHub after you commit it: GitHub marks lines with unknown owners or invalid patterns.
Pattern syntax
Pattern | Matches |
|---|---|
* | Every file. |
/apps/web/ | The apps/web folder at the root and everything inside it. |
docs/ | Any folder named docs, at any depth. |
*.md | Markdown files anywhere. |
Dockerfile | Files named Dockerfile anywhere. |
/apps/api/migrations/ | The migrations folder. With two owners on the line, either one can approve. |
CODEOWNERS uses most .gitignore rules, but ! negation and [ ] character ranges don't work.
Require their review
The file alone only requests reviews. To make them required, open Settings → Rules → Rulesets, add a branch ruleset for your default branch, enable Require a pull request before merging and check Require review from Code Owners. A change to the migrations folder then needs approval from one of its owners before it can merge.
Variant: a small team
For a few people without GitHub teams, name users directly and keep the file short:
* @alice @bob
/infra/ @carolTwo default owners mean either can approve, so one person's holiday doesn't block every merge.