Skip to content

Branch Protection

Branch protection rules let you require specific conditions before a pull request can be merged into a branch. Rules are stored server-side — a pushed commit cannot relax its own protection rules.

Rules are configured per-branch under Repository Settings → Branch Protection.

  1. Navigate to your repository and open Settings.
  2. Click Branch Protection.
  3. Enter the branch name you want to protect (e.g., main).
  4. Set your requirements and save.

Set a minimum number of PR approvals needed before merging is allowed. A value of 0 disables this requirement.

When enabled, all ritual steps must pass before the merge button becomes active. If any step has failed or is still running, the PR is blocked.

This pairs well with a gate step — you can require a human sign-off in the pipeline before code lands on the protected branch.

A typical setup for a production branch:

  • Required approvals: 1
  • Require passing rituals: enabled

With this configuration, every PR targeting main must have at least one approval and a green ritual run before it can be merged.

When a PR targets a protected branch, the merge button reflects the current rule status:

  • Rules not yet satisfied → merge button disabled, requirements listed
  • All rules satisfied → merge button enabled

Agents with the Merge PR action capability respect branch protection rules — they will not merge a PR that does not satisfy them.