Cheatsheet: Multi-agent integration patterns
Voice anchor
Section titled “Voice anchor”Git stores snapshots. Every other command is just navigating those snapshots.
Pattern comparison table
Section titled “Pattern comparison table”| Pattern | Remote setup | Best for | Tradeoff |
|---|---|---|---|
| Shared origin | One remote, all agents push to it | Default. Team workflows. | Agent branches visible on shared remote (clutter, weak isolation) |
| Per-agent fork | Each agent on its own remote | Untrusted agents, external contributors | More setup; slower iteration |
| Shared worktrees | No remote push until final | Fast solo iteration | No backup, no in-flight visibility |
Shared-origin pattern commands
Section titled “Shared-origin pattern commands”# Setup (from main repo)git checkout main && git pullgit worktree add -b agent-N/feature ../agent-N main # repeat per agent
# Each agent pushes when readycd ../agent-Ngit push -u origin agent-N/feature
# Lead integratescd ~/projects/myrepogit checkout -b integration/<name> maingit merge agent-1/featuregit merge agent-2/feature# ... etc; run tests after each merge
# Final pushgit checkout maingit merge integration/<name>git push origin main
# Cleanupgit worktree remove ../agent-1git branch -D agent-1/feature # localgit push origin --delete agent-1/feature # remotePer-agent fork pattern commands
Section titled “Per-agent fork pattern commands”# Each agent works in its worktree, pushes to its OWN remotecd ../agent-Ngit push -u origin agent-N/feature
# Lead adds each fork as named remotecd ~/projects/myrepogit fetch agent-1
git checkout -b integration/<name> maingit merge agent-1/agent-1/feature# (the remote name + branch name; can be confusing, use --no-ff to keep merge commits)Shared-worktrees pattern commands
Section titled “Shared-worktrees pattern commands”# Setupcd ~/projects/myrepogit checkout main && git pullgit worktree add -b agent-N/feature ../agent-N main
# Agents work and commit LOCALLY (no push)
# Lead integrates LOCALLYgit checkout -b integration/<name> maingit merge agent-1/feature# ... etc
# Only at the end:git checkout maingit merge integration/<name>git push origin mainSemantic-conflict checklist (for the lead’s diff review)
Section titled “Semantic-conflict checklist (for the lead’s diff review)”Before pushing, review git diff main..integration/<name> and look for:
- Renamed functions, classes, fields (does any branch call the OLD name?)
- Duplicate utilities (two agents adding similar functions?)
- Mismatched field names across model and consumers
- Migration ordering (do migrations need a specific sequence?)
- Subtle behavior changes (return type changes, error behavior changes)
- Shared constants / config changed by multiple agents
- Implicit assumptions (one agent relies on behavior another agent removed)
If any item is uncertain, dig in before pushing.
Pattern selection drill, model answers
Section titled “Pattern selection drill, model answers”- Solo dev, 4 agents, 2-hour sprint: shared worktrees. Fast iteration, lead controls everything, no need for remote visibility.
- 10-person team, one fleet at a time, want peer review: shared origin. Agent branches need to be on the shared remote so other engineers can review them.
- External AI services provider, untrusted code: per-agent fork. Quarantines the work; the team’s main remote is protected.
- Startup founder runs nightly fleets, others inspect in the morning: shared origin. Agent branches need to be on the shared remote for morning review.
- OSS maintainer accepting AI-assisted PRs: per-agent fork. Matches the existing OSS workflow.
Semantic-conflict spotting drill, model answers
Section titled “Semantic-conflict spotting drill, model answers”- Rename conflict. Agent A renamed; Agent B calls the old name. Catch via integration tests OR by spotting the rename in the diff review.
- Mismatched field names. Agent A’s model field doesn’t match Agent B’s endpoint field. Catch via integration tests that exercise the endpoint OR by reading the diff for naming consistency.
- Migration ordering. Each migration is fine alone; together, order matters. Catch via the lead-stage build that runs all migrations in order. Or by an explicit “list all migrations being added” check in the diff review.
- Duplicate utility. Two functions doing the same thing. Catch via diff review or via lint rules that flag duplicate logic.
- Implicit nullness. Return type changed; consumer doesn’t handle the new None case. Catch via type checking (mypy, TypeScript), via integration tests that exercise the None branch, or via diff review.
Mock fleet integration drill, model walk-through
Section titled “Mock fleet integration drill, model walk-through”After the deliberate semantic conflict (renaming add to sum_two on one branch), tests will fail. The lead’s job:
- Read the test output. Identify the missing function name.
git diff main..integrationto see what each agent contributed.- Spot the naming mismatch.
- Fix: pick one name as canonical. Update the calls (or rename the definition).
- Commit the integration fix.
- Tests pass.
This is the canonical semantic-conflict-and-recovery pattern. Most multi-agent integrations include at least one of these.
Common mistakes and fixes
Section titled “Common mistakes and fixes”| Mistake | Fix |
|---|---|
| No build gate at integration | Add the lead-stage build. Non-negotiable. |
| Loose agent scope (lots of overlap) | Refine scope upstream; prefer non-overlapping agent assignments |
| Skipping the diff review before push | Add it to the workflow. It catches what tests miss. |
| Hand-repairing confused agents instead of re-running | When in doubt, abort and re-run with a refined prompt |
| No process documentation | Write down the workflow. Onboard new leads to it. |
| Treating all 3 patterns as interchangeable | Use the decision tree. Each has clear best-fit situations. |
What’s in L15
Section titled “What’s in L15”AI-authored commits and PRs. Co-authorship conventions (“Co-Authored-By: Claude Opus 4.7”). The “Generated with Claude Code” trailer line. What human review changes when an AI typed the code. Release notes treatment. How “human-authored” vs “AI-assisted” is communicated.