Orchestration pattern for parallelizable tasks...
Trigger when:
Do NOT trigger for:
āāāā [Agent 1] āāā Result 1 āāā
ā ā
[Task] ā Decompose āā¼āāā [Agent 2] āāā Result 2 āāā¼āāā Aggregate ā [Final]
ā ā
āāāā [Agent 3] āāā Result 3 āāā
Confirm the task is fan-out appropriate:
Subtask independence check:
- Can subtask B complete without subtask A's result? [YES/NO]
- Do subtasks share mutable state? [YES/NO - should be NO]
- Is order of completion irrelevant? [YES/NO - should be YES]
If any check fails ā Use 'pipeline' pattern instead
Break work into discrete, independent units:
Original task: [Description]
Subtasks:
1. [Subtask 1] - Agent type: [explore/research/analyze]
2. [Subtask 2] - Agent type: [explore/research/analyze]
3. [Subtask 3] - Agent type: [explore/research/analyze]
...
Expected outputs:
- Subtask 1 ā [What result looks like]
- Subtask 2 ā [What result looks like]
Launch agents simultaneously:
Spawning [N] parallel agents:
Agent 1: [Subtask description]
Agent 2: [Subtask description]
Agent 3: [Subtask description]
[Wait for all to complete]
Use Task tool with appropriate subagent_type for each.
Gather outputs from all agents:
Results received:
- Agent 1: [Summary]
- Agent 2: [Summary]
- Agent 3: [Summary]
Aggregate results into coherent output:
Synthesis:
- [Combined insight 1]
- [Combined insight 2]
- [Patterns across results]
- [Conflicts or contradictions]
Present unified findings:
## Fan-Out Results: [Task]
### Summary
[High-level findings]
### Details by Subtask
1. [Subtask 1 findings]
2. [Subtask 2 findings]
...
### Cross-Cutting Insights
[Patterns that emerged across subtasks]
### Recommendations
[Actionable next steps]
When to limit parallelism:
Failure handling:
User: "Check all our API endpoints for authentication issues"
Subtask independence check:
- Can each file be analyzed independently? YES
- Shared state? NO
- Order irrelevant? YES
ā Fan-out appropriate
Decomposing:
1. Analyze src/api/users.ts for auth issues
2. Analyze src/api/orders.ts for auth issues
3. Analyze src/api/products.ts for auth issues
4. Analyze src/api/admin.ts for auth issues
[Spawns 4 parallel explore agents]
Results:
- users.ts: Missing rate limiting on login endpoint
- orders.ts: No auth check on order history
- products.ts: Clean
- admin.ts: Using deprecated auth method
Synthesis:
3 of 4 files have auth issues. Most critical: orders.ts
exposes user data without authentication.
User: "Compare Redis, Memcached, and DynamoDB for our caching layer"
Subtask independence check:
- Independent research? YES
- Shared state? NO
- Order irrelevant? YES
ā Fan-out appropriate
Decomposing:
1. Research Redis: features, performance, pricing
2. Research Memcached: features, performance, pricing
3. Research DynamoDB: features, performance, pricing
[Spawns 3 parallel research agents]
Results synthesized into comparison table with
cross-cutting analysis of trade-offs.
User: "Build a feature: first design it, then implement, then test"
Subtask independence check:
- Can implementation happen without design? NO
- Can tests run without implementation? NO
ā NOT fan-out appropriate
ā Use 'pipeline' pattern instead
Sequential processing of independent tasks wastes time. A human would delegate parallel work to multiple people. This elixir gives Claude the same capability: decompose, distribute, synthesize.
The key insight: parallelism only helps when tasks are truly independent. Otherwise, you get chaos, not speed.