---
name: ultraqa
description: QA 循环工作流 - 测试、验证、修复，并重复直到达成目标
level: 3
---

# UltraQA 技能

[ULTRAQA 已激活 - 自主 QA 循环]

## 概述

你现在处于 **ULTRAQA** 模式，这是一种自主 QA 循环工作流，会一直运行直到你的质量目标达成。

**循环**: qa-tester → architect verification → fix → repeat

## 目标解析

从参数中解析目标。支持以下格式：

| Invocation | 目标类型 | 检查内容 |
|------------|-----------|----------|
| `/oh-my-claudecode:ultraqa --tests` | tests | 所有测试套件通过 |
| `/oh-my-claudecode:ultraqa --build` | build | 构建成功并以 exit 0 结束 |
| `/oh-my-claudecode:ultraqa --lint` | lint | 没有 lint 错误 |
| `/oh-my-claudecode:ultraqa --typecheck` | typecheck | 没有 TypeScript 错误 |
| `/oh-my-claudecode:ultraqa --custom "pattern"` | custom | 输出中出现自定义成功模式 |

如果没有提供结构化目标，则将该参数解释为自定义目标。

## 循环工作流

### 第 N 轮循环（最多 5 轮）

1. **运行 QA**: 根据目标类型执行验证
   - `--tests`: 运行项目的测试命令
   - `--build`: 运行项目的构建命令
   - `--lint`: 运行项目的 lint 命令
   - `--typecheck`: 运行项目的类型检查命令
   - `--custom`: 运行合适的命令并检查匹配模式
   - `--interactive`: 使用 `qa-tester` 进行交互式 CLI/服务测试：
     ```
     Task(subagent_type="oh-my-claudecode:qa-tester", model="sonnet", prompt="TEST:
     Goal: [describe what to verify]
     Service: [how to start]
     Test cases: [specific scenarios to verify]")
     ```

2. **检查结果**: 目标是否通过？
   - **YES** → 以成功消息退出
   - **NO** → 继续到步骤 3

3. **ARCHITECT 诊断**: 启动 architect 分析失败原因
   ```
   Task(subagent_type="oh-my-claudecode:architect", model="opus", prompt="DIAGNOSE FAILURE:
   Goal: [goal type]
   Output: [test/build output]
   Provide root cause and specific fix recommendations.")
   ```

4. **修复问题**: 应用 architect 的建议
   ```
   Task(subagent_type="oh-my-claudecode:executor", model="sonnet", prompt="FIX:
   Issue: [architect diagnosis]
   Files: [affected files]
   Apply the fix precisely as recommended.")
   ```

5. **重复**: 回到步骤 1

## 退出条件

| 条件 | 操作 |
|-----------|--------|
| **目标达成** | 以成功状态退出: `"ULTRAQA COMPLETE: Goal met after N cycles"` |
| **达到第 5 轮循环** | 输出诊断后退出: `"ULTRAQA STOPPED: Max cycles. Diagnosis: ..."` |
| **同一失败出现 3 次** | 提前退出: `"ULTRAQA STOPPED: Same failure detected 3 times. Root cause: ..."` |
| **环境错误** | 退出: `"ULTRAQA ERROR: [tmux/port/dependency issue]"` |

## 可观测性

每轮循环输出进度：
```
[ULTRAQA Cycle 1/5] Running tests...
[ULTRAQA Cycle 1/5] FAILED - 3 tests failing
[ULTRAQA Cycle 1/5] Architect diagnosing...
[ULTRAQA Cycle 1/5] Fixing: auth.test.ts - missing mock
[ULTRAQA Cycle 2/5] Running tests...
[ULTRAQA Cycle 2/5] PASSED - All 47 tests pass
[ULTRAQA COMPLETE] Goal met after 2 cycles
```

## 状态跟踪

在 `.omc/ultraqa-state.json` 中跟踪状态：
```json
{
  "active": true,
  "goal_type": "tests",
  "goal_pattern": null,
  "cycle": 1,
  "max_cycles": 5,
  "failures": ["3 tests failing: auth.test.ts"],
  "started_at": "2024-01-18T12:00:00Z",
  "session_id": "uuid"
}
```

## 取消

用户可以使用 `/oh-my-claudecode:cancel` 取消，这会清理状态文件。

## 重要规则

1. **尽可能并行** - 在准备潜在修复的同时运行诊断
2. **跟踪失败** - 记录每次失败以发现模式
3. **模式早退** - 同一失败出现 3 次 = 停止并输出原因
4. **输出清晰** - 用户应始终知道当前轮次和状态
5. **清理** - 在完成或取消时清理状态文件

## 完成时清理状态

**重要：完成时删除状态文件，不要只设置 `active: false`**

当目标达成、达到最大循环次数或提前退出时：

```bash
# Delete ultraqa state file
rm -f .omc/state/ultraqa-state.json
```

这样可以确保未来会话拥有干净的状态。不应保留 `active: false` 的陈旧状态文件。

---

现在开始 ULTRAQA 循环。解析目标并启动第 1 轮。
