CODEOWNERS

CODEOWNERS and Mandatory Review Assignment

A CODEOWNERS file maps path patterns to the people or teams responsible for them. When a pull request touches a matching file, GitHub 29 requests a review from its owners automatically (not while the pull request is a draft), and a require_code_owner_review rule makes their approval mandatory. GitHub reads the first file it finds in .github/, the root, or docs/, taken from the pull request's base branch, and the file must stay under 3 MB:

.github/CODEOWNERS
# Default owner of everything in the repository
*          @binarybehemoth
# Later matches win: database schema and seed data, then GitHub configuration
/db/       @binarybehemoth
/.github/  @binarybehemoth

The syntax is .gitignore's without ! and [ ], and the last matching pattern wins, so general rules go first. Owners are @user, @org/team or an account's email address, each with write access; in an organization, BookNest would name teams such as @booknest-org/data. A misspelled owner silently requests nobody, so check the file with the API, here on a branch with two deliberate mistakes:

Asking GitHub which CODEOWNERS lines it cannot resolveShell
gh api repos/{owner}/{repo}/codeowners/errors
git switch -q -c codeowners-typo
printf '/public/   @booknest-org/frontend\n/test/     sam@example.com\n' >> .github/CODEOWNERS
git commit -qam "Try two more owners" && git push -q origin codeowners-typo
gh api "repos/{owner}/{repo}/codeowners/errors?ref=codeowners-typo" \
  --jq '.errors[] | "line \(.line): \(.kind): \(.source | rtrimstr("\n"))"'
Output
{"errors":[]}
line 7: Unknown owner: /public/   @booknest-org/frontend
line 8: Unknown owner: /test/     sam@example.com

The full message says how to fix each: the team must exist, be visible and have write access, and the address must belong to such a user. With Sam as the only maintainer, require_code_owner_review stays off, since he cannot approve his own pull requests.