Three coding agents can finish three tasks at once. They can also overwrite the same file, reuse one port, or merge against old code. Speed only helps when each agent has a clear place to work and a safe path back to the main branch.
The goal is not “more agents.” The goal is useful work that can merge with less waiting and less repair.
A branch is not enough when several processes use the same folder. One agent may change files while another is testing them. Build output, lock files, caches, and local databases can also collide.
Use one Git worktree per coding agent. A worktree gives each agent its own folder and branch while sharing the same Git history.
git worktree add ../repo-api -b agent/api
git worktree add ../repo-ui -b agent/ui
git worktree add ../repo-tests -b agent/tests
git worktree list
The VibeFlow CLI can create this shape with vibeflow launch --worktree --new-branch --provider codex. Its official README also provides commands to list sessions, inspect worktrees, and check for conflicts.
Isolation stops folder collisions. It does not stop two agents from solving the same ticket or editing the same shared file.
Use an atomic task claim. The first agent that claims a work item owns it until completion, release, or timeout. Record the session, branch, working directory, commit, and last heartbeat.
VibeFlow agent sessions follow this pattern: initialize, poll, claim, execute, commit, and complete. Code-changing personas also use one live session per branch. A second session gets a branch_locked result instead of racing the first one.
| Control | What it prevents | Evidence to keep |
|---|---|---|
| Worktree per agent | Files changing under another process | Worktree path and branch |
| Atomic task claim | Duplicate work | Work item and session ID |
| Branch lock | Two writers on one branch | Lock owner and heartbeat |
| File ownership note | Shared-file surprises | Planned file list |
| Ordered merge queue | Stale merges | Tested commit and merge order |
Ask each agent to list the files it expects to change. Reject or split plans that overlap on high-risk files such as dependency locks, database migrations, generated clients, root configuration, and shared types.
A simple plan might be:
services/api/**. apps/web/**. tests/e2e/**. package-lock.json, migrations, and shared schemas.
File ownership is a planning rule, not a security boundary. Agents still need tests and review.
Worktrees can still collide through services outside Git. Give each workspace its own port range, cache path, temporary directory, database name, and generated-output folder.
export AGENT_SLOT=2
export PORT=$((3000 + AGENT_SLOT))
export TEST_DB="app_test_${AGENT_SLOT}"
export CACHE_DIR=".cache/agent-${AGENT_SLOT}"
npm test
Do not share a writable local database between agents. Do not let two agents regenerate the same checked-in file. If generation is required, assign it to the integrator after upstream branches merge.
Agents should not all merge when they finish. Merge the branch that changes shared contracts first. Rebase or update the remaining branches, then rerun their checks.
Use this order:
The commit that passed should be the commit that ships. If the merge creates a new commit, run the required checks again.
A heartbeat shows that a process is alive. It does not prove useful progress. Set limits for task time, retry count, tool calls, and cost. Release a claim when the heartbeat expires. Let a human terminate a live but stuck session after checking its logs and uncommitted diff.
Before cleanup, save or review uncommitted work. Automatic worktree removal can delete changes that were never committed.
Start with three tasks that touch different areas. Create three worktrees and branches. Claim each task. Review planned files. Run agents with separate ports and caches. Merge the shared contract first. Update the other branches. Run focused and full tests. Then release the exact tested artifact.
VibeFlow coordinates agent roles, work claims, security review, QA, and Git records. Its agent-session controls add branch locks and worktree-aware ownership. Teams can also use Vera as an independent review step before merge.
Parallel work becomes reliable when ownership is visible. Give every agent one task, one workspace, one branch, and one merge path.