Use when facing 2+ independent tasks that can be worked on without shared state or sequential dependencies
Add this skill
npx mdskills install sickn33/dispatching-parallel-agentsComprehensive guide for parallelizing independent tasks with clear decision framework and examples
1---2name: dispatching-parallel-agents3description: Use when facing 2+ independent tasks that can be worked on without shared state or sequential dependencies4---56# Dispatching Parallel Agents78## Overview910When you have multiple unrelated failures (different test files, different subsystems, different bugs), investigating them sequentially wastes time. Each investigation is independent and can happen in parallel.1112**Core principle:** Dispatch one agent per independent problem domain. Let them work concurrently.1314## When to Use1516```dot17digraph when_to_use {18 "Multiple failures?" [shape=diamond];19 "Are they independent?" [shape=diamond];20 "Single agent investigates all" [shape=box];21 "One agent per problem domain" [shape=box];22 "Can they work in parallel?" [shape=diamond];23 "Sequential agents" [shape=box];24 "Parallel dispatch" [shape=box];2526 "Multiple failures?" -> "Are they independent?" [label="yes"];27 "Are they independent?" -> "Single agent investigates all" [label="no - related"];28 "Are they independent?" -> "Can they work in parallel?" [label="yes"];29 "Can they work in parallel?" -> "Parallel dispatch" [label="yes"];30 "Can they work in parallel?" -> "Sequential agents" [label="no - shared state"];31}32```3334**Use when:**35- 3+ test files failing with different root causes36- Multiple subsystems broken independently37- Each problem can be understood without context from others38- No shared state between investigations3940**Don't use when:**41- Failures are related (fix one might fix others)42- Need to understand full system state43- Agents would interfere with each other4445## The Pattern4647### 1. Identify Independent Domains4849Group failures by what's broken:50- File A tests: Tool approval flow51- File B tests: Batch completion behavior52- File C tests: Abort functionality5354Each domain is independent - fixing tool approval doesn't affect abort tests.5556### 2. Create Focused Agent Tasks5758Each agent gets:59- **Specific scope:** One test file or subsystem60- **Clear goal:** Make these tests pass61- **Constraints:** Don't change other code62- **Expected output:** Summary of what you found and fixed6364### 3. Dispatch in Parallel6566```typescript67// In Claude Code / AI environment68Task("Fix agent-tool-abort.test.ts failures")69Task("Fix batch-completion-behavior.test.ts failures")70Task("Fix tool-approval-race-conditions.test.ts failures")71// All three run concurrently72```7374### 4. Review and Integrate7576When agents return:77- Read each summary78- Verify fixes don't conflict79- Run full test suite80- Integrate all changes8182## Agent Prompt Structure8384Good agent prompts are:851. **Focused** - One clear problem domain862. **Self-contained** - All context needed to understand the problem873. **Specific about output** - What should the agent return?8889```markdown90Fix the 3 failing tests in src/agents/agent-tool-abort.test.ts:91921. "should abort tool with partial output capture" - expects 'interrupted at' in message932. "should handle mixed completed and aborted tools" - fast tool aborted instead of completed943. "should properly track pendingToolCount" - expects 3 results but gets 09596These are timing/race condition issues. Your task:97981. Read the test file and understand what each test verifies992. Identify root cause - timing issues or actual bugs?1003. Fix by:101 - Replacing arbitrary timeouts with event-based waiting102 - Fixing bugs in abort implementation if found103 - Adjusting test expectations if testing changed behavior104105Do NOT just increase timeouts - find the real issue.106107Return: Summary of what you found and what you fixed.108```109110## Common Mistakes111112**❌ Too broad:** "Fix all the tests" - agent gets lost113**✅ Specific:** "Fix agent-tool-abort.test.ts" - focused scope114115**❌ No context:** "Fix the race condition" - agent doesn't know where116**✅ Context:** Paste the error messages and test names117118**❌ No constraints:** Agent might refactor everything119**✅ Constraints:** "Do NOT change production code" or "Fix tests only"120121**❌ Vague output:** "Fix it" - you don't know what changed122**✅ Specific:** "Return summary of root cause and changes"123124## When NOT to Use125126**Related failures:** Fixing one might fix others - investigate together first127**Need full context:** Understanding requires seeing entire system128**Exploratory debugging:** You don't know what's broken yet129**Shared state:** Agents would interfere (editing same files, using same resources)130131## Real Example from Session132133**Scenario:** 6 test failures across 3 files after major refactoring134135**Failures:**136- agent-tool-abort.test.ts: 3 failures (timing issues)137- batch-completion-behavior.test.ts: 2 failures (tools not executing)138- tool-approval-race-conditions.test.ts: 1 failure (execution count = 0)139140**Decision:** Independent domains - abort logic separate from batch completion separate from race conditions141142**Dispatch:**143```144Agent 1 → Fix agent-tool-abort.test.ts145Agent 2 → Fix batch-completion-behavior.test.ts146Agent 3 → Fix tool-approval-race-conditions.test.ts147```148149**Results:**150- Agent 1: Replaced timeouts with event-based waiting151- Agent 2: Fixed event structure bug (threadId in wrong place)152- Agent 3: Added wait for async tool execution to complete153154**Integration:** All fixes independent, no conflicts, full suite green155156**Time saved:** 3 problems solved in parallel vs sequentially157158## Key Benefits1591601. **Parallelization** - Multiple investigations happen simultaneously1612. **Focus** - Each agent has narrow scope, less context to track1623. **Independence** - Agents don't interfere with each other1634. **Speed** - 3 problems solved in time of 1164165## Verification166167After agents return:1681. **Review each summary** - Understand what changed1692. **Check for conflicts** - Did agents edit same code?1703. **Run full suite** - Verify all fixes work together1714. **Spot check** - Agents can make systematic errors172173## Real-World Impact174175From debugging session (2025-10-03):176- 6 failures across 3 files177- 3 agents dispatched in parallel178- All investigations completed concurrently179- All fixes integrated successfully180- Zero conflicts between agent changes181
Full transparency — inspect the skill content before installing.