SuperAPI AI 工具集

parallel-dispatch

智能体与模型

查看项目

更新于 10-16 06:10

技能介绍

用途

parallel-dispatch 技能用于处理多个独立故障或功能分散在不同系统中的场景。它不采用顺序排查,而是创建多个独立的智能体任务,让它们同时处理不同的问题域。

主要能力

  • 按受影响子系统对故障或任务进行分组
  • 验证任务之间的独立性,确认无共享依赖
  • 为每个域创建聚焦范围、目标清晰、约束具体的智能体任务
  • 并发执行所有智能体任务
  • 整合结果,审查、验证兼容性并运行测试

使用方式

快速开始

  1. 识别域:按受影响子系统对故障或任务分组
  2. 验证独立性:确认无共享依赖
  3. 创建任务:聚焦范围、目标清晰、约束具体
  4. 并发调度:同时执行所有智能体任务
  5. 整合结果:审查、验证兼容性、运行测试

何时使用

适用于:

  • 存在多个不相关的故障
  • 3 个以上测试文件因不同根因失败
  • 多个子系统独立损坏
  • 功能之间没有共享代码路径
  • 独立的重构任务

应避免:

  • 故障相互关联
  • 需要完整系统上下文
  • 智能体会干扰共享资源
  • 顺序执行很重要
  • 调试需要整体视角

决策框架

Are failures related?
├── Yes → Sequential debugging
└── No → Are resources shared?
    ├── Yes → Sequential or careful coordination
    └── No → Parallel dispatch suitable

实施模式

步骤 1:域识别

按受影响子系统对故障分组:

Failure Analysis:
├── approval-flow.test.ts → Approval subsystem
├── batch-completion.test.ts → Batch subsystem
├── abort-handler.test.ts → Abort subsystem
└── notification.test.ts → Notification subsystem

每个域成为一个智能体任务。

步骤 2:任务创建

为每个域定义:

## Agent Task: [Domain Name]

**Scope:** [Specific files/modules]

**Goal:** [Clear objective]

**Constraints:**
- Only modify files in [scope]
- Do NOT change [protected areas]
- Must maintain [invariants]

**Deliverable:**
- [ ] Tests passing
- [ ] Summary of changes
- [ ] Any discovered issues

步骤 3:并发调度

同时执行所有任务:

# Terminal 1
claude -p "Fix approval flow tests. Only modify files in src/approval/..."

# Terminal 2
claude -p "Fix batch completion tests. Only modify files in src/batch/..."

# Terminal 3
claude -p "Fix abort handler tests. Only modify files in src/abort/..."

步骤 4:整合

所有智能体完成后:

  1. 审查每个智能体的摘要
  2. 检查变更之间是否存在冲突
  3. 运行综合测试套件
  4. 如果兼容则合并变更
  5. 处理任何整合问题

有效的智能体提示

良好提示的特征

  • 聚焦:一个清晰的问题域
  • 自包含:包含理解所需的所有上下文
  • 受约束:对可更改内容有清晰边界
  • 可衡量:具体的成功标准

提示模板

You are fixing [specific domain] issues.

**Context:**
[Relevant background information]

**Files in scope:**
- src/domain/file1.ts
- src/domain/file2.ts
- tests/domain/*.test.ts

**Goal:**
Fix failing tests in [test file]

**Constraints:**
- Do NOT modify files outside scope
- Do NOT change [specific things]
- Maintain [specific invariants]

**Success criteria:**
- All tests in [file] pass
- No new test failures introduced
- Changes documented in summary

Provide a summary of changes when complete.

反模式

差 好
"Fix all the tests" "Fix agent-tool-abort.test.ts"
"Make it work" "Ensure approval flow handles null input"
"Update the code" "Modify only src/approval/*.ts"

资源协调

共享资源

如果智能体必须接触共享资源:

**Coordination rules:**
- Agent A: Read-only access to shared/config.ts
- Agent B: Write access to shared/config.ts (primary)
- Agent C: No access to shared/

Conflict resolution: Agent B's changes take precedence

文件锁定模式

对于关键文件:

  1. 智能体 A 先完成
  2. 合并智能体 A 的变更
  3. 向智能体 B 提供更新后的上下文
  4. 智能体 B 以全新状态继续

验证

调度前检查清单

  • 域确实独立
  • 无共享文件修改
  • 每个任务有清晰范围
  • 约束可防止干扰
  • 成功标准可衡量

调度后检查清单

  • 所有智能体任务已完成
  • 无冲突的文件变更
  • 综合测试通过
  • 集成测试通过
  • 未引入新问题

最佳实践

应做

  • 清晰定义域边界
  • 在提示中包含所有必要上下文
  • 设置明确约束
  • 要求每个智能体提供摘要
  • 合并后运行集成测试
  • 记录协调策略

不应做

  • 为相互关联的问题调度智能体
  • 允许重叠的文件修改
  • 跳过整合验证
  • 假设智能体不会冲突
  • 使用模糊的成功标准
  • 调度超过需要的智能体数量

错误处理

情况 操作
智能体接触错误文件 以更严格约束重新运行
智能体在共享文件上冲突 将这些任务顺序化
一个智能体失败 不阻塞其他,单独修复
集成测试失败 识别冲突,重新运行受影响部分

指标

指标 目标 描述
并行效率 >70% 相比顺序节省的时间
冲突率 <10% 智能体变更冲突
首次运行成功 >80% 任务无需重新运行即完成
集成通过率 >90% 合并后的变更正常工作

相关技能

  • subagent-driven - 顺序任务执行
  • multi-agent-patterns - 智能体架构
  • writing-plans - 任务规划

版本历史

1.0.0 (2026-01-19):初始版本,改编自 obra/superpowers