---
name: ultrawork
description: 用于高吞吐任务完成的并行执行引擎
level: 4
---

<Purpose>
Ultrawork 是一个并行执行引擎，用于同时运行多个代理以处理彼此独立的任务。它是一个组件，而不是独立的持久化模式 -- 它提供并行能力和智能模型路由，但不提供持久化、验证循环或状态管理。
</Purpose>

<Use_When>
- 多个独立任务可以同时运行
- 用户提到 "ulw"、"ultrawork"，或希望进行并行执行
- 你需要一次性将工作委派给多个代理
- 任务适合并发执行，但用户会自行管理完成过程
</Use_When>

<Do_Not_Use_When>
- 任务需要带验证的完成保证 -- 改用 `ralph`（`ralph` 包含 `ultrawork`）
- 任务需要完整的自主执行流水线 -- 改用 `autopilot`（`autopilot` 包含 `ralph`，而 `ralph` 又包含 `ultrawork`）
- 只有一个顺序执行的任务，没有并行空间 -- 直接委派给 executor 代理
- 用户需要可恢复的会话持久化 -- 使用 `ralph`，它在 `ultrawork` 之上增加了持久化能力
</Do_Not_Use_When>

<Why_This_Exists>
当任务彼此独立时，顺序执行会浪费时间。Ultrawork 允许同时触发多个代理，并将每个任务路由到合适的模型层级，在控制 token 成本的同时缩短总体执行时间。它被设计为一个可组合的组件，供 `ralph` 和 `autopilot` 在其之上进行封装。
</Why_This_Exists>

<Execution_Policy>
- 同时发起所有独立的代理调用 -- 绝不要将独立工作串行化
- 委派时始终显式传递 `model` 参数
- 首次委派前先阅读 `docs/shared/agent-tiers.md`，获取代理选择指导
- 对超过约 30 秒的操作（安装、构建、测试）使用 `run_in_background: true`
- 对快速命令（`git status`、文件读取、简单检查）使用前台执行
</Execution_Policy>

<Steps>
1. **读取代理参考**：加载 `docs/shared/agent-tiers.md` 以进行层级选择
2. **按独立性分类任务**：识别哪些任务可以并行运行，哪些任务存在依赖
3. **路由到正确层级**：
   - 简单查询/定义：LOW 层级（Haiku）
   - 标准实现：MEDIUM 层级（Sonnet）
   - 复杂分析/重构：HIGH 层级（Opus）
4. **同时发起独立任务**：一次性启动所有适合并行的任务
5. **顺序运行依赖任务**：等待前置条件完成后再启动依赖性工作
6. **将长时间操作放入后台**：构建、安装和测试套件使用 `run_in_background: true`
7. **在所有任务完成后进行验证**（轻量级）：
   - 构建/类型检查通过
   - 受影响的测试通过
   - 没有引入新的错误
</Steps>

<Tool_Usage>
- 对简单改动使用 `Task(subagent_type="oh-my-claudecode:executor", model="haiku", ...)`
- 对标准工作使用 `Task(subagent_type="oh-my-claudecode:executor", model="sonnet", ...)`
- 对复杂工作使用 `Task(subagent_type="oh-my-claudecode:executor", model="opus", ...)`
- 对包安装、构建和测试套件使用 `run_in_background: true`
- 对快速状态检查和文件操作使用前台执行
</Tool_Usage>

<Examples>
<Good>
同时发起三个独立任务：
```
Task(subagent_type="oh-my-claudecode:executor", model="haiku", prompt="Add missing type export for Config interface")
Task(subagent_type="oh-my-claudecode:executor", model="sonnet", prompt="Implement the /api/users endpoint with validation")
Task(subagent_type="oh-my-claudecode:executor", model="sonnet", prompt="Add integration tests for the auth middleware")
```
为什么这样好：独立任务被分配到合适的层级，并且全部一次性发起。
</Good>

<Good>
正确使用后台执行：
```
Task(subagent_type="oh-my-claudecode:executor", model="sonnet", prompt="npm install && npm run build", run_in_background=true)
Task(subagent_type="oh-my-claudecode:executor", model="haiku", prompt="Update the README with new API endpoints")
```
为什么这样好：耗时较长的构建在后台运行，而短任务在前台运行。
</Good>

<Bad>
将独立工作顺序执行：
```
result1 = Task(executor, "Add type export")  # wait...
result2 = Task(executor, "Implement endpoint")     # wait...
result3 = Task(executor, "Add tests")              # wait...
```
为什么这样不好：这些任务彼此独立。顺序运行会浪费时间。
</Bad>

<Bad>
错误的层级选择：
```
Task(subagent_type="oh-my-claudecode:executor", model="opus", prompt="Add a missing semicolon")
```
为什么这样不好：对于一个微不足道的修复，Opus 成本过高、属于过度使用。应改用搭配 Haiku 的 executor。
</Bad>
</Examples>

<Escalation_And_Stop_Conditions>
- 当直接调用 ultrawork（而不是通过 ralph）时，只做轻量级验证 -- 构建通过、测试通过、没有新增错误
- 若需要完整持久化和全面的架构验证，建议切换到 `ralph` 模式
- 如果某个任务在多次重试后仍持续失败，应报告问题，而不是无限重试
- 当任务依赖关系不明确或需求相互冲突时，应升级给用户处理
</Escalation_And_Stop_Conditions>

<Final_Checklist>
- [ ] 所有并行任务均已完成
- [ ] 构建/类型检查通过
- [ ] 受影响的测试通过
- [ ] 没有引入新的错误
</Final_Checklist>

<Advanced>
## 与其他模式的关系

```
ralph (persistence wrapper)
 \-- includes: ultrawork (this skill)
     \-- provides: parallel execution only

autopilot (autonomous execution)
 \-- includes: ralph
     \-- includes: ultrawork (this skill)
```

Ultrawork 是并行层。Ralph 增加了持久化和验证。Autopilot 增加了完整的生命周期流水线。
</Advanced>
