# 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 November 30, 2026. Canonical: https://sniptide.com/templates/codeowners
Open it in the Sniptide editor: https://app.sniptide.com/new?template=codeowners
Files as JSON: https://sniptide.com/templates/codeowners.json

## Files

### .github/CODEOWNERS

```
# 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/maintainers
```

## How GitHub reads it [#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](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/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-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 [#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 [#variant-a-small-team]

For a few people without GitHub teams, name users directly and keep the file short:

```text title=".github/CODEOWNERS"
*            @alice @bob
/infra/      @carol
```

Two default owners mean either can approve, so one person's holiday doesn't block every merge.
