Background and parallel agents
Module 08 had you working with one agent in one session, watching it work. Every major coding agent can now also work in the background: you hand over a task, close your laptop, and come back to a pull request. Many engineers run several at once. This module shows how to do that well with any agent, which tasks to hand over, how to write the brief, and why your review, not the number of agents, sets the pace.
- Sam People keep saying they run five agents at once. How does that even work?
- Priya Every major coding agent can now work in the background. You hand over a task, close your laptop, and come back to a pull request. Run several on independent tasks and you have parallel agents. The trick is doing it without drowning in half-finished work.
- Priya Picture a site manager renovating a house. Each crew gets a written work order for one room: what to do, what not to touch, how it'll be inspected. The crews work at the same time in separate rooms. The manager answers questions as they come up and inspects every room before signing off.
- Sam So the work order is the prompt?
- Priya It's the task brief: goal, context, constraints, and how to know it's done. The separate room is a git worktree or a cloud sandbox, a copy of the code on its own branch. And the inspection is your review of the pull request.
- Sam Walk me through it.
- Priya You write three briefs: add missing tests, upgrade a library, fix the docs. Three agents start, each in its own copy of the code, so their edits can't collide. One hits a decision the brief didn't cover and asks; you answer when you have a minute. They open pull requests, the checks run, one fails and the agent fixes it. Then three green pull requests land in your review queue.
- Sam And locally, without a cloud?
- Priya Git worktrees. One command gives you another folder for the same repository on a new branch. One worktree per task, any agent in each. It's plain git, so it works with every tool.
- Sam What makes a good brief?
- Priya A background agent can't ask you every few minutes, so the brief does the job a conversation would. Say the goal, link the context, list what not to touch, define done in a way the agent can check, and say what to do when unsure.
- Priya Your turn. "Fix the date stuff in the orders page." Good brief?
- Priya No. The agent has to guess which bug and when it's done. In the example on the page, it changed the date format in fourteen files and updated the failing tests to match. Plausible, large, and wrong.
- Sam What can I try?
- Priya A sorter: hand each task to a background agent now, write a brief first, or keep it interactive. And a calculator: set how many agents, how long they take, and how long you need to review a pull request. It shows where your review becomes the bottleneck.
- Sam Which tasks should I hand over?
- Priya Work that's well defined, easy to check, and doesn't overlap: tests, bugs with a reproduction, dependency upgrades, docs, fixing failing checks. Keep design decisions, investigations and security work interactive.
- Sam Best practices?
- Priya One task, one branch, one pull request. Independent tasks, so agents don't conflict. Prepare the environment so the agent can run its own tests; Cursor calls that the most important step. Sandbox by default, with no production secrets; Thoughtworks calls sandboxing a sensible default. Time-box every task. And size your parallelism to your review time.
- Sam Any downsides?
- Priya Cost and rate limits multiply. Review becomes the bottleneck, and rushed review is how bad changes get in. And Thoughtworks puts coding agent swarms in Caution. Start with two or three well-briefed tasks, and count merged pull requests, not running agents.
- Sam What does each tool offer?
- Priya Copilot's cloud agent takes an issue and returns one pull request per task. Claude Code has cloud sessions, plus a worktree flag for local parallel sessions. Codex cloud runs each task in its own workspace, even while your computer sleeps. Cursor runs as many cloud agents as you like, started from Slack, GitHub or the web. Antigravity runs background subagents with an agent manager panel. And worktrees with the headless command work locally for all of them.
- Sam The memory hook?
- Priya Work orders, separate rooms, one inspector. And the inspector is you.
- Sam Common mistakes?
- Priya One-line briefs. Overlapping tasks. No working environment. More agents than you can review. Secrets in the sandbox. No time limits. And forgetting to clean up old worktrees and branches.
- Sam And the lab?
- Priya Pick three small, independent tasks and write a brief for each. Run them in parallel in worktrees, run one in the cloud, and review all the pull requests while timing yourself. Then use your real numbers in the calculator to find how many agents are worth running for you.
1. The idea
A background agent works on a task without you watching each step. You describe the task, it works in its own copy of the code, and it hands back a pull request. Run several on independent tasks and you have parallel agents. Words you'll need:
| Term | Meaning |
|---|---|
| Foreground agent | The interactive session from Module 08: you watch, steer and approve as it goes. |
| Git worktree | A second (third, fourth…) working folder for the same repository, each on its own branch. Agents in different worktrees can't overwrite each other's files. |
| Cloud agent | An agent that runs on a remote machine (a VM or sandbox) prepared with your repository and tools. It keeps going when your laptop sleeps. |
| Task brief | The written work order: goal, context, constraints, and how to know it's done. |
| Hand-off | How work comes back: a branch and a pull request, with its checks, ready for review (Module 13a). |
2. How it works
On your own machine, the tool that keeps parallel agents apart is git worktrees. They're plain git, so they work with every agent:
A background agent can't ask you to clarify every few minutes, so the brief does the work a conversation would. Compare a vague brief with a good one:
3. Try it yourself
Hand it over?
For each task, decide: hand it to a background agent now, write a brief (or spec) first, or keep it in an interactive session where you can steer.
How many agents?
More agents produce more pull requests, but somebody has to review them. Move the sliders and watch where the bottleneck moves.
4. Why it matters at work
Background agents are good at work that is well defined, easy to verify and doesn't overlap with other work. They are poor at work where the hard part is deciding what to do.
| Good to hand over | Keep interactive (or spec it first) |
|---|---|
| Tests for existing code; a bug with a reproduction; dependency upgrades; docs; a mechanical change across many files; fixing CI failures on a PR | New design decisions; vague features; changes that touch many teams' code; security-sensitive work; anything you can't easily check |
Best practices
| Practice | Why |
|---|---|
| One task, one branch, one pull request | Small, reviewable results; Copilot's cloud agent enforces exactly this. |
| Write the brief like a work order | Goal, links to context, constraints, "done when", and how to verify. A spec (Module 08a) for anything bigger. |
| Pick independent tasks | Two agents editing the same files means merge conflicts and wasted work. |
| Prepare the environment | Dependencies, test commands and services ready, so the agent can run its own checks (Module 12a). |
| Sandbox by default | Thoughtworks' Radar (Trial, April 2026): isolated file system, controlled network, bounded resources, "a sensible default rather than an optional enhancement". No production secrets. |
| Match parallelism to review capacity | Unreviewed pull requests are inventory, not progress. Start with two or three agents. |
| Time-box and budget | Limits on minutes, turns and cost per task; parallel sessions share your plan's rate limits. |
| Same checks as everyone | Every agent PR goes through CI and review (Module 13a), with a named owner. |
The portable recipe
On your machine: one worktree per task, any agent in each. AGENT_CMD is your tool's headless command (Module 13).
#!/usr/bin/env bash
# run-tasks.sh: one worktree and one background agent per task brief in tasks/*.md
AGENT_CMD="${AGENT_CMD:-claude -p}" # or "codex exec", "copilot -p", "agent -p", "agy -p"
for brief in tasks/*.md; do
name=$(basename "$brief" .md)
git worktree add "../wt-$name" -b "agent/$name" # a separate folder and branch
( cd "../wt-$name" &&
$AGENT_CMD "$(cat "$OLDPWD/$brief") Run ./scripts/check before finishing. Commit your work." \
> "agent.log" 2>&1 &&
git push -u origin "agent/$name" &&
gh pr create --draft --fill ) & # each runs in the background
done
wait # then review the draft PRs; remove a worktree with: git worktree remove ../wt-NAME
# tasks/upgrade-date-lib.md: a brief that works without a conversation
Goal: upgrade date-fns from 2.x to 3.x.
Context: docs/dependencies.md; the breaking changes list at the date-fns changelog.
Constraints: no behaviour changes; don't touch src/billing/ (owned by another team).
Done when: ./scripts/check passes and no date-fns 2.x imports remain.
If unsure: stop and write your question at the top of the PR description.
In CI instead, the same brief can start a job (for example a GitHub Actions workflow triggered by an issue label) that runs AGENT_CMD on a fresh runner and opens a draft PR. That is roughly what the built-in cloud agents do for you, with a prepared environment.
5. In your five tools
Every tool can run agents away from your screen; they differ in where. Git worktrees plus the headless command work locally with all of them. Checked 31 October 2026.
| Tool | Background or cloud agents | Parallel on your machine |
|---|---|---|
| GitHub Copilot | Cloud agent: assign work from an issue, a pull request, the Copilot panel or a repository's Agents tab. Runs in GitHub Actions (59-minute limit per session) or a cloud sandbox; one branch and one pull request per task. "Watch and fix" works on failed checks and merge conflicts | copilot -p in separate worktrees |
| Claude Code | Cloud sessions from the browser, the app or claude --cloud "task"; each runs in its own VM and keeps going when your laptop is closed. --teleport pulls one back to your terminal; Auto-fix watches a PR for failed checks and review comments | claude --worktree NAME starts an isolated session in its own worktree |
| Codex | Codex cloud: tasks start from a published environment; "each task has its own workspace and can keep working while your computer is asleep". Review the diff, ask for changes, then open a PR | codex exec in separate worktrees |
| Cursor | Cloud Agents in isolated VMs, as many in parallel as you like; start them from the desktop app, the web, Slack, Linear, a GitHub comment (@cursor) or the API. Environment in .cursor/environment.json or a Dockerfile; can open PRs across several repositories | agent -p in separate worktrees |
| Antigravity CLI | Background subagents for long builds, searches and multi-file edits; the /agents panel shows each one's state, /tasks tracks background commands. In the app, a subagent can get its own git worktree | agy -p in separate worktrees |
6. Remember it
How this hook works: what “Work orders, separate rooms, one inspector” means
What the slogan means, phrase by phrase
- “Work orders”
- The task brief: goal, context, constraints, done-when. It replaces the conversation you won't be having.
- “separate rooms”
- A worktree, branch or sandbox per agent, and tasks that don't overlap.
- “one inspector”
- Your review. It caps how many agents are worth running.
Why this picture fits: renovation crews work in parallel only because each has its own room and a written job; and a building isn't finished until it passes inspection.
The story → the concept
| Renovation | Background agents |
|---|---|
| Work order | Task brief or spec |
| A crew | One agent |
| Its own room | A git worktree or cloud sandbox, on its own branch |
| Tools and materials on site | The prepared environment |
| Room ready for inspection | A pull request with green checks |
| The inspector | You (plus the checks in Module 13a) |
The trap it saves you from
Hiring more crews than you can inspect. Ten agents and one hour of review a day means a growing pile of unreviewed pull requests, and a temptation to approve them without reading.
7. Common mistakes
8. Hands-on lab (roadmap week 8)
- Pick three small, independent tasks from your backlog: for example a test gap, a dependency bump and a docs fix.
- Write a brief for each with goal, context, constraints, done-when and "if unsure".
- Run them in parallel locally: one git worktree each, tool A in all three (or the script above).
- Run one in the cloud with your tool's cloud agent, and compare the experience.
- Review all four PRs and time yourself. Which brief produced the best result, and why?
- Find your number: using your real review times in the calculator above, how many agents are worth running for you?
9. Self-check quiz
How do you stop two local agents from overwriting each other's files?
Which task suits a background agent best?
You go from 3 to 10 parallel agents, and merged PRs per day barely change. The most likely limit?
Which line makes a brief checkable?
A cloud agent's PRs often break tests it says it ran. First thing to check?
What's the current advice on sandboxing background agents?
10. Go deeper
| Resource | Time | Why |
|---|---|---|
| About Copilot cloud agent (GitHub Docs) | 10 min | Where it runs, its limits, and how to assign work. |
| Use Claude Code in the cloud and parallel sessions with worktrees (Claude Code docs) | 20 min | Cloud sessions, teleport, Auto-fix, and --worktree. |
| Codex cloud (OpenAI docs) | 5 min | Environments and parallel tasks. |
| Cloud Agents (Cursor docs) | 10 min | Environment setup, network controls and the many ways to start an agent. |
| Subagents (Antigravity docs) | 10 min | Background subagents and the Agent Manager. |
| Sandboxed execution for coding agents (Thoughtworks Radar, April 2026) | 3 min | Why sandboxing is the default, and the options. |
| git worktree (Git documentation) | 10 min | The plain-git tool behind local parallel agents. |