name: parallel-execution
Execute multiple independent tasks simultaneously to dramatically reduce implementation time for multi-component features.
Invoke parallel execution when:
Avoid parallel execution when:
Claude Code natively supports parallel work via multiple tool calls in one message.
When you make multiple independent task() calls in a single response, Claude Code executes them in parallel:
I'll execute these three tasks in parallel:
task(subagent_type="CoderAgent", description="Implement auth service", prompt="...")
task(subagent_type="CoderAgent", description="Implement user service", prompt="...")
task(subagent_type="TestEngineer", description="Create integration tests", prompt="...")
Key points:
Requires: CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=true
Agent teams allow multiple agents to collaborate on a shared workspace:
I'll create an agent team for this feature:
team(
name="auth-implementation",
agents=[
{type: "CoderAgent", task: "Backend auth service"},
{type: "OpenFrontendSpecialist", task: "Login UI components"},
{type: "TestEngineer", task: "E2E auth tests"}
],
shared_context=".tmp/sessions/auth-context.md"
)
Key points:
TaskManager automatically identifies parallel tasks and marks them with parallel: true:
task.json:
{
"id": "user-dashboard",
"subtask_count": 5,
"context_files": [".opencode/context/core/standards/code-quality.md"]
}
subtask_01.json (parallel):
{
"id": "user-dashboard-01",
"seq": "01",
"title": "Create user profile API",
"parallel": true,
"depends_on": [],
"suggested_agent": "CoderAgent"
}
subtask_02.json (parallel):
{
"id": "user-dashboard-02",
"seq": "02",
"title": "Design dashboard UI components",
"parallel": true,
"depends_on": [],
"suggested_agent": "OpenFrontendSpecialist"
}
subtask_03.json (sequential - depends on 01 and 02):
{
"id": "user-dashboard-03",
"seq": "03",
"title": "Integrate API with UI",
"parallel": false,
"depends_on": ["01", "02"],
"suggested_agent": "CoderAgent"
}
Use the task-management CLI to identify parallel tasks:
# Show which tasks can run in parallel
bash .opencode/skills/task-management/router.sh parallel user-dashboard
Output:
Batch 1 (Ready now):
- subtask_01.json (parallel: true)
- subtask_02.json (parallel: true)
Batch 2 (After Batch 1):
- subtask_03.json (depends_on: ["01", "02"])
Step 1: Analyze Task Structure
Read .tmp/tasks/{feature}/task.json
Read all subtask_NN.json files
Identify parallel batches using dependency graph
Step 2: Execute Parallel Batch
For Batch 1 (subtasks 01 and 02 are parallel):
task(
subagent_type="CoderAgent",
description="Execute subtask 01",
prompt="Read .tmp/tasks/user-dashboard/subtask_01.json and implement..."
)
task(
subagent_type="OpenFrontendSpecialist",
description="Execute subtask 02",
prompt="Read .tmp/tasks/user-dashboard/subtask_02.json and implement..."
)
Wait for both to complete...
Step 3: Verify Batch Completion
bash .opencode/skills/task-management/router.sh status user-dashboard
Step 4: Execute Next Batch
Once Batch 1 is complete, proceed to Batch 2:
task(
subagent_type="CoderAgent",
description="Execute subtask 03",
prompt="Read .tmp/tasks/user-dashboard/subtask_03.json and integrate..."
)
Scenario: Convert 5 subagent files from old format to new format
I'll convert these subagents in parallel:
task(subagent_type="CoderAgent", description="Convert auth-agent",
prompt="Convert .opencode/agent/subagents/auth-agent.md to new format...")
task(subagent_type="CoderAgent", description="Convert user-agent",
prompt="Convert .opencode/agent/subagents/user-agent.md to new format...")
task(subagent_type="CoderAgent", description="Convert payment-agent",
prompt="Convert .opencode/agent/subagents/payment-agent.md to new format...")
task(subagent_type="CoderAgent", description="Convert notification-agent",
prompt="Convert .opencode/agent/subagents/notification-agent.md to new format...")
task(subagent_type="CoderAgent", description="Convert analytics-agent",
prompt="Convert .opencode/agent/subagents/analytics-agent.md to new format...")
Time savings: 5 tasks × 10 min each = 50 min sequential → ~10 min parallel (80% faster)
Scenario: Run unit tests, integration tests, and E2E tests simultaneously
I'll run all test suites in parallel:
task(subagent_type="TestEngineer", description="Run unit tests",
prompt="Execute unit test suite for src/auth/...")
task(subagent_type="TestEngineer", description="Run integration tests",
prompt="Execute integration test suite for src/api/...")
task(subagent_type="TestEngineer", description="Run E2E tests",
prompt="Execute E2E test suite for user flows...")
Time savings: 3 suites × 5 min each = 15 min sequential → ~5 min parallel (67% faster)
Scenario: Build authentication system with parallel work streams
I'll implement these independent components in parallel:
task(subagent_type="CoderAgent", description="JWT service",
prompt="Create JWT token generation and validation service...")
task(subagent_type="CoderAgent", description="Password hashing",
prompt="Implement bcrypt password hashing utilities...")
task(subagent_type="CoderAgent", description="Session storage",
prompt="Create Redis-based session storage layer...")
task(subagent_type="OpenFrontendSpecialist", description="Login UI",
prompt="Design and implement login form components...")
Time savings: 4 components × 30 min each = 120 min sequential → ~30 min parallel (75% faster)
✅ Good (isolated files):
task(CoderAgent, "Create src/auth/service.ts")
task(CoderAgent, "Create src/user/service.ts")
task(CoderAgent, "Create src/payment/service.ts")
❌ Bad (same file):
task(CoderAgent, "Add auth function to src/utils/helpers.ts")
task(CoderAgent, "Add validation function to src/utils/helpers.ts")
✅ Good (balanced tasks):
task(CoderAgent, "Implement user CRUD API (30 min)")
task(CoderAgent, "Implement auth middleware (30 min)")
❌ Bad (unbalanced):
task(CoderAgent, "Implement entire backend (2 hours)")
task(CoderAgent, "Add one import statement (1 min)")
After delegating parallel tasks, track completion:
# Check status periodically
bash .opencode/skills/task-management/router.sh status {feature}
# Look for:
# - subtask_01.json: status: "completed" ✓
# - subtask_02.json: status: "completed" ✓
# - subtask_03.json: status: "in_progress" ...
If one parallel task fails:
Batch 1 Results:
- Task 01: ✅ Completed
- Task 02: ❌ Failed (missing dependency)
- Task 03: ✅ Completed
Action: Fix Task 02 before proceeding to Batch 2
When tasks need shared information:
✅ Good (pre-load context):
# Load context BEFORE parallel execution
Read .opencode/context/core/standards/code-quality.md
Read .opencode/context/core/standards/security-patterns.md
# Now all parallel tasks have same context
task(CoderAgent, "Implement auth service...")
task(CoderAgent, "Implement user service...")
❌ Bad (each task discovers context):
# Each task will call ContextScout separately (slower)
task(CoderAgent, "Discover context and implement auth...")
task(CoderAgent, "Discover context and implement user...")
Problem: Task 02 finishes before Task 01, but Task 03 depends on both
Solution: Use dependency tracking in subtask JSON:
{
"id": "feature-03",
"depends_on": ["01", "02"],
"parallel": false
}
Don't start Task 03 until BOTH 01 and 02 are marked status: "completed".
Problem: Two tasks tried to modify the same file
Solution:
parallel: falseProblem: Task 01 needs output from Task 02, but both marked parallel
Solution: Fix dependency graph:
{
"id": "feature-01",
"depends_on": ["02"], // Add dependency
"parallel": false // Mark sequential
}
Problem: Tasks executing sequentially despite parallel flags
Solution: Ensure you're making multiple task() calls in SAME message:
✅ Correct:
I'll execute these in parallel:
task(...)
task(...)
task(...)
❌ Wrong (sequential):
I'll execute task 1:
task(...)
[Wait for response]
Now I'll execute task 2:
task(...)
| Scenario | Sequential | Parallel | Savings |
|---|---|---|---|
| 3 independent components (30 min each) | 90 min | 30 min | 67% |
| 5 file conversions (10 min each) | 50 min | 10 min | 80% |
| 4 test suites (15 min each) | 60 min | 15 min | 75% |
| Frontend + Backend + Tests | 120 min | 40 min | 67% |
/task-breakdown — Creates task structure with parallel flags/context-discovery — Load shared context before parallel execution/code-review — Review all parallel outputs togetherFor complex features requiring tight coordination, use agent teams (experimental):
team(
name="e-commerce-checkout",
agents=[
{
type: "CoderAgent",
role: "backend",
tasks: ["Payment API", "Order processing", "Inventory check"]
},
{
type: "OpenFrontendSpecialist",
role: "frontend",
tasks: ["Checkout UI", "Payment form", "Order confirmation"]
},
{
type: "TestEngineer",
role: "qa",
tasks: ["Integration tests", "E2E checkout flow"]
}
],
shared_context: ".tmp/sessions/checkout-context.md",
coordination: "async" // Agents coordinate via shared context file
)
Benefits:
Drawbacks:
Parallel execution is a powerful technique for reducing implementation time when:
parallel: truetask() calls in same messageKey takeaways:
Time savings: 50-80% reduction in execution time for multi-component features.