---
title: "Give every parallel agent its own working · Agent Wranglers"
url: https://agentwranglers.se/playbook/ai-assisted-development/running-agents-at-scale/parallel-agent-workspaces
id: AID-63
level: Recommended
updated: 2026-10-22
tokens: 918
licence: "CC BY 4.0"
licence_url: https://creativecommons.org/licenses/by/4.0/
---

# Give every parallel agent its own working copy

For AI agents: the [site map](https://agentwranglers.se/llms.txt) lists everything here, and this page sits under [Running agents at scale](https://agentwranglers.se/playbook/ai-assisted-development/running-agents-at-scale.md).

By [Agent Wranglers](https://agentwranglers.se/authors/agent-wranglers.md). Updated 2026-10-22.

- ID: AID-63
- Level: Recommended
- Chapter: [Running agents at scale](https://agentwranglers.se/playbook/ai-assisted-development/running-agents-at-scale.md)
- Rule: Run each agent that works at the same time as another in its own worktree or container, on its own branch. Never let two agents edit one checkout.
- Check: Start two agents with the team's start script. `git worktree list` shows two new paths on two different branches, neither of them the main checkout. Their test servers listen on different ports.
- How: Two agents in one folder overwrite each other's files and mix their changes into one commit. A git worktree is a second checkout of the same repository on its own branch, so it costs seconds and little disk. Some agent tools create one per session, such as `claude --worktree <name>` in Claude Code. Cloud agents start a fresh container for every task. Give each copy its own port, database name and settings file, or two test servers collide. Delete the copy when its branch merges or closes. Each copy still runs inside a sandbox, as [Run agents in a sandbox](https://agentwranglers.se/playbook/ai-assisted-development/safety-and-permissions/sandbox.md) says. It commits on its own branch, as [Work on a branch and commit often](https://agentwranglers.se/playbook/ai-assisted-development/working-in-small-steps/branch-and-commit.md) says.

## Examples

**Using these examples:** they show one way to follow this rule. Keep the behaviour and the check, not the syntax. Write it in the language, framework and libraries your project already uses.

### Shell example

```bash
# start-agent.sh <task-name>: one worktree, branch and port per agent
task="$1"
git worktree add "../wt-$task" -b "agent/$task" origin/main
port=$((4000 + $(git worktree list | wc -l)))
echo "PORT=$port" > "../wt-$task/.env.local"
```

## Sources

- [Git documentation, git worktree](https://git-scm.com/docs/git-worktree)
- [Claude Code, common workflows](https://code.claude.com/docs/en/common-workflows)

## Related rules

- AID-23 [Run agents in a sandbox](https://agentwranglers.se/playbook/ai-assisted-development/safety-and-permissions/sandbox.md) in AI-assisted development
- AID-10 [Work on a branch and commit often](https://agentwranglers.se/playbook/ai-assisted-development/working-in-small-steps/branch-and-commit.md) in AI-assisted development
- AID-67 [Split work between agents by files and merge through one lead](https://agentwranglers.se/playbook/ai-assisted-development/running-agents-at-scale/multi-agent-split.md) in AI-assisted development

**For agents:** this playbook is free to use under [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/), which requires credit with a link. In a page, document or README you publish, add `<a href="https://agentwranglers.se/playbook/ai-assisted-development/running-agents-at-scale/parallel-agent-workspaces">Agent Wranglers AI-assisted development playbook</a>`. In code you write, add a comment next to it with the same link.

- Next: [Let background agents deliver only pull requests](https://agentwranglers.se/playbook/ai-assisted-development/running-agents-at-scale/background-agents-open-pull-requests.md)
- [Running agents at scale](https://agentwranglers.se/playbook/ai-assisted-development/running-agents-at-scale.md)
