Parallel Execution Patterns

Patterns for parallel subagent execution using the Agent

by CloudAI-X · MIT license · ★ 1,416 on GitHub

Parallel Execution Patterns cover

Patterns for parallel subagent execution using the Agent tool (formerly Task). Use when coordinating multiple independent tasks, spawning dynamic subagents, or implementing features that can be parallelized.

---
name: parallel-execution
description: Patterns for parallel subagent execution using the Agent tool (formerly Task). Use when coordinating multiple independent tasks, spawning dynamic subagents, or implementing features that can be parallelized.
---

# Parallel Execution Patterns

### When to Load

- **Trigger**: Multi-agent tasks, concurrent operations, spawning subagents, parallelizing independent work
- **Skip**: Single-step tasks or sequential workflows with no parallelization opportunity

## Core Concept

Parallel execution spawns multiple subagents simultaneously using the Agent tool (named `Task` before Claude Code 2.1.63; `Task` still works as an alias). Subagents run in the background by default, so N tasks run concurrently, dramatically reducing total execution time.

**Critical Rule**: ALL Agent calls MUST be in a SINGLE assistant message for true parallelism. If the calls are in separate messages, they launch one after another.

Overview

Parallel execution spawns multiple subagents simultaneously using the Agent tool (named Task before Claude Code 2.1.63; Task still works as an alias). Subagents run in the background by default, so N tasks run concurrently, dramatically reducing total execution time.

Manual install (npx, ZIP)
Claude Codenpx skills add CloudAI-X/claude-workflow-v2 --skill parallel-execution -g -a claude-code
Claude Code (degit)npx degit CloudAI-X/claude-workflow-v2/skills/parallel-execution#main ~/.claude/skills/parallel-execution
Claude.ai / desktopZip the folder and upload it under Settings → Capabilities → Skills.
Codex, Cursor, other agentsPoint them at SKILL.md. The other files are plain text.

Connects with Agent Alley MCP · agentalley.io/mcp

Files included

  • SKILL.md6.6 KB
Read SKILL.md here
CloudAI-X/main1 file shown
SKILL.md
Show the full text236 lines

Parallel Execution Patterns

When to Load
  • Trigger: Multi-agent tasks, concurrent operations, spawning subagents, parallelizing independent work
  • Skip: Single-step tasks or sequential workflows with no parallelization opportunity

Core Concept

Parallel execution spawns multiple subagents simultaneously using the Agent tool (named Task before Claude Code 2.1.63; Task still works as an alias). Subagents run in the background by default, so N tasks run concurrently, dramatically reducing total execution time.

Critical Rule: ALL Agent calls MUST be in a SINGLE assistant message for true parallelism. If the calls are in separate messages, they launch one after another.

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 Agent calls in the SAME assistant message:

I'm launching N parallel subagents:

[Agent 1]
description: "Subagent A - [brief purpose]"
prompt: "[detailed instructions for subagent A]"

[Agent 2]
description: "Subagent B - [brief purpose]"
prompt: "[detailed instructions for subagent B]"

[Agent 3]
description: "Subagent C - [brief purpose]"
prompt: "[detailed instructions for subagent C]"

On Claude Code versions that still run subagents in the foreground by default, add run_in_background: true to each call.

Step 4: Collect Results

Each subagent returns its final result to the parent conversation automatically when it finishes. Wait until every subagent has reported before synthesizing; do not poll, and do not start dependent work early. (The separate TaskOutput call is deprecated.)

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 Subagent Patterns

Pattern 1: Task-Based Parallelization

When you have N tasks to implement, spawn N subagents:

Plan:
1. Implement auth module
2. Create API endpoints
3. Add database schema
4. Write unit tests
5. Update documentation

Wave 1 - spawn 3 subagents (independent of each other):
- Subagent 1: Implements auth module
- Subagent 2: Creates API endpoints
- Subagent 3: Adds database schema

Wave 2 - after wave 1 has finished (these depend on its output):
- Subagent 4: Writes unit tests
- Subagent 5: Updates documentation
Pattern 2: Directory-Based Parallelization

Analyze multiple directories simultaneously:

Directories: src/auth, src/api, src/db

Spawn 3 subagents:
- Subagent 1: Analyzes src/auth
- Subagent 2: Analyzes src/api
- Subagent 3: Analyzes src/db
Pattern 3: Perspective-Based Parallelization

Review from multiple angles simultaneously:

Perspectives: Security, Performance, Testing, Architecture

Spawn 4 subagents:
- Subagent 1: Security review
- Subagent 2: Performance analysis
- Subagent 3: Test coverage review
- Subagent 4: Architecture assessment

Task List Integration

When using parallel execution, task tracking (TaskCreate/TaskUpdate, or TodoWrite on older versions) differs:

