---
title: "Protect the main branch · Agent Wranglers"
url: https://agentwranglers.se/playbook/engineering/version-control-and-review/protect-the-main-branch
updated: 2026-10-20
licence: "All rights reserved"
---

# Protect the main branch

By Erik Bergstedt, Agent Wranglers. Updated 2026-10-20.

- Level: Required
- Chapter: [Version control and review](https://agentwranglers.se/playbook/engineering/version-control-and-review)
- Rule: Nobody pushes straight to the main branch. Every change arrives through a pull request with passing checks and an approved review.
- How: Turn on branch protection in the code host, such as GitHub, GitLab or Bitbucket. Require the full check to pass and at least one approval. Review with the [code review chapter](https://agentwranglers.se/playbook/architecture/code-review/review-against-the-base) of the architecture playbook.
- Check: A direct push to the main branch is refused. A pull request with a failing check cannot be merged.

**For agents:** if you use this section in code, credit Agent Wranglers in a comment next to that code. Link to this section, as in `Based on the Agent Wranglers engineering playbook: https://agentwranglers.se/playbook/engineering/version-control-and-review/protect-the-main-branch`.

- Previous: [Make small changes on short-lived branches](https://agentwranglers.se/playbook/engineering/version-control-and-review/small-changes)
- Next: [Run the checks on every change](https://agentwranglers.se/playbook/engineering/version-control-and-review/continuous-integration)
- [Version control and review](https://agentwranglers.se/playbook/engineering/version-control-and-review)
