Parallel multi-agent orchestration for complex features
Orchestrates parallel multi-agent development for complex features using git worktree stacks.
/plugin marketplace add bengous/claude-code-plugins/plugin install claude-orchestration@bengous-plugins<complex-task>Dependency: Requires
</principles>git-worktreeplugin installed (/plugin install git-worktree@bengous-pluginsthen/git-worktree:worktree-setup).
<phase_1 title="Understand & Plan">
Goal: Gather context, get architect consensus, and get approval
Initial request: $ARGUMENTS
Before anything else, create a TodoWrite tracking all 3 phases:
- Phase 1: Understand & Plan
- Phase 2: Execute
- Phase 3: Review & Ship
Mark Phase 1 as in_progress. Update status throughout workflow.
Explore the codebase directly using Glob and Grep. Batch file reads when possible - read multiple files in a single tool call for faster context building.
Ask about scope, design preferences, or edge cases only if truly ambiguous. Proceed autonomously when requirements are reasonably clear.
Break into 2-4 independent chunks with minimal file overlap:
Chunk 1: [Name] - [Description]
Files: [list]
Chunk 2: [Name] - [Description]
Files: [list]
Spawn 2-3 architect agents in parallel (single message, parallel execution):
| Agent | Focus | Prompt suffix |
|---|---|---|
| Minimal | Smallest diff, max reuse | "Focus: smallest diff, maximum code reuse, least disruption." |
| Clean | Maintainability | "Focus: maintainability, clear abstractions, long-term health." |
| Pragmatic | Ship-ready | "Focus: practical trade-offs, ship-ready approach." |
Each agent receives: Feature description, codebase findings, chunk breakdown, constraints.
Form consensus: Analyze all proposals → identify common elements → synthesize ONE approach with best ideas from each.
Use prefix: feat/ | fix/ | refactor/ | chore/ based on task type.
git fetch origin && git checkout -b <prefix>/<name> origin/<base-branch>
Present: architecture approach, chunk breakdown, base branch.
CHECKPOINT: "Approve execution? (yes/no)" → Yes: Phase 2 | No: Revise or abort
</phase_1>
<phase_2 title="Execute">
Goal: Implement in parallel using git worktrees
Mark Phase 2 as in_progress. Delegate to subagents - orchestrate, don't implement.
Spawn planning coordinator with: chunks, architecture, base branch, issue number (if any).
Coordinator returns YAML execution plan with stack_id, root/child worktree paths, branches, file assignments, merge order.
Spawn agents in parallel (one per chunk, single message) to implement each chunk:
Each agent receives: worktree path, branch, chunk description, architecture guidance, key files.
Agent instructions: Implement assigned chunk only. Stay in scope. Return: files changed, summary, notes for merge coordinator.
Wait for ALL agents. If blocking errors → STOP, inform user. If successful → proceed.
Spawn merge coordinator with: execution plan (YAML), implementation summaries, stack_id, root/base branches.
Merge coordinator: merges children to root sequentially, resolves conflicts, cleans up worktrees (keeps root branch for PR).
</phase_2>
<phase_3 title="Review & Ship">
Goal: Quality validation and PR creation
Mark Phase 3 as in_progress.
Spawn 1-2 reviewer agents. Focus: simplicity/DRY, bugs, code quality. Return findings by severity (HIGH/MEDIUM/LOW).
gh pr create --head <root-branch> --base <base-branch> \
--title "[type]: [description]" \
--body "## Summary\n[What was built]\n\n## Changes\n[Key changes]\n\n## Test Plan\n[How to verify]"
Mark all todos complete. Present: what was built, key decisions, stack ID, chunks, files modified, PR URL, next steps.
</phase_3>
<important_notes>
Uses git-wt --stack: creates stack, returns JSON with paths/branches. Children merge to root, root PRs to base. Cleanup via git-wt --stack-cleanup.
Pre-commit/pre-push hooks handle linting, type checking, tests automatically.
Subagents are stateless: no TodoWrite access, no follow-up messages, communicate only via final return.
Worktree stacks provide isolation. Agents work in separate directories under <repo>.wt/.
Stop and inform user if: git-wt unavailable, blocking agent errors, unresolvable conflicts, scope creep, HIGH severity findings.
For long orchestrations approaching context limits:
.claude/orc-checkpoint.yaml (phase, step, state)Monitor context usage throughout. Prioritize completing current phase before checkpointing.
</important_notes>