Engineering
Parallel Agent Worktree Sweep
Run more agents, but keep their blast radiuses separate.
Use when
You have multiple independent coding tasks and the human bottleneck is orchestration, not implementation speed.
Cadence
When several independent repo improvements can run at once
Verification
Each agent branch has isolated scope, passing checks, a summary, and no conflicting files before integration review.
Structured loop spec
| Field | Value |
|---|---|
| Name | Parallel Agent Worktree Sweep |
| Category | Engineering |
| Trigger | When several independent repo improvements can run at once |
| Objective | Run more agents, but keep their blast radiuses separate. |
| Allowed inputs | Relevant files, source notes, logs, tests, screenshots, metrics, or task state for this loop |
| Allowed actions | Split the work into independent tasks with non-overlapping files or explicit conflict boundaries.; Create separate branches or worktrees and give each agent its own goal, commands, budget, and done contract.; Require each agent to return diff summary, verification output, known risks, and next-step recommendation.; Review branches in priority order, checking for overlapping files, duplicated abstractions, and integration risks.; Merge only the branches with passing evidence and clear product value; park or discard the rest. |
| Verification | Each agent branch has isolated scope, passing checks, a summary, and no conflicting files before integration review. |
| Stop condition | Stop when the verifier passes, the budget is exhausted, no progress is made, a blocker appears, or approval is required. |
| Budget | Set a time, turn, token, retry, file, or dollar cap before running the loop. |
| Approval boundary | Human approval required before publishing, sending, deleting, spending, changing accounts, touching production, or making reputational/legal/financial commitments. |
| Safe output | Pull request, patch, report, or evidence log |
| Works with | Claude Code, OpenAI Codex, Cursor, Gemini CLI, any tool-using coding agent |
Steps
- Split the work into independent tasks with non-overlapping files or explicit conflict boundaries.
- Create separate branches or worktrees and give each agent its own goal, commands, budget, and done contract.
- Require each agent to return diff summary, verification output, known risks, and next-step recommendation.
- Review branches in priority order, checking for overlapping files, duplicated abstractions, and integration risks.
- Merge only the branches with passing evidence and clear product value; park or discard the rest.
Prompt
Run the Parallel Agent Worktree Sweep loop. Split the repo work into independent tasks with non-overlapping scope, then create one branch or worktree per agent. Give each agent a goal, commands, budget, and done contract. Require diff summary, verification output, risks, and recommendation. Review branches for conflicts, duplicated abstractions, and integration risk before merging anything. Park or discard weak branches instead of forcing a messy merge.Run in Claude Code
Paste this into Claude Code (or any tool-using agent) to run the loop bounded: one change per round, the same verification every round, durable state files, and explicit stop conditions.
Run the "Parallel Agent Worktree Sweep" loop from AI Loop Library (https://ailooplibrary.com/loops/parallel-agent-worktree-sweep/) as a bounded loop.
Goal: Run more agents, but keep their blast radiuses separate.
Rules: one change per round; run the same verification every round (Each agent branch has isolated scope, passing checks, a summary, and no conflicting files before integration review.); append each round to docs/loops/parallel-agent-worktree-sweep/progress.md and update docs/loops/parallel-agent-worktree-sweep/state.json; stop on verifier pass, 8 rounds, 3 consecutive failed verifications, no progress, a blocker, or anything needing human approval (money, production, outbound, deletion). Finish with a proof report: rounds used, changes made, verification output, remaining risk, and the next human decision.