From specpowers
当请求可以拆成 2 个以上可并发运行的独立 workstreams,并且没有 shared mutable state、file ownership conflicts 或 sequential dependencies 时使用。
How this skill is triggered — by the user, by Claude, or both
Slash command
/specpowers:dispatching-parallel-agentsThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
当一个任务包含彼此独立的问题域时,使用此 skill 协调多个隔离的 specialist agents。Orchestrator 仍然是 user-facing answer、task decomposition、integration、verification 和 final judgment 的唯一负责人。
当一个任务包含彼此独立的问题域时,使用此 skill 协调多个隔离的 specialist agents。Orchestrator 仍然是 user-facing answer、task decomposition、integration、verification 和 final judgment 的唯一负责人。
Sub-agents 不会继承当前对话、隐藏假设或彼此的工作。每个派发任务都必须包含该 agent 独立完成所需的精确 context、scope、constraints 和 expected output。
核心原则: 每个 independent domain 派发一个 agent,然后通过单一 orchestration layer 整合 findings。
只有以下条件全部成立时,才使用此 skill:
优先在这些场景使用:
不要在这些场景使用:
如果 independence 不确定,先做短 triage pass。边界不清时,在 writer agents 前派发 read-only planning agents。
派发前回答这些问题:
| Check | Ready Signal | If Not Ready |
|---|---|---|
| Domain boundary | 每个 agent 拥有独立 file set、subsystem 或 concern | 先做 triage/planning pass |
| Dependency order | Agents 不需要彼此 outputs 就能开始 | 顺序执行或拆成 phases |
| Write conflicts | 可写 paths 不重叠 | 指派一个 writer,其他设为 read-only |
| Shared state | 没有 shared test database、service、branch state 或 generated artifact conflict | 串行化风险步骤 |
| Verification | 已知如何验证每个结果和集成结果 | 先定义 focused 和 full verification |
按独立 problem domain 对请求分组:
对每个 domain,记录:
使用能完成该 domain 的最小 specialist role:
| Role | Template | Use When |
|---|---|---|
| Planner | ./planner-agent-prompt.md | 需要在编辑前做 read-only codebase analysis、dependency mapping、implementation sequencing 或 risk assessment。 |
| Security Reviewer | ./security-reviewer-prompt.md | 需要带 severity、evidence、confidence 和 coverage boundaries 的安全只读审查。通常通过 requesting-code-review 调用。 |
| TDD Guide | ./tdd-guide-prompt.md | 需要 feature 的 test-first plan、behavior matrix 或 red-green-refactor coaching。 |
| Code Reviewer | ../requesting-code-review/code-reviewer-prompt.md | 需要通用 code quality review。通过 requesting-code-review 调用,不要作为单独 user-facing flow。 |
| Debug/Fix Agent | Inline prompt | 需要针对一个 file、subsystem 或 failing test group 的有界 implementation 或 investigation。 |
每个 agent prompt 必须包含:
Ad hoc agents 使用此模板:
You are a focused sub-agent working on one independent domain.
## Objective
[Concrete task]
## Scope
- Own: [files/directories/tests/concerns]
- Do not touch: [out-of-scope areas]
## Context
[Paste all relevant errors, requirements, design notes, and constraints. Do not assume access to the parent conversation.]
## Working Rules
- [Allowed tools/actions]
- [Forbidden tools/actions]
- [Behavior-preserving constraints]
- [Conflict-avoidance constraints]
## Success Criteria
- [Measurable completion condition]
- [Focused verification command or evidence, if applicable]
## Return Format
### Outcome
[Done / Partial / Blocked]
### Root Cause or Key Findings
[Concise evidence-based explanation]
### Changes Made or Recommendations
- `[file]`: [change or recommendation]
### Verification
[Commands run, results, or why verification was not possible]
### Risks and Follow-ups
[Remaining concerns, integration risks, or open questions]
只有 scopes 已分离后,才并行派发 agents。除非明确指派,否则以下 shared resources 由 orchestrator 拥有:
如果两个 agents 可能需要同一个 shared file,把其中一个设为 read-only,或按顺序编辑。
Agents 返回后:
不要盲目拼接 sub-agent outputs。Orchestrator 必须产出一个连贯 final conclusion。
最终回复应包含:
除非用户要求详细 logs,否则避免暴露 raw sub-agent transcripts。
Review-oriented specialists 应位于 unified review orchestration layer 背后。使用 requesting-code-review 作为 user-facing review entrypoint。Security、general code quality 或其他 review specialists 只作为 unified review flow 的内部 helpers 派发。
用户应收到一个 review conclusion,而不是彼此不协调的多个 reviewer opinions。
对 sub-agents 产出的 code 或 recommendations 应用这些检查:
Scenario:一次 refactor 后,三个无关文件中出现六个 test failures。
Claude Code dispatch example: Agent("Fix agent-tool-abort.test.ts failures")
agent-tool-abort.test.ts timing failures。batch-completion-behavior.test.ts event-shape failures。tool-approval-race-conditions.test.ts async completion failures。每个 agent 都收到 failing test names、error messages、relevant scope、constraints 和 return contract。Orchestrator 随后检查 changes、检查 file overlap,并运行 full suite。
Scenario:多个 failures 都涉及同一个 request lifecycle state machine。
不要按 failing test file 派发多个 writer agents。先把 shared state machine 作为一个 domain 调查。理解 root cause 后,只拆分独立 follow-up work。
| Mistake | Why It Fails | Better Approach |
|---|---|---|
| “Fix all tests” | 太宽;agent 会失去焦点 | 指派一个 failing file 或 root-cause domain |
| Missing error context | Agent 会重复 discovery work 或猜测 | 包含 test names、errors、logs 和相关 constraints |
| Overlapping write scope | Agents 会产生 conflicts 或 inconsistent behavior | 指派独占 writable ownership |
| No return contract | Orchestrator 无法可靠整合 results | 要求 outcome、findings、changes、verification、risks |
| Skipping verification | Parallel fixes 可能静默冲突 | 运行 focused checks 和 integration checks |
所有 agents 返回后,尽可能完成以下 protocol:
npx claudepluginhub nsobjects/specpowers --plugin specpowersGuides creation, editing, and verification of skills for AI coding agents using test-driven development with subagent scenarios. Use when authoring or debugging skills.