All guidesMERGE
Merge Gate·2 min·English
A gate on the merge path before it goes fully automatic
Branch protection, required review and CI checks: the gate you need before letting background agents open a PR on their own.

What you get
Three concrete bolts for a protection gate, before you let an agent run in the background and open a PR without asking
Who it is for
For developers and teams running code agents in the background who want to give them autonomy without risking main.
Why this needs a gate at all
In July 2026, Claude Code changed a default: background agents started with the claude agents command no longer stop to ask before they finish a code task in a worktree. They commit, push, and open a draft PR on their own.
- That saves time, and it also means the only step left between the agent's confidence and your main is the gate you built in advance.
- Without a gate: the agent's 'done' becomes your production incident.
What to set up before you let an agent run in the background
- Who must approve before merging into main.
- Which checks must pass green before merge.
- Which branch is protected and which is not.
- What happens when a check fails, who gets notified.
- Whether a draft PR is enough, or you also need a manual merge block.
The first bolt: branch protection
- Set the main branch as protected in the repo settings.
- Block direct push to the protected branch, from an agent and from you.
- Require the branch to be up to date before merge.
- Prevent deletion of the protected branch.
The second bolt: required review
- Require at least one human reviewer before merge, even when the PR was opened automatically by an agent.
- Don't approve your own agent's PR without reading the diff.
- If several agents work on the same repo, set a fixed reviewer for auditing automated PRs.
The third bolt: CI checks
- Require every check to be green before the merge button can even be clicked.
- Include a focused test, a full build, and lint/typecheck in the required chain.
- If CI fails, the PR stays a draft. Don't override it with a manual check because 'it's probably fine'.
A short prompt for the agent
Copy box
When you finish, commit, push, and open a draft PR as usual.
Do not expect manual approval before this step - it will not come.
The only gate is what I configured on the repository: branch protection,
required reviewers, and CI checks. If those are not set up, say so
explicitly instead of assuming it is safe to proceed further.How to use this now
The agent doesn't ask you anymore before it pushes. The gate you built asks for you.