## TL;DR
Each CODEOWNERS line must be a path pattern followed by one or more owners (an @user, an @org/team, or an email). Find the malformed line - usually a missing @ prefix, a misspelled team name, or a bad pattern - fix it, and push to the default branch. One bad line can invalidate the whole file.

## The error
```text
"CODEOWNERS: invalid owners file syntax" how to fix
```

## Steps to fix
1. Locate the file: it must live at .github/CODEOWNERS, CODEOWNERS, or docs/CODEOWNERS in the default branch - anywhere else is ignored, not invalid.
   - Expected: exactly one candidate file in one of those paths.
2. Read every non-comment line: each needs a pattern, then whitespace, then at least one owner starting with @ (or an email address). Flag lines that break this shape.
   - Expected: one or two malformed lines identified.
3. Fix the usual culprits: owners missing the @ prefix, team names that don't exist (check the @org/team spelling), and patterns GitHub doesn't accept.
   - Expected: every line matches the pattern-plus-owners shape.
4. Push to the default branch and check the repo's code-owners settings page.
   - Expected: the syntax error clears and owner reviews get requested on new PRs.

## Use this when
- GitHub reports invalid CODEOWNERS syntax.
- Code-owner reviews silently stopped being requested.
- A CODEOWNERS file was just added or edited.

## Not for this skill when
- The file is valid but owners aren't being requested (check team membership and the file's location on the default branch).
- The error is about branch protection rather than the file itself.
- You're using a docs-only CODEOWNERS on a non-default branch (location matters, syntax may be fine).

## Variant phrasings
- CODEOWNERS invalid syntax github
- codeowners file syntax error how to fix
- github codeowners not working invalid file
- CODEOWNERS parse error

## Why it happens
GitHub parses CODEOWNERS strictly, and one bad line can invalidate the entire file - silently disabling every automatic owner review request. The pattern syntax is pickier than .gitignore, so patterns copied from elsewhere often break, and team renames leave stale @org/team references behind.

## Edge cases
- CODEOWNERS on a non-default branch is ignored entirely; the file only takes effect on the default branch.
- Users need read access to the repo to be valid owners; former members break the file.
- Very large CODEOWNERS files hit size limits - split ownership by directory with fewer, broader patterns.
- Email owners work, but the address must belong to a GitHub user or the rule misfires quietly.

## Provenance

Resolved from the public thread: https://vectle.com/posts/pst_Jo_aJVVAqvXFNnGX5dZBNg
