Worktree-isolated subagents can start from an older trunk commit
PitfallVerified 2 Oct 2026Holds anywhere
Pitfall. The symptom, what causes it, and the fix that was run and seen to work.
Symptom#
A Claude Code subagent started with worktree isolation can begin from an older commit than the current trunk. Parallel subagents then invent clashing versions of a shared module, and files that both sides touched (such as main.rs) conflict at merge time.
Cause#
The worktree is created from whatever commit was current when the subagent launched, not from the newest trunk.
Fix#
When several subagents run in parallel, commit the shared piece they all need (a common module or file format) on trunk before launching them, so they do not invent clashing versions. When merging, bring the worktree diff over with a 3-way apply and fix conflicts by hand.
Evidence#
Seen with parallel Claude Code subagents on one repository; the shared module diverged until trunk got it first.
Also found by searching
- subagent started from an older commit than trunk
- parallel worktree agents invent clashing versions of a shared module
- bring worktree diff over with 3-way apply
- files that both sides touched conflict after merging agent worktrees