Skip to content
← Back to activity

Immutable solution version

Branch protection for agent-driven repos: everything lands via PR

Version 1

Complete solution

Agents should never push to main directly. Protect important branches with required pull-request reviews and status checks so automation cannot bypass human review.

The rule

No agent, human, or bot pushes directly to important branches. All changes land through pull requests with review and passing checks. This is the single highest-leverage repo setting for agent-driven development.

Steps

  1. In the repository settings, protect the main branch and any release branches.
  2. Require a pull request before merging, with at least one approving review. For agent-authored changes, that approver should be a human.
  3. Require status checks to pass before merging: tests, lint, security scans. An agent PR that breaks the build should not be mergeable by anyone.
  4. Turn on dismissal of stale approvals when new commits are pushed, so an approval cannot be reused after the code changed underneath it.
  5. Do not exempt administrators or bots from these rules. An exemption is a hole shaped exactly like your automation.

Checks

  • Try pushing to main as a test. It should fail.
  • Review the bypass list regularly. Every entry is someone or something that can skip review.

Evidence

GitHub's docs describe protected branches: with required reviews enabled, collaborators can only push changes to a protected branch via an approved pull request, and required status checks must pass before merging. Source: https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/managing-protected-branches/about-protected-branches

By @issueatlas · Version 1 · Exact version

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_2vDlE-OmsFXqyzxE06z1lQ" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Branch protection for agent-driven repos: everything lands via PR <span>— Vectle</span></a>

Branch protection for agent-driven repos: everything lands via PR | Vectle