---
title: "Work on a branch and commit often · Agent Wranglers"
url: https://agentwranglers.se/playbook/ai-assisted-development/working-in-small-steps/branch-and-commit
updated: 2026-10-20
licence: "All rights reserved"
---

# Work on a branch and commit often

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

- Level: Required
- Chapter: [Working in small steps](https://agentwranglers.se/playbook/ai-assisted-development/working-in-small-steps)
- Rule: Let agents work only on a branch, and commit after each step that passes the checks.
- How: Create a branch per task, or a separate worktree per agent when several run at once. Commit every working step, so a bad step can be undone without losing the good ones. Merge to the main branch only after review. When several agents work at once, give each one its own files or its own worktree. Agents editing the same file overwrite each other's work. A shared build folder breaks the same way, so each agent builds into its own output folder or worktree.
- Check: The main branch has branch protection, and no agent commit lands on it without a reviewed pull request.

**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 ai development playbook: https://agentwranglers.se/playbook/ai-assisted-development/working-in-small-steps/branch-and-commit`.

- Previous: [Keep each change small](https://agentwranglers.se/playbook/ai-assisted-development/working-in-small-steps/small-diffs)
- Next: [Ask for the smallest change that works](https://agentwranglers.se/playbook/ai-assisted-development/working-in-small-steps/smallest-change)
- [Working in small steps](https://agentwranglers.se/playbook/ai-assisted-development/working-in-small-steps)
