CODEOWNERS
Automatic review assignment based on file ownership patterns.
Drok supports the CODEOWNERS file format with identical syntax to GitHub. Define ownership rules for files and directories, and Drok automatically assigns reviewers to merge requests that modify owned files.
Configuration
Create a CODEOWNERS file in one of these locations (checked in order):
.drok/CODEOWNERSCODEOWNERSdocs/CODEOWNERS
Syntax
# Each line defines a pattern and one or more owners
# Owners can be usernames or team names
# Default owners for everything
* @your-org/engineering
# Backend code
/src/api/ @your-org/backend
/src/database/ @your-org/backend @alice
# Frontend code
/src/ui/ @your-org/frontend
/src/components/ @your-org/frontend
# Infrastructure
/infra/ @your-org/devops
Dockerfile @your-org/devops
docker-compose.yml @your-org/devops
# Documentation
/docs/ @your-org/docs-team
*.md @your-org/docs-team
# Security-sensitive files
/src/auth/ @your-org/security @your-org/backend
/src/crypto/ @your-org/security
# Build configuration
Cargo.toml @bob
package.json @your-org/frontendPattern Matching
| Pattern | Matches |
|---|---|
* | All files |
*.rs | All Rust files in any directory |
/src/ | The src directory at the repository root |
src/ | Any src directory at any depth |
/docs/**/*.md | All Markdown files under the root docs directory |
Dockerfile | Any file named Dockerfile at any depth |
Later rules override earlier rules. If a file matches multiple patterns, the last matching pattern determines the owners.
Behavior
When a merge request is created or updated:
- Drok computes the set of changed files
- Each changed file is matched against CODEOWNERS patterns
- The union of all matched owners is computed
- Those owners are automatically added as reviewers
Required Reviews
When combined with branch protection rules, CODEOWNERS reviews can be required:
drok branch-protection set main --require-review-from-codeownersWith this setting, a merge request cannot be merged until at least one owner from each matched CODEOWNERS pattern has approved.
Optional vs. Required Owners
By default, all CODEOWNERS are optional reviewers — they are notified and listed on the merge request, but their approval is not required unless branch protection mandates it.
To mark specific patterns as always requiring approval:
# Prefix with [required] to mandate approval
[required] /src/auth/ @your-org/security
[required] /src/crypto/ @your-org/securityViewing Ownership
Check who owns a specific file:
drok codeowners my-org/my-repo src/api/handler.rsOutput:
src/api/handler.rs
Owners: @your-org/backend
Rule: /src/api/ @your-org/backend (CODEOWNERS:8)The web interface displays ownership information on every file page and in the merge request reviewer sidebar.
Validation
Drok validates the CODEOWNERS file on push:
- Invalid usernames or team references produce a warning
- Invalid patterns produce a warning
- Syntax errors prevent the file from being used (falls back to previous valid version)
Validation warnings appear in the repository settings page under Code Owners.