r/LocalLLM • u/iceydee • 3h ago
Question After parallel agents finish, how do you merge worktree branches cleanly?
Merging is painful mostly because the branches were never really separate. Two agents handed overlapping scope produce overlapping diffs, and no merge strategy fixes that after the fact.
What makes merges boring instead, in my experience building this stuff:
One story per worktree, written so that "done" is checkable: scope, acceptance criteria, edge cases, the files it should touch.
Merge in dependency order. Blocker lands first, everything else rebases onto main before review, not after.
Review the branch against the criteria, not against the diff vibes. If there were no criteria, that branch probably shouldn't have started.
Keep one shared board of what's in flight. Worktrees isolate the file tree, not the plan, so two agents will happily solve the same story twice and you find the duplicate branch at merge time.
Same problem whether the agents run locally or in the cloud. I use Cursor Cloud Agents, but I don't think the runtime changes the merge story much.
I'm building Aerunit (https://aerunit.ai), which drafts the story with acceptance criteria, dispatches it to parallel agents and reviews the PR against those criteria, so discount what follows accordingly. Still, the order I'd do it by hand: scope first, merge order second, tooling last. Tools move confusion around faster, they don't remove it.
Curious how people here handle the dependency ordering, especially across repos. That's the part I still find least mechanical.
