Learning center

Required reviewers in a ruleset or CODEOWNERS: which to use?

Use a ruleset's required reviewers rule when a path needs a set number of approvals from specific teams, or exclusions by negation. Keep CODEOWNERS for routing review requests to the people who know the code. The rule lives outside the repository, so a pull request cannot edit it.

What the rule does#

The required reviewers rule is part of a ruleset's "Require a pull request before merging" rule. It lets you "require review or approval from specific teams when a pull request changes certain files or directories. You can specify up to 15 different teams, and for each team you can require a certain number of approvals from team members." Approvals per team range "from 0 (zero) to 10," and zero "means that the team will be added for visibility, but the team does not need to approve the request." For a team member's approval to count, "the team must have write permissions (or higher) for the repository." Required reviewers

Each team gets its own list of file patterns. The rulesets page says the list uses "the same as a standard .gitignore file" format, with negation: "A pattern starting with an exclamation mark (!) is a negation. This will cause paths matching earlier patterns to not require approvals," and "Patterns are matched in order." The REST reference describes the same field as using "fnmatch syntax." Create a repository ruleset The two pages differ, so test any pattern beyond plain ** and * on a real pull request before you depend on it.

The rule entered public preview in November 2025 and became generally available on 17 February 2026, with negation patterns added since the preview. Required review by specific teams changelog, Required reviewer rule changelog It names teams, so it "is not available on user-owned repositories as they do not contain teams."

How it differs from CODEOWNERS#

CODEOWNERS with required code owner reviewRuleset required reviewers
Who can be namedUsers, teams or email addressesTeams only, up to 15 per rule
What satisfies a pathOne approval from any owner on the last matching lineThe set number of approvals from each listed team
Two teams on one pathNot expressible; either team's approval sufficesEach team has its own entry and count
ExclusionsA later line with no owners; ! does not work! negation in the pattern list
Where it is definedA file on the base branch, changed by pull requestRuleset settings, changed by people who can edit rules
ScopeOne branch of one repositoryA repository, or many through organization or enterprise rulesets
Requests review without requiring itYes, this is its default behaviorYes, with zero required approvals

The documentation for the first column is on About code owners. GitHub's changelog describes the split directly: "While CODEOWNERS defines ownership, this rule focuses on policy enforcement," and "The required reviewer rule augments CODEOWNERS files but doesn't replace them. CODEOWNERS files remain the best way to manage ownership, support individuals as reviewers, and request reviews even when not required."

The "where it is defined" row is the one that changes what a pull request can do. A CODEOWNERS file is code: a pull request can propose removing a team, and the change takes effect once it merges, which is why the file needs its own owner. A ruleset is changed by repository administrators or roles with the "edit repository rules" permission, outside any pull request.

A fictional policy written both ways#

Suppose the fictional acme/payments-api repository wants two rules, taken from the examples in GitHub's changelog: *.sql changes need a review from the data platform team, and authentication code needs two reviews from the security team. The security team does not want to review Markdown in the authentication directory.

CODEOWNERS can route the requests:

*                    @acme/payments
**/*.sql             @acme/data-platform
/services/auth/      @acme/security

With Require review from Code Owners on, this gets one approval from @acme/security on authentication changes, not two. A .sql file inside services/auth/ matches the auth line last, so the data platform team is not requested for it. There is no way to exclude services/auth/**/*.md except an override line per file pattern, and ! does not work in CODEOWNERS.

The ruleset version, as the REST API accepts it for POST /repos/acme/payments-api/rulesets:

{
  "name": "payments review policy",
  "target": "branch",
  "enforcement": "active",
  "conditions": { "ref_name": { "include": ["~DEFAULT_BRANCH"], "exclude": [] } },
  "rules": [
    {
      "type": "pull_request",
      "parameters": {
        "required_approving_review_count": 1,
        "dismiss_stale_reviews_on_push": true,
        "require_code_owner_review": false,
        "require_last_push_approval": false,
        "required_review_thread_resolution": false,
        "required_reviewers": [
          {
            "reviewer": { "id": 3333333, "type": "Team" },
            "minimum_approvals": 2,
            "file_patterns": ["services/auth/**", "!services/auth/**/*.md"]
          },
          {
            "reviewer": { "id": 4444444, "type": "Team" },
            "minimum_approvals": 1,
            "file_patterns": ["**/*.sql"]
          }
        ]
      }
    }
  ]
}

Here the two entries are independent. A .sql file under services/auth/ needs two security approvals and one data platform approval, and a README change in the auth directory needs neither. The CODEOWNERS file stays in place for review requests and for the ownership tooltip, with require_code_owner_review off so the two policies do not double up. If you leave both on, "all applicable rules are enforced," as with any layered rules. About rulesets

What neither catches#

Both mechanisms count approvals from people with write access. Neither shows that the approver read the diff, and neither can tell an authentication change that matters from one that renames a variable. A path pattern also misses risky changes that live elsewhere: an authentication flag flipped in a shared configuration file is outside services/auth/**.

The cost#

Two required security approvals on every authentication change is a standing queue for that team. Zero-approval entries are a cheaper first step: the team is added to matching pull requests and sees the traffic before you decide what to require. Organization and enterprise rulesets reach many repositories at once, so a broad pattern there can block merges across the organization. Rulesets have an Evaluate status for trying rules first, but the REST reference notes "evaluate is only available with GitHub Enterprise." Create a repository ruleset

Which to use#

Use CODEOWNERS when one owner's approval per path is enough, when owners include individuals, or when you only want review requests. Use the ruleset rule when a path needs a count above one from a specific team, approval from two teams, an exclusion inside a directory, or the same policy across repositories, as the guide to multiple owners shows. Keep the patterns narrow, start sensitive teams at zero required approvals, and raise the count once you have seen what the pattern catches. Several rulesets can apply to one branch, so check how a new one layers with existing branch protection.

One month of free code review.

New organizations get one calendar month of hosted code review for private and public GitHub repositories. No card or cloud connection required. Eligibility and fair-use terms.

Start free with GitHub

Related reading