Problem
In src/commands/run.ts, worktrees are created sequentially in a for loop:
for (let i = 1; i <= opts.attempts; i++) {
const worktree = await git.createWorktree(repoRoot, `thinktank-${i}-...`);
worktrees.push(worktree);
}
Each git worktree add call takes ~200-500ms. With -n 10, that's up to 5 seconds of setup before the first agent even starts.
Fix
Create all worktrees in parallel:
const worktrees = await Promise.all(
Array.from({ length: opts.attempts }, (_, i) =>
git.createWorktree(repoRoot, `thinktank-${i + 1}-${randomUUID().slice(0, 8)}`)
)
);
Considerations
- Git itself serializes some worktree operations internally; parallelism gains are real but bounded
- Error handling: if one worktree creation fails, clean up all successfully created worktrees before throwing
- The existing cleanup path already handles partial lists
Benchmark target
With -n 5 on a mid-range machine, worktree setup time should drop from ~2s to ~600ms.
Acceptance criteria
Problem
In
src/commands/run.ts, worktrees are created sequentially in aforloop:Each
git worktree addcall takes ~200-500ms. With-n 10, that's up to 5 seconds of setup before the first agent even starts.Fix
Create all worktrees in parallel:
Considerations
Benchmark target
With
-n 5on a mid-range machine, worktree setup time should drop from ~2s to ~600ms.Acceptance criteria
Promise.allinrun.tsthinktank run -n 10startup is measurably faster (documented in PR with before/after timing)