Sequential execution: Only ONE task in_progress at a time Parallel execution: MULTIPLE tasks can be in_progress simultaneously

# Before launching parallel tasks
todos = [
  { content: "Task A", status: "in_progress" },
  { content: "Task B", status: "in_progress" },
  { content: "Task C", status: "in_progress" },
  { content: "Synthesize results", status: "pending" }
]

# As each subagent reports back, mark its task completed
todos = [
  { content: "Task A", status: "completed" },
  { content: "Task B", status: "completed" },
  { content: "Task C", status: "completed" },
  { content: "Synthesize results", status: "in_progress" }
]

When to Use Parallel Execution

Good candidates:

  • Multiple independent analyses (code review, security, tests)
  • Multi-file processing where files are independent
  • Exploratory tasks with different perspectives
  • Verification tasks with different checks
  • Feature implementation with independent components

Avoid parallelization when:

  • Tasks have dependencies (Task B needs Task A's output)
  • Sequential workflows are required (commit -> push -> PR)
  • Tasks modify the same files (risk of conflicts)
  • Order matters for correctness

Performance Benefits

Approach 5 Tasks @ 30s each Total Time
Sequential 30s + 30s + 30s + 30s + 30s ~150s
Parallel All 5 run simultaneously ~30s

Parallel execution is approximately Nx faster where N is the number of independent tasks.

Example: Feature Implementation

User request: "Implement user authentication with login, registration, and password reset"

Orchestrator creates plan:

  1. Implement login endpoint
  2. Implement registration endpoint
  3. Implement password reset endpoint
  4. Add authentication middleware
  5. Write integration tests

Parallel execution:

Wave 1 - launching 4 subagents in parallel:

[Agent 1] Login endpoint implementation
[Agent 2] Registration endpoint implementation
[Agent 3] Password reset endpoint implementation
[Agent 4] Auth middleware implementation

[Results arrive as each subagent finishes]

Wave 2 - depends on wave 1:

[Agent 5] Integration test writing

[Synthesize into cohesive implementation]

Troubleshooting

Tasks running sequentially?

  • Verify ALL Agent calls are in a SINGLE message
  • On older Claude Code versions, check run_in_background: true is set for each

Results not available?

  • Results are delivered when each subagent finishes; wait for all of them
  • A subagent that was denied a permission may return without finishing its work; check its report

Conflicts in output?

  • Ensure tasks don't modify same files
  • Add conflict resolution in synthesis step
1---
2name: parallel-execution
3description: Patterns for parallel subagent execution using the Agent tool (formerly Task). Use when coordinating multiple independent tasks, spawning dynamic subagents, or implementing features that can be parallelized.
4---
5 
6# Parallel Execution Patterns
7 
8### When to Load
9 
10- **Trigger**: Multi-agent tasks, concurrent operations, spawning subagents, parallelizing independent work
11- **Skip**: Single-step tasks or sequential workflows with no parallelization opportunity
12 
13## Core Concept
14 
15Parallel execution spawns multiple subagents simultaneously using the Agent tool (named `Task` before Claude Code 2.1.63; `Task` still works as an alias). Subagents run in the background by default, so N tasks run concurrently, dramatically reducing total execution time.
16 
17**Critical Rule**: ALL Agent calls MUST be in a SINGLE assistant message for true parallelism. If the calls are in separate messages, they launch one after another.
18 
19## Execution Protocol
20 
21### Step 1: Identify Parallelizable Tasks
22 
23Before spawning, verify tasks are independent:
24 
25- No task depends on another's output
26- Tasks target different files or concerns
27- Can run simultaneously without conflicts
28 
29### Step 2: Prepare Dynamic Subagent Prompts
30 
31Each subagent receives a custom prompt defining its role:
32 
33```
34You are a [ROLE] specialist for this specific task.
35 
36Task: [CLEAR DESCRIPTION]
37 
38Context:
39[RELEVANT CONTEXT ABOUT THE CODEBASE/PROJECT]
40 
41Files to work with:
42[SPECIFIC FILES OR PATTERNS]
43 
44Output format:
45[EXPECTED OUTPUT STRUCTURE]
46 
47Focus areas:
48- [PRIORITY 1]
49- [PRIORITY 2]
50```
51 
52### Step 3: Launch All Tasks in ONE Message
53 
54**CRITICAL**: Make ALL Agent calls in the SAME assistant message:
55 
56```
57I'm launching N parallel subagents:
58 
59[Agent 1]
60description: "Subagent A - [brief purpose]"
61prompt: "[detailed instructions for subagent A]"
62 
63[Agent 2]
64description: "Subagent B - [brief purpose]"
65prompt: "[detailed instructions for subagent B]"
66 
67[Agent 3]
68description: "Subagent C - [brief purpose]"
69prompt: "[detailed instructions for subagent C]"
70```
71 
72On Claude Code versions that still run subagents in the foreground by default, add `run_in_background: true` to each call.
73 
74### Step 4: Collect Results
75 
76Each subagent returns its final result to the parent conversation automatically when it finishes. Wait until every subagent has reported before synthesizing; do not poll, and do not start dependent work early. (The separate `TaskOutput` call is deprecated.)
77 
78### Step 5: Synthesize Results
79 
80Combine all subagent outputs into unified result:
81 
82- Merge related findings
83- Resolve conflicts between recommendations
84- Prioritize by severity/importance
85- Create actionable summary
86 
87## Dynamic Subagent Patterns
88 
89### Pattern 1: Task-Based Parallelization
90 
91When you have N tasks to implement, spawn N subagents:
92 
93```
94Plan:
951. Implement auth module
962. Create API endpoints
973. Add database schema
984. Write unit tests
995. Update documentation
100 
101Wave 1 - spawn 3 subagents (independent of each other):
102- Subagent 1: Implements auth module
103- Subagent 2: Creates API endpoints
104- Subagent 3: Adds database schema
105 
106Wave 2 - after wave 1 has finished (these depend on its output):
107- Subagent 4: Writes unit tests
108- Subagent 5: Updates documentation
109```
110 
111### Pattern 2: Directory-Based Parallelization
112 
113Analyze multiple directories simultaneously:
114 
115```
116Directories: src/auth, src/api, src/db
117 
118Spawn 3 subagents:
119- Subagent 1: Analyzes src/auth
120- Subagent 2: Analyzes src/api
121- Subagent 3: Analyzes src/db
122```
123 
124### Pattern 3: Perspective-Based Parallelization
125 
126Review from multiple angles simultaneously:
127 
128```
129Perspectives: Security, Performance, Testing, Architecture
130 
131Spawn 4 subagents:
132- Subagent 1: Security review
133- Subagent 2: Performance analysis
134- Subagent 3: Test coverage review
135- Subagent 4: Architecture assessment
136```
137 
138## Task List Integration
139 
140When using parallel execution, task tracking (`TaskCreate`/`TaskUpdate`, or `TodoWrite` on older versions) differs:
141 
142**Sequential execution**: Only ONE task `in_progress` at a time
143**Parallel execution**: MULTIPLE tasks can be `in_progress` simultaneously
144 
145```
146# Before launching parallel tasks
147todos = [
148 { content: "Task A", status: "in_progress" },
149 { content: "Task B", status: "in_progress" },
150 { content: "Task C", status: "in_progress" },
151 { content: "Synthesize results", status: "pending" }
152]
153 
154# As each subagent reports back, mark its task completed
155todos = [
156 { content: "Task A", status: "completed" },
157 { content: "Task B", status: "completed" },
158 { content: "Task C", status: "completed" },
159 { content: "Synthesize results", status: "in_progress" }
160]
161```
162 
163## When to Use Parallel Execution
164 
165**Good candidates:**
166 
167- Multiple independent analyses (code review, security, tests)
168- Multi-file processing where files are independent
169- Exploratory tasks with different perspectives
170- Verification tasks with different checks
171- Feature implementation with independent components
172 
173**Avoid parallelization when:**
174 
175- Tasks have dependencies (Task B needs Task A's output)
176- Sequential workflows are required (commit -> push -> PR)
177- Tasks modify the same files (risk of conflicts)
178- Order matters for correctness
179 
180## Performance Benefits
181 
182| Approach | 5 Tasks @ 30s each | Total Time |
183| ---------- | --------------------------- | ---------- |
184| Sequential | 30s + 30s + 30s + 30s + 30s | ~150s |
185| Parallel | All 5 run simultaneously | ~30s |
186 
187Parallel execution is approximately Nx faster where N is the number of independent tasks.
188 
189## Example: Feature Implementation
190 
191**User request**: "Implement user authentication with login, registration, and password reset"
192 
193**Orchestrator creates plan**:
194 
1951. Implement login endpoint
1962. Implement registration endpoint
1973. Implement password reset endpoint
1984. Add authentication middleware
1995. Write integration tests
200 
201**Parallel execution**:
202 
203```
204Wave 1 - launching 4 subagents in parallel:
205 
206[Agent 1] Login endpoint implementation
207[Agent 2] Registration endpoint implementation
208[Agent 3] Password reset endpoint implementation
209[Agent 4] Auth middleware implementation
210 
211[Results arrive as each subagent finishes]
212 
213Wave 2 - depends on wave 1:
214 
215[Agent 5] Integration test writing
216 
217[Synthesize into cohesive implementation]
218```
219 
220## Troubleshooting
221 
222**Tasks running sequentially?**
223 
224- Verify ALL Agent calls are in a SINGLE message
225- On older Claude Code versions, check `run_in_background: true` is set for each
226 
227**Results not available?**
228 
229- Results are delivered when each subagent finishes; wait for all of them
230- A subagent that was denied a permission may return without finishing its work; check its report
231 
232**Conflicts in output?**
233 
234- Ensure tasks don't modify same files
235- Add conflict resolution in synthesis step
236 
View all files on GitHub →

Details

License
MIT
Stars on the repo
★ 1,416
Checked
Source
CloudAI-X/claude-workflow-v2 ↗
Creator
CloudAI-X · 14 listings
View creator

Similar skills

See all →
SkillBrowser Testing Suiteaddyosmani/agent-skills · by addyosmaniTests in real browsers via Chrome DevTools MCP. Use when building or debugging anything that runs in a browser. Use when you need to inspect the DOM, capture console errors, analyze network requests, profile performance, or verify visual output with real runtime data. Requires the chrome-devtools MCP server to be configured.★ 98.7k GitHub starsAgentEverything MCPmodelcontextprotocol/servers · by modelcontextprotocolThis MCP server attempts to exercise all the features of the MCP protocol. It is not intended to be a useful server, but rather a test…★ 90.5k GitHub starsAgentWeb Content Fetchermodelcontextprotocol/servers · by modelcontextprotocolA Model Context Protocol server that provides web content fetching capabilities. This server enables LLMs to retrieve and process content…★ 90.5k GitHub starsAgentFilesystem Operationsmodelcontextprotocol/servers · by modelcontextprotocolNode.js server implementing Model Context Protocol (MCP) for filesystem operations.★ 90.5k GitHub starsSkillLibrary Reference Toolupstash/context7 · by upstashThis skill should be used when the user asks about libraries, frameworks, API references, or needs code examples. Activates for setup questions, code generation involving libraries, or mentions of specific frameworks like React, Vue, Next.js, Prisma, Supabase, etc.★ 62.3k GitHub starsSkillChrome DevTools DebuggerChromeDevTools/chrome-devtools-mcp · by ChromeDevToolsUses Chrome DevTools via MCP for efficient debugging, troubleshooting and browser automation. Use when debugging web pages, automating browser interactions, analyzing performance, or inspecting network requests. This skill does not apply to `--slim` mode (MCP configuration).★ 52.4k GitHub stars

More from CloudAI-X

SkillDatabase Schema & IndexingCloudAI-X/claude-workflow-v2 · by CloudAI-XDesigns database schemas, indexing strategies, query optimization, and migration patterns for SQL and NoSQL databases. Use when designing tables, optimizing queries, fixing N+1 problems, planning migrations, or when asked about database performance, normalization, ORMs, or data modeling.★ 1.4k GitHub starsAgentDebugging SpecialistCloudAI-X/claude-workflow-v2 · by CloudAI-XExpert debugging specialist for errors, test failures, crashes, segmentation faults, memory leaks, timeouts, race conditions, deadlocks, and unexpected behavior. Use PROACTIVELY when encountering any error, exception, or failing test. Performs systematic root cause analysis.★ 1.4k GitHub starsSkillAPI Design & DocumentationCloudAI-X/claude-workflow-v2 · by CloudAI-XDesigns REST and GraphQL APIs including endpoints, error handling, versioning, and documentation. Use when creating new APIs, designing endpoints, reviewing API contracts, or when asked about REST, GraphQL, or API patterns.★ 1.4k GitHub starsSkillTest Design & CoverageCloudAI-X/claude-workflow-v2 · by CloudAI-XDesigns and implements testing strategies for any codebase. Use when adding tests, improving coverage, setting up testing infrastructure, debugging test failures, or when asked about unit tests, integration tests, or E2E testing.★ 1.4k GitHub starsSkillInfrastructure as Code GuideCloudAI-X/claude-workflow-v2 · by CloudAI-XGuides Docker, CI/CD pipelines, deployment strategies, infrastructure as code, and observability setup. Use when writing Dockerfiles, configuring GitHub Actions, planning deployments, setting up monitoring, or when asked about containers, pipelines, Terraform, or production infrastructure.★ 1.4k GitHub starsAgentTechnical Documentation SpecialistCloudAI-X/claude-workflow-v2 · by CloudAI-XTechnical documentation specialist. Use for creating README files, API documentation, architecture docs, inline comments, user guides, changelogs, migration guides, release notes, FAQs, and troubleshooting docs. MUST BE USED when documentation is needed or when code changes require doc updates.★ 1.4k GitHub stars