| English | 中文 |
When developing with multiple agents in parallel, the core is isolating tasks, clarifying ownership, and finally having humans perform integration.
ai/task-parser-refactor # one clear task
ai/experiment-parser-a # approach A to the same problem
ai/experiment-parser-b # approach B to the same problem
ai/review-parser-refactor # cleanup branch prepared for review
Before merging experimental branches, reorganize them into normal business branches:
feat/parser-error-handling
fix/parser-empty-input
Two agents each produced a solution. First check what each branch changed relative to the main line:
git log --oneline main..ai/experiment-parser-a
git diff main...ai/experiment-parser-a # three dots: only the branch's own changes
git diff main...ai/experiment-parser-b
Then compare the two solutions directly:
git diff ai/experiment-parser-a..ai/experiment-parser-b
git range-diff main ai/experiment-parser-a ai/experiment-parser-b
git range-diff aligns the two branches commit by commit, which works well when the two solutions have similar structure.
Do not decide on diffs alone. Run the same test commands on both branches and record the results in the task notes or PR description as the basis for the decision.
When solution A wins as a whole, turn it into a business branch:
git switch -c feat/parser-error-handling ai/experiment-parser-a
git rebase main
When you only need part of solution B, pick by commit:
git cherry-pick <commit-sha>
Or pick by file:
git restore --source ai/experiment-parser-b -- src/parser/recover.ts
git add src/parser/recover.ts
git commit
Prevention first: cut task boundaries so agent scopes do not overlap, and let only one task touch files such as route tables, dependency manifests, and shared configuration.
When a collision still happens, handle it in order:
git rebase main.# Tag first if you want to preserve the state for later reference
git tag archive/ai-experiment-parser-b ai/experiment-parser-b
# Delete the local branch and its worktree
git branch -D ai/experiment-parser-b
git worktree remove ../wt-parser-b
# If it was pushed, delete the remote branch as well
git push origin --delete ai/experiment-parser-b
When closing the draft PR of a losing branch, state why it lost, so similar future tasks have a record to consult.
ai/ branches.