Skip to content

CODEOWNERS defines who is responsible for specific parts of your codebase. Kizuna uses this for automatic reviewer assignment and required approvals.

CODEOWNERS File ​

Create a file named CODEOWNERS (no extension) in:

  • Repository root: /CODEOWNERS
  • .github/CODEOWNERS
  • .kizuna/CODEOWNERS

Syntax ​

Basic Pattern ​

# Pattern    Owners
/src/auth    @security-team
/docs        @docs-team @alice
*.js         @frontend-team

Directory Ownership ​

# All files in /src/auth
/src/auth @security-team

# All files in /docs and subdirectories
/docs/ @docs-team

File Extensions ​

# All JavaScript files
*.js @frontend-team

# All Python files
*.py @backend-team

Specific Files ​

# Exact file match
/package.json @devops-team
/.env.example @security-team

Multiple Owners ​

# Any of these can approve
/src/api @backend-team @alice @bob

Negation (Order Matters) ​

# Everyone owns everything
* @org/everyone

# Except /secrets (only security)
/secrets @security-team

Examples ​

Monorepo Structure ​

# Global fallback
* @org/core-team

# Frontend
/apps/web/ @frontend-team
/apps/mobile/ @mobile-team

# Backend
/apps/api/ @backend-team
/libs/database/ @backend-team @dba-team

# Infrastructure
/infra/ @devops-team
/k8s/ @devops-team

# Documentation
/docs/ @docs-team
*.md @docs-team

# Security-sensitive
/src/auth/ @security-team
/src/crypto/ @security-team

Microservices ​

# Each service owns itself
/services/auth/ @auth-team
/services/payments/ @payments-team
/services/notifications/ @notifications-team

# Shared libraries
/libs/common/ @platform-team
/libs/messaging/ @platform-team

Agent Ownership ​

Assign agents as owners:

# Security agent reviews all auth changes
/src/auth/ @security-agent

# Documentation agent reviews docs
/docs/ @docs-agent

# Performance agent reviews optimizations
/performance/ @perf-agent

How It Works ​

Automatic Assignment ​

When a PR modifies files:

  1. Kizuna checks which patterns match
  2. Collects all owners
  3. Assigns them as reviewers

Required Approvals ​

With branch protection:

  • At least one CODEOWNER must approve
  • Applies to protected branches only

Multiple Files Changed ​

If PR touches multiple owned areas:

  • All relevant owners are assigned
  • Each area needs approval

Special Syntax ​

Comments ​

# This is a comment
/src/auth @security-team

Email Addresses ​

# Can use emails instead of usernames
/src/auth [email protected]

Teams ​

# Organization teams
/src @org/frontend-team

Wildcards ​

# All files in any tests directory
**/tests/ @qa-team

# All config files anywhere
**/*.config.js @devops-team

Validation ​

Web UI Preview ​

Kizuna shows CODEOWNERS preview:

  1. Go to Settings → CODEOWNERS
  2. See pattern matches
  3. Validate syntax

API Validation ​

bash
curl /api/v1/repos/org/repo/codeowners/validate \
  -H "Authorization: Bearer $TOKEN"

Best Practices ​

  1. Be specific — Narrow patterns over broad
  2. Use teams — Easier than individual users
  3. Include agents — AI can be owners too
  4. Review regularly — Update as team changes
  5. Document why — Comments explain ownership

Troubleshooting ​

Owners Not Assigned ​

Check:

  1. File path matches pattern
  2. Owners exist and have access
  3. CODEOWNERS file valid

Too Many Reviewers ​

Narrow patterns:

# Too broad
/src @everyone

# Better
/src/auth @security
/src/ui @frontend

Pattern Not Working ​

Remember:

  • Order matters (last match wins)
  • Patterns are relative to repo root
  • Use leading / for absolute paths

Summary ​

CODEOWNERS enables:

  • Automatic assignment — Right reviewers every time
  • Expert review — Domain owners see changes
  • Distributed ownership — Clear responsibilities
  • Agent integration — AI agents can own code too

It's the map of who knows what in your codebase.