CODEOWNERS and SPDX Cheat Sheet: Owners, Patterns and Licence IDs
Checked against GitHub CODEOWNERS and SPDX GitHub Docs (checked 28 Nov 2026), SPDX License List 3.29.0 (16 Sep 2026), SPDX spec 3.0.1 on 28 November 2026. Each section links to the official docs it was checked against.
Two small files that decide who reviews a change and what licence it ships under. This sheet covers GitHub's CODEOWNERS rules from the GitHub Docs and SPDX licence identifiers and expressions from the SPDX License List 3.29.0 and spec 3.0.1. We didn't push a CODEOWNERS file to a live repository for this page, so those rows are marked untested.
When to use what
Keep one CODEOWNERS file in .github/. GitHub looks in .github/, then the repository root, then docs/, and uses the first it finds, so a second copy elsewhere is ignored and only confuses people. Start with a catch-all * line for a default team, then add narrower paths below it, because the last matching line wins. Use teams rather than people so ownership survives someone leaving. CODEOWNERS only requests reviews; turn on "Require review from Code Owners" in branch protection or a ruleset if you want it enforced. Paste your file and some paths into the CODEOWNERS tester to see who owns what before you merge, and the glob pattern tester helps with trickier patterns.
For licences, always use an SPDX identifier instead of free text: MIT, Apache-2.0, GPL-3.0-or-later. For GNU licences pick -only or -or-later explicitly; the bare GPL-2.0 and GPL-3.0 IDs are deprecated. Use OR when users may choose, AND when they must comply with both, and WITH for an exception. The SPDX expression checker parses an expression and shows how it groups, and the licence generator writes the LICENSE file itself.
.github/CODEOWNERSPreferred location; GitHub checks .github/, then root, then docs/ and uses the first file found
* @acme/platformDefault owners for every file; put this line first so later lines override it
*.go [email protected]Owners can be an email address linked to a GitHub account
*.txt @octo-org/octocatsAssign a team; it must be visible and have write access to the repo
/.github/CODEOWNERS @acme/leadsGive the CODEOWNERS file itself an owner so nobody quietly edits ownership
/apps/ @octocat @hubotList several owners on one line; any one approval satisfies the requirement
Patterns follow most .gitignore rules, but ! negation, [ ] character ranges and escaping # with a backslash are not supported. Invalid lines are skipped. Files over 3 MB are not loaded at all.
/build/logs/ @doctocatLeading slash: only the build/logs folder at the repo root and everything under it
docs/* [email protected]Only files directly inside any docs folder, not deeper subfolders
apps/ @octocatAn apps folder anywhere in the tree, with all its contents
**/logs @octocatAny logs folder at any depth
/apps/githubA pattern with no owner: that path needs no code owner review
*.js @js-owner # inline commentText after # is a comment; this later line beats an earlier *.js line
IDs are case-insensitive but use the canonical case from the list. Exceptions have their own list at https://spdx.org/licenses/exceptions-index.html.
MITMIT License, the usual permissive default for JavaScript packages
Apache-2.0Apache License 2.0, permissive with an explicit patent grant
BSD-2-Clause / BSD-3-ClauseSimplified and New BSD licences
ISC / 0BSDShort permissive licences; 0BSD drops the attribution requirement
MPL-2.0Mozilla Public License 2.0, file-level copyleft
GPL-3.0-only / GPL-3.0-or-laterGPLv3, pinned to that version or allowing later ones; bare GPL-3.0 is deprecated
LGPL-2.1-or-laterLesser GPL 2.1 or any later version
AGPL-3.0-onlyAffero GPL v3, copyleft that also covers network use
Unlicense / CC0-1.0Public-domain style dedications
Classpath-exception-2.0 / LLVM-exceptionException IDs, only valid on the right of WITH
Precedence from tightest to loosest: +, WITH, AND, OR. Operators must be all upper or all lower case.
MIT OR Apache-2.0Dual licence: the user may pick either
LGPL-2.1-only AND MIT AND BSD-2-ClauseConjunction: the user must comply with all three
GPL-2.0-or-later WITH Bison-exception-2.2Apply an exception to one licence; WITH needs spaces on both sides
MIT AND (LGPL-2.1-or-later OR BSD-3-Clause)Parentheses override the default grouping
LGPL-2.1-only OR BSD-3-Clause AND MITWithout brackets this means LGPL-2.1-only OR (BSD-3-Clause AND MIT)
EPL-1.0+Plus suffix on a non-GNU ID: this version or later; no space before +
LicenseRef-Acme-EULAYour own licence text that isn't on the SPDX list
// SPDX-License-Identifier: MITOne-line source file header in the language's comment syntax
"license": "(MIT OR Apache-2.0)"The same expression in a package.json license field
Worked example: Work out who reviews a change and what licence a file carries
A repository with this .github/CODEOWNERS:
* @acme/platform
*.ts @acme/frontend
/packages/api/ @acme/backend
/packages/api/vendor/
/.github/ @acme/leads
Now a pull request touches four files:
packages/api/src/user.ts -> @acme/backend
packages/web/src/App.ts -> @acme/frontend
packages/api/vendor/lib.js -> no code owner
.github/workflows/ci.yml -> @acme/leads
The rule is last match wins. user.ts matches *, *.ts and /packages/api/, and the API line is lowest, so backend owns it even though it is a TypeScript file. If you wanted frontend to review every .ts file, the *.ts line would have to come after the API line. The vendor folder has a pattern with no owner, which removes the requirement for that path. These outcomes follow the documented rules; paste the file into the CODEOWNERS tester to check them against your own paths. For the licence side, user.ts starting with // SPDX-License-Identifier: Apache-2.0 OR MIT tells scanners the file is dual licensed and the user can choose either.
Common mistakes
Putting the catch-all
*line at the bottom of CODEOWNERS.Put it first; because the last match wins, a final
*line overrides every specific rule above it.Writing owners on separate lines for the same pattern.
List all owners on one line; repeating the pattern means only the last line's owners count.
Using
!docs/**to exclude a folder, as in .gitignore.Negation isn't supported; add the path on its own line with no owner instead.
Assigning a team that only has read access and wondering why no review is requested.
Give the team write access to the repository and make sure it is visible.
Writing
GPL-3.0orApache 2in package metadata.Use exact SPDX IDs such as
GPL-3.0-or-laterorApache-2.0; free text and deprecated IDs confuse scanners.Writing
MIT or apache-2.0 With LLVM-exceptionwith mixed-case operators.Use all-caps
AND,ORandWITH; mixed case likeWithis invalid.
Related cheat sheets
Sources
- https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners
- https://spdx.org/licenses/
- https://spdx.org/licenses/exceptions-index.html
- https://spdx.github.io/spdx-spec/v3.0.1/annexes/spdx-license-expressions/
- https://spdx.dev/learn/handling-license-info/
How we research: where our facts come from, how often we re-check them, and why no one can pay for a review or a verdict.