// Identify and execute independent operations in parallel for 3-5x speedup. Auto-analyzes task dependencies, groups into batches, launches parallel Task() calls. Applies to /optimize (5 checks), /ship pre-flight (5 checks), /implement (task batching), /prototype (N screens). Auto-triggers when detecting multiple independent operations in a phase.
| name | parallel-execution-optimizer |
| description | Identify and execute independent operations in parallel for 3-5x speedup. Auto-analyzes task dependencies, groups into batches, launches parallel Task() calls. Applies to /optimize (5 checks), /ship pre-flight (5 checks), /implement (task batching), /prototype (N screens). Auto-triggers when detecting multiple independent operations in a phase. |
Traditional sequential execution wastes time:
This skill analyzes operation dependencies, groups independent work into batches, and orchestrates parallel execution using multiple Task() agent calls in a single message. The result: 3-5x faster phase completion with zero compromise on quality or correctness.
<quick_start> <basic_pattern> When you detect multiple independent operations, send a single message with multiple tool calls:
Sequential (slow):
Parallel (fast):
<immediate_use_cases>
Scan the current phase for operations that:
Examples:
Build a dependency graph:
Example (/optimize):
Layer 0 (parallel):
- security-sentry (reads codebase)
- performance-profiler (reads codebase + runs benchmarks)
- accessibility-auditor (reads UI components)
- type-enforcer (reads TypeScript files)
- dependency-curator (reads package.json)
Layer 1 (after Layer 0):
- Generate optimization-report.md (combines all Layer 0 results)
**Group into batches**
Create batches for each layer:
Batch size considerations:
Send a single message with multiple tool calls for each batch.
Critical requirements:
See references/execution-patterns.md for detailed examples.
**Aggregate results**After each batch completes:
Failure handling:
<phase_specific_patterns> <optimize_phase> Operation: Run 5 quality gates in parallel
Dependency graph:
Layer 0 (parallel - 5 operations):
1. security-sentry → Scan for vulnerabilities, secrets, auth issues
2. performance-profiler → Benchmark API endpoints, detect N+1 queries
3. accessibility-auditor → WCAG 2.1 AA compliance (if UI feature)
4. type-enforcer → TypeScript strict mode compliance
5. dependency-curator → npm audit, outdated packages
Layer 1 (sequential - 1 operation):
6. Generate optimization-report.md (aggregates Layer 0 findings)
Time savings:
See references/optimize-phase-parallelization.md for implementation details. </optimize_phase>
<ship_preflight> Operation: Run 5 pre-flight checks in parallel
Dependency graph:
Layer 0 (parallel - 5 operations):
1. Check environment variables (read .env.example vs .env)
2. Validate production build (npm run build)
3. Check Docker configuration (docker-compose.yml, Dockerfile)
4. Validate CI configuration (.github/workflows/*.yml)
5. Run dependency audit (npm audit --production)
Layer 1 (sequential - 1 operation):
6. Update state.yaml with pre-flight results
Time savings:
See references/ship-preflight-parallelization.md. </ship_preflight>
<implement_phase> Operation: Execute independent task batches in parallel
Dependency analysis:
Example (15 tasks):
Layer 0 (4 tasks - parallel):
T001: Create User model
T002: Create Product model
T005: Setup test framework
T008: Create API client utility
Layer 1 (3 tasks - parallel, depend on Layer 0):
T003: User CRUD endpoints (needs T001)
T004: Product CRUD endpoints (needs T002)
T009: Write User model tests (needs T001, T005)
Layer 2 (2 tasks - parallel):
T006: User-Product relationship (needs T001, T002)
T010: Write Product model tests (needs T002, T005)
Layer 3 (sequential):
T007: Integration tests (needs all above)
Execution:
Time savings:
See references/implement-phase-parallelization.md. </implement_phase>
<prototype_screens> Operation: Generate multiple prototype screens in parallel
Use case: User wants to create 3 different screens (login, dashboard, settings)
Sequential approach (slow):
Parallel approach (fast):
Speedup: 3x
Note: All screens share theme.yaml for consistency. </prototype_screens> </phase_specific_patterns>
<dependency_analysis> <determining_independence> Two operations are independent if:
Two operations are dependent if:
<common_patterns> Independent (safe to parallelize):
Dependent (must sequence):
<edge_cases> Shared mutable state: If operations modify the same git branch, database, or filesystem location, they CANNOT run in parallel safely.
Resource contention: Even if logically independent, operations competing for same resource (CPU, memory, network) may not see speedup. Monitor system resources.
Cascading failures: If one parallel operation fails and others depend on it indirectly, you may need to cancel or retry the batch. </edge_cases> </dependency_analysis>
<auto_trigger_conditions> <when_to_apply> Automatically apply parallel execution when you detect:
<when_not_to_apply> Do NOT parallelize when:
<proactive_detection> Scan for these phrases in phase workflows:
When detected, immediately analyze dependencies and propose parallel execution strategy. </proactive_detection> </auto_trigger_conditions>
**Context**: Running /optimize on a feature with UI componentsSequential execution (15 minutes):
1. Launch security-sentry (3 min)
2. Wait for completion
3. Launch performance-profiler (4 min)
4. Wait for completion
5. Launch accessibility-auditor (3 min)
6. Wait for completion
7. Launch type-enforcer (2 min)
8. Wait for completion
9. Launch dependency-curator (2 min)
10. Wait for completion
11. Aggregate results (1 min)
Total: 15 minutes
Parallel execution (5 minutes):
1. Launch 5 agents in SINGLE message:
- security-sentry
- performance-profiler
- accessibility-auditor
- type-enforcer
- dependency-curator
2. All run concurrently (longest is 4 min)
3. Aggregate results (1 min)
Total: 5 minutes
Implementation: See examples/optimize-phase-parallel.md
**Context**: Running pre-flight checks before deploymentSequential execution (12 minutes):
1. Check env vars (1 min)
2. Run build (5 min)
3. Check Docker config (2 min)
4. Validate CI config (2 min)
5. Dependency audit (2 min)
Total: 12 minutes
Parallel execution (6 minutes):
1. Launch 5 checks in SINGLE message (all concurrent)
2. Longest operation is build (5 min)
3. Update workflow state (1 min)
Total: 6 minutes
Implementation: See examples/ship-preflight-parallel.md
**Context**: 12 tasks with dependency graph in /implement phaseTask dependencies:
T001 (User model) → no deps
T002 (Product model) → no deps
T003 (User endpoints) → depends on T001
T004 (Product endpoints) → depends on T002
T005 (User tests) → depends on T001, T003
T006 (Product tests) → depends on T002, T004
T007 (Integration tests) → depends on T003, T004
Parallel execution plan:
Batch 1 (Layer 0): T001, T002 (parallel - 2 tasks)
Batch 2 (Layer 1): T003, T004 (parallel - 2 tasks, wait for Batch 1)
Batch 3 (Layer 2): T005, T006 (parallel - 2 tasks, wait for Batch 2)
Batch 4 (Layer 3): T007 (sequential - 1 task, wait for Batch 3)
Time savings:
Implementation: See examples/implement-batching-parallel.md
<anti_patterns> <anti_pattern name="fake-parallelism"> Problem: Sending multiple messages rapidly, thinking they'll run in parallel
Wrong approach:
Send message 1: Launch agent A
Send message 2: Launch agent B
Send message 3: Launch agent C
These execute sequentially because each message waits for the previous to complete.
Correct approach:
Send ONE message with 3 tool calls (A, B, C)
Rule: Multiple tool calls in a SINGLE message = parallel. Multiple messages = sequential. </anti_pattern>
<anti_pattern name="ignoring-dependencies"> Problem: Parallelizing dependent operations causing race conditions
Wrong approach:
Parallel batch:
- Generate User model code
- Write tests for User model (needs generated code)
Second operation will fail because code doesn't exist yet.
Correct approach:
Batch 1 (sequential): Generate User model code
Batch 2 (sequential): Write tests for User model
Rule: Always build dependency graph first. Never parallelize dependent operations. </anti_pattern>
<anti_pattern name="over-parallelization"> Problem: Launching 20 agents in parallel, overwhelming system
Wrong approach:
Launch 20 agents in single message (all tasks at once)
System resources exhausted, agents may fail or slow down dramatically.
Correct approach:
Batch 1: Launch 5 agents (Layer 0)
Batch 2: Launch 5 agents (Layer 1)
Batch 3: Launch 5 agents (Layer 2)
Batch 4: Launch 5 agents (Layer 3)
Rule: Keep batches to 3-8 operations. More layers is better than huge batches. </anti_pattern>
<anti_pattern name="parallelizing-trivial-operations"> Problem: Using parallel execution for operations taking <30 seconds each
Wrong approach:
Parallel batch:
- Read spec.md (5 seconds)
- Read plan.md (5 seconds)
Overhead of parallel coordination exceeds time savings.
Correct approach:
Sequential:
- Read spec.md
- Read plan.md
Rule: Only parallelize operations taking ≥1 minute each. Below that, sequential is fine. </anti_pattern> </anti_patterns>
After applying parallel execution optimization:<testing_approach> Before parallelization:
After parallelization:
Validate:
Rollback if:
<reference_guides> For deeper topics, see reference files:
Execution patterns: references/execution-patterns.md
Phase-specific guides:
Dependency analysis: references/dependency-analysis-guide.md
Troubleshooting: references/troubleshooting.md
<success_criteria> The parallel-execution-optimizer skill is successfully applied when: