skills/dispatching-parallel-agents/SKILL.md
将多个独立子任务并行派发给隔离上下文代理,避免上下文污染。触发:3+ 测试文件因不同根因失败、多个子系统独立损坏、每个问题无需其他上下文即可单独理解。不适用:相关失败(修一个可修全部)、需理解系统全貌、代理会互相干扰、探索性调试、存在共享状态。
npx skillsauth add Chikage0o0/opencode dispatching-parallel-agentsInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
你将任务委派给具有隔离上下文的专业代理。通过精确构建它们的指令和上下文,你确保它们保持专注并成功完成任务。它们绝不应继承你会话的上下文或历史 —— 你构建它们所需的精确内容。这也为你保留了用于协调工作的上下文。
当你有多个不相关的失败(不同的测试文件、不同的子系统、不同的 bug)时,按顺序调查它们会浪费时间。每个调查都是独立的,可以并行进行。
核心原则: 每个独立问题域派发一个代理。让它们并发工作。
flowchart TD
A{多个失败?} -->|是| B{独立?}
B -->|否-相关| C[单代理调查全部]
B -->|是| D{可并行?}
D -->|是| E[并行派发]
D -->|否-共享状态| F[顺序代理]
使用场景:
不使用场景:
按损坏的内容对失败进行分组:
每个域都是独立的 —— 修复工具审批不会影响中止测试。
每个代理获得:
// In OpenCode
task({
description: "Review agent-tool-abort failures",
subagent_type: "general",
prompt: "Fix src/agents/agent-tool-abort.test.ts failures and return a summary."
})
task({
description: "Review batch-completion failures",
subagent_type: "general",
prompt: "Fix src/agents/batch-completion-behavior.test.ts failures and return a summary."
})
task({
description: "Review tool-approval failures",
subagent_type: "general",
prompt: "Fix src/agents/tool-approval-race-conditions.test.ts failures and return a summary."
})
// Dispatch all three in parallel
当代理返回时:
优秀的代理提示具有以下特点:
Fix the 3 failing tests in src/agents/agent-tool-abort.test.ts:
1. "should abort tool with partial output capture" - expects 'interrupted at' in message
2. "should handle mixed completed and aborted tools" - fast tool aborted instead of completed
3. "should properly track pendingToolCount" - expects 3 results but gets 0
These are timing/race condition issues. Your task:
1. Read the test file and understand what each test verifies
2. Identify root cause - timing issues or actual bugs?
3. Fix by:
- Replacing arbitrary timeouts with event-based waiting
- Fixing bugs in abort implementation if found
- Adjusting test expectations if testing changed behavior
Do NOT just increase timeouts - find the real issue.
Return: Summary of what you found and what you fixed.
❌ 范围太广: "修复所有测试" —— 代理会迷失方向 ✅ 具体: "修复 agent-tool-abort.test.ts" —— 聚焦范围
❌ 没有上下文: "修复竞态条件" —— 代理不知道在哪里 ✅ 有上下文: 粘贴错误消息和测试名称
❌ 没有约束: 代理可能会重构所有内容 ✅ 有约束: "不要更改生产代码" 或 "仅修复测试"
❌ 输出模糊: "修复它" —— 你不知道更改了什么 ✅ 具体: "返回根因和更改的总结"
相关失败: 修复一个可能修复其他 —— 先一起调查 需要完整上下文: 理解需要看到整个系统 探索性调试: 你还不知道什么坏了 共享状态: 代理会互相干扰(编辑相同文件、使用相同资源)
场景: 重大重构后 3 个文件中的 6 个测试失败
失败:
决策: 独立域 —— 中止逻辑与批量完成和竞态条件分离
派发:
Agent 1 → Fix agent-tool-abort.test.ts
Agent 2 → Fix batch-completion-behavior.test.ts
Agent 3 → Fix tool-approval-race-conditions.test.ts
结果:
集成: 所有修复独立,无冲突,完整套件通过
节省时间: 3 个问题并行解决,而非按顺序
代理返回后:
来自调试会话(2025-10-03):
data-ai
Sync delta specs from a change to main specs. Use when the user wants to update main specs with changes from a delta spec, without archiving the change.
development
Create new agent skills with proper structure, progressive disclosure, and bundled resources. Use when user wants to create, write, or build a new skill.
development
Test-driven development with red-green-refactor loop. Use when user wants to build features or fix bugs using TDD, mentions "red-green-refactor", wants integration tests, or asks for test-first development.
development
Simplifies code for clarity without changing behavior. Use for readability, maintainability, and complexity reduction after behavior is understood.