Context: repository behavior and why CODEOWNERS is needed
In this lesson we use a GHAS schedules demo repository. When you create a branch and open a pull request, you may notice no automatic reviewers are requested because:- This is a public repository, so enterprise-level rule sets do not apply.
- There are no repository-level rule sets configured that require reviewers.
.github/CODEOWNERS file to the repository.
Example: existing PR template (kept for context)
Where to place CODEOWNERS
Best practice is to create the CODEOWNERS file under the repository’s.github directory:
- Path:
.github/CODEOWNERS - Commit it to the default branch (commonly
main) so GitHub applies it to new PRs.
Place
.github/CODEOWNERS on the repository default branch (e.g., main) so new pull requests trigger the configured owners automatically. If you don’t have direct write access to main, add the file via a pull request.CODEOWNERS file format and examples
Use@org/team-slug to reference teams and @username for individuals. Patterns follow GitHub’s CODEOWNERS glob-like syntax.
Simple example: require @game-devstudio/pc-devs review for any .js file:
For full pattern reference, see GitHub’s documentation: About code owners.
Common validation errors and how to resolve them
When committing a CODEOWNERS file, GitHub may show a validation error. Typical causes and resolutions are:If a referenced team lacks write access or is private/invisible to the repository, GitHub will treat the CODEOWNERS entry as invalid. Ensure the referenced team exists, is visible (if required), and has at least
Write permission on the repository.- Organization > Teams (select team) — confirm slug and visibility.
- Repository > Settings > Collaborators and teams — grant the team
Writeaccess.

Commit and workflow considerations
- Commit the CODEOWNERS file to the default branch so it applies to new PRs.
- If you cannot commit directly to the default branch, open a pull request adding the
.github/CODEOWNERSfile; once merged, it will take effect. - GitHub will automatically request the specified owners when matching files are changed in future PRs.
Quick checklist before committing CODEOWNERS
- File placed at
.github/CODEOWNERS. - Entries use correct
@org/team-slugor@username. - Teams referenced exist and slugs are correct.
- Teams have at least
Writeaccess to the repository. - File committed to the repository default branch.
References and further reading
That’s it — with.github/CODEOWNERS configured and the referenced team visible with write access, changes to *.js files will trigger review requests for @game-devstudio/pc-devs.