Configure CODEOWNERS file
✓Works with OpenClaudeYou are a GitHub repository administrator. The user wants to configure a CODEOWNERS file to automate code review assignments based on file paths and directory patterns.
What to check first
- Verify repository has at least one branch protection rule enabled (required for CODEOWNERS enforcement)
- Run
git rev-parse --show-toplevelto find your repository root directory - Confirm you have write access to the repository (admin or maintain role minimum)
Steps
- Create a
CODEOWNERSfile in the root directory or in the.github/folder at the exact path.github/CODEOWNERSorCODEOWNERS - Define ownership rules using GitHub handles or team names, with format:
path/pattern @usernameorpath/pattern @org/team-name - Add specific file patterns first (e.g.,
*.md @docs-team), then broader directory rules, then catch-all fallback - Use
@prefix for individual users and@organization/team-nameformat for teams; teams must have explicit write access to the repo - Test patterns locally by running
git check-attr diff merge codeowners -- path/to/fileto validate which rules match - Commit the CODEOWNERS file to your default branch (typically
mainormaster) - Navigate to repository Settings → Branches → Branch protection rules and enable "Require code owner review before merging"
- Verify enforcement by opening a pull request that modifies protected paths—code owners should be auto-requested
Code
# CODEOWNERS file
# Format: path/pattern @owner1 @owner2 @org/team-name
# Root level catch-all
* @default-owner
# Documentation ownership
*.md @docs-team
docs/ @org/documentation
# Frontend code
src/components/ @frontend-lead @org/frontend-team
src/pages/ @frontend-lead
frontend/ @org/frontend-team
# Backend code
api/ @backend-lead @org/backend-team
server/ @backend-lead
src/services/ @backend-lead
# Infrastructure and deployment
.github/workflows/ @devops-team @infrastructure-owner
terraform/ @devops-team
docker/ @devops-team
Dockerfile @devops-team
# Configuration files
package.json @tech-lead
tsconfig.json @tech-lead
.env.example @security-team
# Database migrations
migrations/ @database-admin @backend-lead
# Tests and CI/CD
.github/ @devops-team
jest.config.js @tech-lead
tests/ @qa-team
# Security-sensitive paths
security/ @security-team
secrets/ @security-team
auth/ @security-team @backend-lead
Pitfalls
- Team names are case-sensitive and must match exactly; use
@org/team-slug(lowercase with hyphens), not the display name - CODEOWNERS only works on the default branch—changes to CODEOWNERS on
Common Pitfalls
- Treating this skill as a one-shot solution — most workflows need iteration and verification
- Skipping the verification steps — you don't know it worked until you measure
- Applying this skill without understanding the underlying problem — read the related docs first
When NOT to Use This Skill
- When a simpler manual approach would take less than 10 minutes
- On critical production systems without testing in staging first
- When you don't have permission or authorization to make these changes
How to Verify It Worked
- Run the verification steps documented above
- Compare the output against your expected baseline
- Check logs for any warnings or errors — silent failures are the worst kind
Production Considerations
- Test in staging before deploying to production
- Have a rollback plan — every change should be reversible
- Monitor the affected systems for at least 24 hours after the change
Related Workflow Automation Skills
Other Claude Code skills in the same category — free to download.
Git Workflow
Set up Git branching workflow (GitFlow, trunk-based)
Pre-Commit Hooks
Configure pre-commit hooks (Husky, lint-staged)
Auto Formatter
Set up auto-formatting (Prettier, ESLint)
Issue Template
Create GitHub issue and PR templates
Dependabot Setup
Configure Dependabot/Renovate for auto-updates
Release Workflow
Automate release workflow with changelogs
Branch Protection
Set up branch protection rules
Auto Labeler
Auto-label PRs based on changed files
Want a Workflow Automation skill personalized to YOUR project?
This is a generic skill that works for everyone. Our AI can generate one tailored to your exact tech stack, naming conventions, folder structure, and coding patterns — with 3x more detail.