Patterns for parallel subagent execution using Task tool with run_in_background. Use when coordinating multiple independent tasks, spawning dynamic subagents, or implementing features that can be parallelized.
View on GitHubCloudAI-X/claude-workflow-v2
project-starter
January 14, 2026
Select agents to install to:
npx add-skill https://github.com/CloudAI-X/claude-workflow-v2/blob/main//skills/parallel-execution/SKILL.md -a claude-code --skill parallel-executionInstallation paths:
.claude/skills/parallel-execution/# Parallel Execution Patterns ## Core Concept Parallel execution spawns multiple subagents simultaneously using the Task tool with `run_in_background: true`. This enables N tasks to run concurrently, dramatically reducing total execution time. **Critical Rule**: ALL Task calls MUST be in a SINGLE assistant message for true parallelism. If Task calls are in separate messages, they run sequentially. ## Execution Protocol ### Step 1: Identify Parallelizable Tasks Before spawning, verify tasks are independent: - No task depends on another's output - Tasks target different files or concerns - Can run simultaneously without conflicts ### Step 2: Prepare Dynamic Subagent Prompts Each subagent receives a custom prompt defining its role: ``` You are a [ROLE] specialist for this specific task. Task: [CLEAR DESCRIPTION] Context: [RELEVANT CONTEXT ABOUT THE CODEBASE/PROJECT] Files to work with: [SPECIFIC FILES OR PATTERNS] Output format: [EXPECTED OUTPUT STRUCTURE] Focus areas: - [PRIORITY 1] - [PRIORITY 2] ``` ### Step 3: Launch All Tasks in ONE Message **CRITICAL**: Make ALL Task calls in the SAME assistant message: ``` I'm launching N parallel subagents: [Task 1] description: "Subagent A - [brief purpose]" prompt: "[detailed instructions for subagent A]" run_in_background: true [Task 2] description: "Subagent B - [brief purpose]" prompt: "[detailed instructions for subagent B]" run_in_background: true [Task 3] description: "Subagent C - [brief purpose]" prompt: "[detailed instructions for subagent C]" run_in_background: true ``` ### Step 4: Retrieve Results with TaskOutput After launching, retrieve each result: ``` [Wait for completion, then retrieve] TaskOutput: task_1_id TaskOutput: task_2_id TaskOutput: task_3_id ``` ### Step 5: Synthesize Results Combine all subagent outputs into unified result: - Merge related findings - Resolve conflicts between recommendations - Prioritize by severity/importance - Create actionable summary ## Dynamic Subagen