---
title: "Choose the CODEOWNERS pattern that matches a team's directory | Proofline"
description: "Use /path/ for a team that owns a directory and everything below it; it is anchored at the root and recursive."
url: https://proofline.sh/learn/codeowners-directory-patterns/
---

[Learning center](/learn/)

# Choose the CODEOWNERS pattern that matches a team's directory

Use /path/ for a team that owns a directory and everything below it; it is anchored at the root and recursive. A /path/ line covers only the files directly inside, so deeper files fall to another owner or none. Unanchored path/ and /path match that name anywhere in the tree.

Code review The Proofline team November 23, 2026 4 min read

## What each pattern matches

GitHub's example CODEOWNERS file documents each directory form with a comment. [About code owners: example file](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners#example-of-a-codeowners-file)

| Pattern | What the documentation says it matches |
| --- | --- |
| `/docs/` | "any file in the `/docs` directory in the root of your repository and any of its subdirectories" |
| `/build/logs/` | "any files in the build/logs directory at the root of the repository and any of its subdirectories" |
| `docs/*` | "files like `docs/getting-started.md` but not further nested files like `docs/build-app/troubleshooting.md`" |
| `apps/` | "any file in an apps directory anywhere in your repository" |
| `**/logs` | "any file in a `/logs` directory such as `/build/logs`, `/scripts/logs`, and `/deeply/nested/logs`" |

The page also shows `/apps/github` with no trailing slash used for a subdirectory, so a path without a slash covers the directory's contents too. The patterns follow "most of the same rules used in gitignore files," and they are case sensitive. [CODEOWNERS syntax](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners#codeowners-syntax)

Two of these rows are easy to misuse. `/path/*` looks like "everything in path," but the documentation says it stops at the first level. `path/` without a leading slash looks like the root directory, but it matches a directory of that name at any depth.

## Node.js: a single star that stops one level down

Node.js uses all three forms in one file, which makes the difference visible. [nodejs/node .github/CODEOWNERS](https://github.com/nodejs/node/blob/main/.github/CODEOWNERS), read on 2026-11-23. Its header says the file is for "courtesy pings," not requirements for landing, so the consequence there is who is notified.

The test runner section reads:

```
/doc/api/test.md @nodejs/test_runner
/lib/internal/main/test_runner.js @nodejs/test_runner
/lib/internal/test_runner/* @nodejs/test_runner
/lib/test.js @nodejs/test_runner
/lib/test/reporters.js @nodejs/test_runner
/test/parallel/test-runner-* @nodejs/test_runner
```

The repository has files below that directory, such as `lib/internal/test_runner/reporter/spec.js` and `lib/internal/test_runner/mock/mock.js` (both present on 2026-11-23). By the documented meaning of `docs/*`, `/lib/internal/test_runner/*` matches neither, because they are nested one level deeper. No other line in the file names them, so a change to the spec reporter or the mock implementation requests nobody from the test runner team, while a change to a file directly in `lib/internal/test_runner/` does.

The same file shows both fixes. Its contributing guides use an explicit recursive pattern, `/doc/contributing/**/* @nodejs/tsc`, and the WASI tests use the directory form, `/test/wasi/ @nodejs/wasi`. Either would carry the test runner team down into `reporter/` and `mock/`.

You can confirm a case like this without reading patterns. Browse to the file and hover over the shield icon in its header; the tooltip reads "Owned by USER or TEAM (from CODEOWNERS line NUMBER)." [About code owners](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners#about-code-owners)

## An unanchored pattern that reaches too far

Suppose a fictional repository gives its documentation team the docs directory with:

```
docs/   @acme/docs
```

Because the pattern has no leading slash, it behaves like the documented `apps/` row and matches every directory named `docs`. If `services/payments/docs/` holds the payment team's API reference, the documentation team is the last match for it unless a later line says otherwise. With code owner review required, their approval satisfies changes to the payments reference, and the payments team is not asked. Writing `/docs/` keeps the documentation team at the root.

Unanchored patterns are the right tool when a name means the same thing wherever it appears. Kibana clears the owner of `moon.yml` files throughout the tree with an empty `**/moon.yml` line because, as its comment says, they are "generated files covered by CI checks." A later `/moon.yml` line gives the root file back to its operations team. [elastic/kibana .github/CODEOWNERS](https://github.com/elastic/kibana/blob/main/.github/CODEOWNERS), read on 2026-11-23.

## What the right pattern does not catch

A pattern that matches exactly the intended files can still lose to a later line, since GitHub applies only the last match; [the last-match rule](/learn/codeowners-last-matching-pattern-wins/) covers ordering. A recursive pattern also does not follow code that moves: when a team's module is moved to a new directory, its line keeps pointing at the old path until someone edits it, and the moved files take whatever owner the new location has.

## The cost of each choice

A recursive pattern asks the team to review everything below the directory, including test fixtures, generated snapshots and vendored files that happen to live there. That is the friction that leads teams to approve without reading. A first-level pattern asks less but leaves deeper files to fall through to another owner, often the default `*` team, which is the opposite failure. The fix for the first is a later line that hands the noisy subdirectory to someone else or to no one; [owning generated and vendored files](/learn/codeowners-generated-and-vendored-files/) describes those choices.

## Pick the pattern from the boundary

Start from the boundary the team owns, then write the pattern for it:

1.  A directory and everything in it, at one place in the tree: `/path/`.
2.  Only the files directly in a directory, with subdirectories owned by others: `/path/*`, and add a line for each subdirectory so none falls through.
3.  A name that recurs across the tree with one owner everywhere: `**/name` or `name/`.
4.  A file type across the tree: `*.ext`, placed after the directory lines it should override.

After editing, hover over one file at the deepest level of each team's directory and check the tooltip names the line you wrote. CODEOWNERS also does not support gitignore's `!` and `[ ]` forms, which [a separate guide](/learn/codeowners-gitignore-syntax-differences/) covers.

## One month of free code review.

New organizations get one calendar month of hosted code review for private and public GitHub repositories. No card or cloud connection required. [Eligibility and fair-use terms](/free-code-review/).

[Start free with GitHub](https://proofline.sh/orgs/plan?offer=free_month)

## Related reading

-   ### [Which CODEOWNERS line owns a file when several match?](/learn/codeowners-last-matching-pattern-wins/)
    
    Code review The Proofline team November 23, 2026 4 min read
    
-   ### [Which gitignore habits fail in a CODEOWNERS file?](/learn/codeowners-gitignore-syntax-differences/)
    
    Code review The Proofline team November 23, 2026 4 min read
