Loading...
Loading...
Use when a task has multiple independent subtasks that can be executed concurrently by separate agents. Triggers when decomposed work has 2+ subtasks with no data dependencies, when subtasks operate on different files or codebase sections, when serial execution time would be significantly longer than parallel, or when independent analyses or deliverables need concurrent generation.
npx skill4agent add pixel-process-ug/superkit-agents dispatching-parallel-agentsAgentpromptdescriptionsubagent_type"Explore""Plan""general-purpose"run_in_backgroundtruemodel"sonnet""opus""haiku"Agentrun_in_background=truesubagent_type"superpowers:code-reviewer"/decompose| Criterion | Question | If NO |
|---|---|---|
| No shared files | Do any two agents write to the same file? | Serialize those tasks |
| No shared mutable state | Does any agent depend on a side effect of another? | Serialize dependent tasks |
| Self-contained context | Can each agent work with only its own inputs? | Provide more context or serialize |
| Independent verification | Can each agent's output be validated alone? | Combine into single task |
| Scenario | Parallelize? | Reason |
|---|---|---|
| Different files, different concerns | Yes | No conflict possible |
| Same module, different files | Yes (careful) | Verify no shared imports change |
| Same file, different sections | No | Merge conflicts inevitable |
| Task B uses Task A's output | No | Sequential dependency |
| Both read same files, write different | Yes | Reads are safe to parallelize |
| Both modify shared config file | No | Config conflicts |
| Independent test files | Yes | Tests are independent |
| One agent adds dep, another uses it | No | Package-level dependency |
AgentSCOPE: Add structured JSON logging to all API route handlers in src/api/.
Replace console.log calls with the logger from src/utils/logger.ts.
Files to modify: src/api/users.ts, src/api/orders.ts, src/api/products.ts.CONTEXT:
- Logger API: logger.info(message, metadata), logger.error(message, error)
- Import: import { logger } from '../utils/logger'
- Current pattern in files: console.log('action', data)
- Target pattern: logger.info('action', { data, requestId: req.id })OUTPUT: For each modified file, return:
1. The file path
2. A summary of changes made
3. Number of console.log calls replacedCONSTRAINTS:
- Do NOT modify any files outside src/api/
- Do NOT change the logger utility itself
- Do NOT add new dependencies
- Do NOT refactor function signatures
- Do NOT modify test files
- If you encounter an issue outside your scope, report it but do not fix itYou are a focused agent with a single task.
## Scope
[Specific task description with exact files]
## Context
[All information needed to complete the task]
[Relevant code patterns, APIs, conventions]
## Output Format
[Exact structure of what to return]
## Constraints
- Do NOT modify files outside: [list]
- Do NOT change: [list things to leave alone]
- Do NOT add dependencies
- If you encounter an issue outside your scope, report it but do not fix it| Check | Question |
|---|---|
| Scope is specific | Can the agent complete the task without guessing? |
| Context is complete | Does the agent need to explore the codebase? (should be no) |
| Output is defined | Will the agent return what you need to integrate? |
| Constraints are explicit | Are file boundaries and "do NOT" items clear? |
AgentAgentAgent| Agent | Task | Status | Files | Result |
|-------|------|--------|-------|--------|
| Agent 1 | Add logging to API | in_progress | src/api/*.ts | — |
| Agent 2 | Update unit tests | in_progress | tests/unit/*.ts | — |
| Agent 3 | Fix CSS layout | in_progress | src/styles/*.css | — || Scenario | Action |
|---|---|
| One agent fails, others succeed | Retry failed agent independently (via the |
| Multiple agents fail independently | Retry each independently (via the |
| Agent reports out-of-scope issue | Note for post-integration review |
| Agent exceeds scope (modifies wrong files) | Reject output, re-dispatch (via the |
| Check | Command | Must Pass |
|---|---|---|
| No file conflicts | Diff outputs for shared files | Yes |
| Tests pass | Full test suite | Yes |
| Build passes | Build command | Yes |
| Lint passes | Lint command | Yes |
| No regressions | Compare test count before/after | Yes |
| Failure Type | Diagnosis | Action |
|---|---|---|
| Test failure in Agent 1's files | Agent 1's changes have a bug | Re-dispatch Agent 1 (via the |
| Test failure in unrelated files | Cross-cutting regression | Identify root cause, fix manually or re-dispatch (via the |
| Build failure | Import/type issue | Check which agent's changes caused it, fix |
| Merge conflict | Agents touched same file (should not happen) | Rollback, serialize those tasks |
| Pattern | When to Use | Example |
|---|---|---|
| By Module | Independent modules or packages | One |
| By Layer | Layers touch different files | API agent, service agent, data agent |
| By Feature Area | Independent vertical slices | Auth agent, profile agent, billing agent |
| By Task Type | Code, tests, docs touch different files | Code agent, test agent, docs agent |
TASK: "Update the API to v2, add tests, and update OpenAPI spec"
AGENT 1 - API Routes:
Scope: Update route handlers in src/routes/v2/
Context: [v2 API spec, breaking changes list]
Output: Modified files list, breaking changes implemented
Constraints: Do NOT touch tests or docs
AGENT 2 - Tests:
Scope: Write tests in tests/v2/
Context: [v2 API spec, test conventions, existing v1 tests as reference]
Output: New test files, coverage summary
Constraints: Do NOT modify source code
AGENT 3 - OpenAPI Spec:
Scope: Update openapi/v2.yaml
Context: [v2 API spec, OpenAPI 3.1 format]
Output: Updated spec file
Constraints: Do NOT modify code or tests| Anti-Pattern | Why It Fails | Correct Approach |
|---|---|---|
| Two agents modifying the same file | Merge conflicts, data loss | One file owner per |
| Shared mutable state between agents | Race conditions, inconsistency | Eliminate shared state |
| Incomplete context in prompts | Agents explore and step on each other | Provide ALL needed context |
| Vague file boundaries | Agents guess scope, modify wrong files | Explicit file lists in constraints |
| No integration check after completion | Cross-cutting bugs go undetected | Full test suite after integration |
| Parallelizing sequential tasks | Agent B needs Agent A's output | Verify independence first |
| Not tracking which agent touched which file | Cannot diagnose integration failures | Maintain dispatch tracking table |
| Dispatching too many agents (10+) | Coordination overhead exceeds savings | 2-5 |
| Skipping rollback preparation | Cannot recover from integration failure | Keep pre-dispatch state recoverable |
| Skill | Relationship | When |
|---|---|---|
| Upstream — identifies independent task clusters | Before dispatching |
| Complementary — provides review gates | Quality gates for agent output |
| Upstream — may delegate independent tasks | During plan execution |
| Downstream — verifies integrated result | After integration |
| Downstream — reviews integrated changes | After all agents complete |
| On failure — retries failed agents | When individual agents fail |
| Rule | Rationale |
|---|---|
| No two agents modify the same file | Prevents merge conflicts and race conditions |
| No shared mutable state | Eliminates data races |
| Each agent gets complete context | Prevents agents from exploring and stepping on each other |
| Define file boundaries explicitly | Makes ownership unambiguous |
| Review integration after completion | Catches cross-cutting issues |
| Atomic commit for all changes | All in or all out |
| Always have a rollback path | Keep pre-dispatch state recoverable |