Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Dispatches multiple independent subagents in parallel to investigate or fix separate problem domains concurrently.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
SKILL.md
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## Overview910You delegate tasks to specialized agents with isolated context. By precisely crafting their instructions and context, you ensure they stay focused and succeed at their task. They should never inherit your session's context or history — you construct exactly what they need. This also preserves your own context for coordination work.1112When 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.1314**Core principle:** Dispatch one agent per independent problem domain. Let them work concurrently.1516## When to Use1718```dot19digraph when_to_use {20"Multiple failures?" [shape=diamond];21"Are they independent?" [shape=diamond];22"Single agent investigates all" [shape=box];23"One agent per problem domain" [shape=box];24"Can they work in parallel?" [shape=diamond];25"Sequential agents" [shape=box];26"Parallel dispatch" [shape=box];2728"Multiple failures?" -> "Are they independent?" [label="yes"];29"Are they independent?" -> "Single agent investigates all" [label="no - related"];30"Are they independent?" -> "Can they work in parallel?" [label="yes"];31"Can they work in parallel?" -> "Parallel dispatch" [label="yes"];32"Can they work in parallel?" -> "Sequential agents" [label="no - shared state"];33}34```3536**Use when:**37- 3+ test files failing with different root causes38- Multiple subsystems broken independently39- Each problem can be understood without context from others40- No shared state between investigations4142**Don't use when:**43- Failures are related (fix one might fix others)44- Need to understand full system state45- Agents would interfere with each other4647## The Pattern4849### 1. Identify Independent Domains5051Group failures by what's broken:52- File A tests: Tool approval flow53- File B tests: Batch completion behavior54- File C tests: Abort functionality5556Each domain is independent - fixing tool approval doesn't affect abort tests.5758### 2. Create Focused Agent Tasks5960Each agent gets:61- **Specific scope:** One test file or subsystem62- **Clear goal:** Make these tests pass63- **Constraints:** Don't change other code64- **Expected output:** Summary of what you found and fixed6566### 3. Dispatch in Parallel6768```typescript69// In Claude Code / AI environment70Task("Fix agent-tool-abort.test.ts failures")71Task("Fix batch-completion-behavior.test.ts failures")72Task("Fix tool-approval-race-conditions.test.ts failures")73// All three run concurrently74```7576### 4. Review and Integrate7778When agents return:79- Read each summary80- Verify fixes don't conflict81- Run full test suite82- Integrate all changes8384## Agent Prompt Structure8586Good agent prompts are:871. **Focused** - One clear problem domain882. **Self-contained** - All context needed to understand the problem893. **Specific about output** - What should the agent return?9091```markdown92Fix the 3 failing tests in src/agents/agent-tool-abort.test.ts:93941. "should abort tool with partial output capture" - expects 'interrupted at' in message952. "should handle mixed completed and aborted tools" - fast tool aborted instead of completed963. "should properly track pendingToolCount" - expects 3 results but gets 09798These are timing/race condition issues. Your task:991001. Read the test file and understand what each test verifies1012. Identify root cause - timing issues or actual bugs?1023. Fix by:103- Replacing arbitrary timeouts with event-based waiting104- Fixing bugs in abort implementation if found105- Adjusting test expectations if testing changed behavior106107Do NOT just increase timeouts - find the real issue.108109Return: Summary of what you found and what you fixed.110```111112## Common Mistakes113114**❌ Too broad:** "Fix all the tests" - agent gets lost115**✅ Specific:** "Fix agent-tool-abort.test.ts" - focused scope116117**❌ No context:** "Fix the race condition" - agent doesn't know where118**✅ Context:** Paste the error messages and test names119120**❌ No constraints:** Agent might refactor everything121**✅ Constraints:** "Do NOT change production code" or "Fix tests only"122123**❌ Vague output:** "Fix it" - you don't know what changed124**✅ Specific:** "Return summary of root cause and changes"125126## When NOT to Use127128**Related failures:** Fixing one might fix others - investigate together first129**Need full context:** Understanding requires seeing entire system130**Exploratory debugging:** You don't know what's broken yet131**Shared state:** Agents would interfere (editing same files, using same resources)132133## Real Example from Session134135**Scenario:** 6 test failures across 3 files after major refactoring136137**Failures:**138- agent-tool-abort.test.ts: 3 failures (timing issues)139- batch-completion-behavior.test.ts: 2 failures (tools not executing)140- tool-approval-race-conditions.test.ts: 1 failure (execution count = 0)141142**Decision:** Independent domains - abort logic separate from batch completion separate from race conditions143144**Dispatch:**145```146Agent 1 → Fix agent-tool-abort.test.ts147Agent 2 → Fix batch-completion-behavior.test.ts148Agent 3 → Fix tool-approval-race-conditions.test.ts149```150151**Results:**152- Agent 1: Replaced timeouts with event-based waiting153- Agent 2: Fixed event structure bug (threadId in wrong place)154- Agent 3: Added wait for async tool execution to complete155156**Integration:** All fixes independent, no conflicts, full suite green157158**Time saved:** 3 problems solved in parallel vs sequentially159160## Key Benefits1611621. **Parallelization** - Multiple investigations happen simultaneously1632. **Focus** - Each agent has narrow scope, less context to track1643. **Independence** - Agents don't interfere with each other1654. **Speed** - 3 problems solved in time of 1166167## Verification168169After agents return:1701. **Review each summary** - Understand what changed1712. **Check for conflicts** - Did agents edit same code?1723. **Run full suite** - Verify all fixes work together1734. **Spot check** - Agents can make systematic errors174175## Real-World Impact176177From debugging session (2025-10-03):178- 6 failures across 3 files179- 3 agents dispatched in parallel180- All investigations completed concurrently181- All fixes integrated successfully182- Zero conflicts between agent changes183