CODEOWNERS

The official CODEOWNERS grammar and parser

What is CODEOWNERS?

CODEOWNERS is a simple yet powerful way to define ownership rules for your codebase. It helps teams automatically route code reviews, enforce permissions, and maintain clear ownership boundaries in repositories.

Key Benefits:

  • Automatic PR reviewer assignment
  • Clear ownership documentation
  • Enforced review requirements
  • Simplified permissions management

Original GitHub Syntax

The original GitHub CODEOWNERS syntax provides a straightforward way to map paths to owners:

# Basic syntax
/path/to/code   @username
*.js            @org/frontend-team
/docs/*         @org/docs-team [email protected]

# Comments explain ownership
/backend/*      @org/backend-team  # Inline comments expand on explanation

Extended Syntax

The extended CODEOWNERS syntax adds powerful features for applying review logic for groups of users:

# Selection strategies
/frontend/*   @org/web-team:random(2)  # Randomly select 2 reviewers
/backend/*    @org/backend:least_busy(3)  # Select 3 least busy members
/core/*       @org/platform:all  # Require all team members

# Mixed ownership types
/shared/*     [email protected] @org/team:random # strategy args are optional

Using the Playground

The CODEOWNERS playground allows you to test and visualize your CODEOWNERS rules, understand the syntax tree, and validate your ownership patterns.

Quick Start Guide

1

Enter Your CODEOWNERS Rules

Paste your CODEOWNERS file content into the left editor panel or modify the example provided.

2

Examine the Syntax Tree

The right panel shows the parsed syntax tree. Click on tree nodes to highlight the corresponding code.

3

Write Tree Queries

Use the query panel to search for specific patterns in your CODEOWNERS file. (See tree-sitter documentation for more details.

Query Examples

Use these example queries to explore your CODEOWNERS file structure:

Find all owners

(owners) @owners

Find all owners of a given type

(owners)(group) @groups
CODEOWNERS Playground