# Branch protection rules for pull requests written by agents

Canonical: [Branch protection rules for pull requests written by agents](https://contextingo.com/blog/branch-protection-for-agent-pull-requests)

Locale: en

Purpose: Require pull requests, passing checks and a human approval on the main branch. The settings to turn on, and what each one prevents.

Content updated: 2026-10-05

Source revision: content.ts 2026-10-05

Maintenance owner: the Contextingo site owner

[Topic map](https://contextingo.com/llm/topics/blog.md) · [Complete scoped map](https://contextingo.com/sitemap.md)

Branch protection is a setting on the repository host that decides what must be true before a change reaches a branch. It is the technical backstop for the rule that nothing unchecked is done.

## Settings worth turning on for main

- **Require a pull request** before merging, so no one pushes straight to main.
- **Require status checks to pass,** and list the checks by name: tests, lint, typecheck.
- **Require review from a person,** with at least one approval.
- **Dismiss stale approvals** when new commits are pushed.
- **Require branches to be up to date** so checks ran on what will be merged.
- **Block force pushes and deletion** of the branch.
- **Apply the rules to administrators,** so they are not skipped under pressure.

## Why it matters with agents

An agent with a token that can push to main can bypass review by accident. A protected branch makes the safe path the only path, whatever the agent was told.

## Use a limited token

Give the agent’s credentials only the rights it needs, normally to push to its own branch and open a pull request.

## Together with Contextingo

Contextingo fetches the CI results for the commit itself, and a maintainer accepts the work. Branch protection adds the same rule on the repository side. Related: [least privilege for coding agents](/blog/least-privilege-coding-agents).

## Questions

### Does branch protection slow the team down?

A little. It prevents the failures that cost more time.

### Which checks should be required?

The ones that would block a release: tests, lint and typecheck at least.
