spec-review
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseSpec Review Skill
规范审查Skill
Overview
概述
Stage 1 of two-stage review: Verify implementation matches specification and follows TDD.
For a complete worked example, see .
references/worked-example.mdMANDATORY: Before accepting any rationalization for approving without full verification, consult. Every common excuse is catalogued with a counter-argument and the correct action.references/rationalization-refutation.md
两阶段审查的第一阶段:验证实现是否符合规范并遵循TDD。
完整示例可参考。
references/worked-example.md强制要求: 在接受任何未完全验证就批准的理由之前,请查阅。其中收录了所有常见借口的反驳论据及正确处理方式。references/rationalization-refutation.md
Triggers
触发条件
Activate this skill when:
- User runs command (first stage)
/review - Task implementation is complete
- Need to verify spec compliance before quality review
- Subagent reports task completion
在以下场景激活此Skill:
- 用户执行命令(第一阶段)
/review - 任务实现已完成
- 需要在质量审查前验证规范合规性
- 子代理(Subagent)报告任务完成
Execution Context
执行上下文
This skill runs in a SUBAGENT spawned by the orchestrator, not inline.
The orchestrator provides:
- State file path (preferred) OR design/plan paths
- Diff output from (context-efficient)
exarchos_orchestrate({ action: "review_diff" }) - Task ID being reviewed
The subagent:
- Reads state file to get artifact paths
- Uses diff output instead of reading full files
- Runs verification commands
- Generates report
- Returns verdict to orchestrator
此Skill在由编排器(orchestrator)生成的SUBAGENT中运行,而非内联执行。
编排器提供:
- 状态文件路径(首选)或设计/计划路径
- 来自的差异输出(上下文高效)
exarchos_orchestrate({ action: "review_diff" }) - 待审查的任务ID
子代理:
- 读取状态文件获取工件路径
- 使用差异输出而非读取完整文件
- 运行验证命令
- 生成报告
- 向编排器返回评审结论
Data Handoff Protocol
数据交接协议
The orchestrator is responsible for generating the diff before dispatching the spec-review subagent. The subagent does NOT generate its own diff.
Orchestrator responsibilities:
- Generate diff:
exarchos_orchestrate({ action: "review_diff", worktreePath: "<worktree-path>", baseBranch: "main" }) - Pass diff content in the subagent dispatch prompt
- Include state file path for artifact resolution
Subagent responsibilities:
- Receive diff content from dispatch prompt (do NOT re-generate)
- Read state file for design/plan artifact paths
- Run verification commands against the working tree
- Return structured JSON verdict
编排器负责在调度规范审查子代理前生成差异文件。子代理不会自行生成差异。
编排器职责:
- 生成差异:
exarchos_orchestrate({ action: "review_diff", worktreePath: "<worktree-path>", baseBranch: "main" }) - 在子代理调度提示中传递差异内容
- 包含状态文件路径以解析工件
子代理职责:
- 从调度提示接收差异内容(请勿重新生成)
- 读取状态文件获取设计/计划工件路径
- 针对工作树运行验证命令
- 返回结构化JSON格式的评审结论
Context-Efficient Input
上下文高效输入
Instead of per-worktree diffs, receive an integrated diff from the
integration branch (e.g., ) against main:
feature/integration-branchbash
undefined无需按工作树生成差异,可接收集成分支(如)与main分支的合并差异:
feature/integration-branchbash
undefinedGenerate integrated diff for review
生成用于审查的合并差异
git diff main...integration > /tmp/combined-diff.patch
git diff main...integration > /tmp/combined-diff.patch
Alternative: use review-diff script against integration branch via orchestrate
替代方案:通过orchestrate针对集成分支使用review-diff脚本
exarchos_orchestrate({ action: "review_diff", worktreePath: "<worktree-path>", baseBranch: "main" })
exarchos_orchestrate({ action: "review_diff", worktreePath: "<worktree-path>", baseBranch: "main" })
This provides the complete picture of all changes across all tasks and reduces context consumption by 80-90%.
这能呈现所有任务的完整变更情况,将上下文消耗减少80-90%。Pre-Review Schema Discovery
审查前模式发现
Before evaluating, query the review strategy runbook to determine the appropriate evaluation approach:
- Evaluation strategy: to determine the review approach based on diff scope, prior fix cycles, and review stage.
exarchos_orchestrate({ action: "runbook", id: "review-strategy" })
评估前,查询审查策略手册以确定合适的评估方法:
- 评估策略: 执行,根据差异范围、之前的修复周期和审查阶段确定审查方法。
exarchos_orchestrate({ action: "runbook", id: "review-strategy" })
Review Scope
审查范围
Review Scope: Combined Changes
审查范围:合并变更
After delegation completes, spec review examines:
- The complete integrated diff (main...feature/integration branch)
- All changes across all tasks in one view
- The full picture of combined functionality
This enables catching:
- Cross-task interface mismatches
- Bugs not visible in isolation
- Combined behavior vs specification
Spec Review focuses on:
- Functional completeness
- TDD compliance
- Specification alignment
- Test coverage
Does NOT cover (that's Quality Review):
- Code style
- SOLID principles
- Performance optimization
- Error handling elegance
任务委托完成后,规范审查将检查:
- 完整的合并差异(main...feature/integration分支)
- 所有任务的全部变更,统一查看
- 合并功能的完整情况
这有助于发现:
- 跨任务接口不匹配问题
- 孤立查看时无法发现的Bug
- 合并行为与规范的一致性
规范审查重点:
- 功能完整性
- TDD合规性
- 规范一致性
- 测试覆盖率
不包含的内容(属于质量审查范畴):
- 代码风格
- SOLID原则
- 性能优化
- 错误处理的优雅性
Review Checklist
审查清单
For the full checklist with verification commands, tables, and report template, see .
references/review-checklist.mdVerification:
bash
npm run test:run
npm run test:coverage
npm run typechecktypescript
exarchos_orchestrate({
action: "check_tdd_compliance",
featureId: "<featureId>",
taskId: "<taskId>",
branch: "<branch>"
})包含验证命令、表格和报告模板的完整清单,请参考。
references/review-checklist.md验证命令:
bash
npm run test:run
npm run test:coverage
npm run typechecktypescript
exarchos_orchestrate({
action: "check_tdd_compliance",
featureId: "<featureId>",
taskId: "<taskId>",
branch: "<branch>"
})Fix Loop
修复循环
If review FAILS:
- Create fix task with specific issues
- Dispatch to implementer (same or new)
- Re-review after fixes
- Repeat until PASS
typescript
// Return to implementer
Task({
model: "opus",
description: "Fix spec review issues",
prompt: `若审查不通过:
- 创建包含具体问题的修复任务
- 派发给实现者(原实现者或新实现者)
- 修复完成后重新审查
- 重复直至通过
typescript
// 返回给实现者
Task({
model: "opus",
description: "Fix spec review issues",
prompt: `Fix Required: Spec Review Failed
需修复:规范审查未通过
Issues to Fix
待修复问题
-
Missing rate limiting implementation
- Add rate limiter middleware
- Test: RateLimiter_ExceedsLimit_Returns429
-
Email validation incomplete
- Add MX record check
- Test: ValidateEmail_InvalidDomain_ReturnsError
-
缺少限流实现
- 添加限流中间件
- 测试用例:RateLimiter_ExceedsLimit_Returns429
-
邮箱验证不完整
- 添加MX记录检查
- 测试用例:ValidateEmail_InvalidDomain_ReturnsError
Success Criteria
成功标准
- All tests pass
- Coverage >80%
- All issues resolved ` })
undefined- 所有测试通过
- 覆盖率>80%
- 所有问题已解决 ` })
undefinedRequired Output Format
要求的输出格式
The subagent MUST return results as structured JSON. The orchestrator parses this JSON to populate state. Any other format is an error.
json
{
"verdict": "pass | fail | blocked",
"summary": "1-2 sentence summary",
"issues": [
{
"severity": "HIGH | MEDIUM | LOW",
"category": "spec | tdd | coverage",
"file": "path/to/file",
"line": 123,
"description": "Issue description",
"required_fix": "What must change"
}
],
"test_results": {
"passed": 0,
"failed": 0,
"coverage_percent": 0
}
}子代理必须以结构化JSON格式返回结果。编排器会解析此JSON以更新状态。任何其他格式均视为错误。
json
{
"verdict": "pass | fail | blocked",
"summary": "1-2句话的摘要",
"issues": [
{
"severity": "HIGH | MEDIUM | LOW",
"category": "spec | tdd | coverage",
"file": "path/to/file",
"line": 123,
"description": "问题描述",
"required_fix": "必须修改的内容"
}
],
"test_results": {
"passed": 0,
"failed": 0,
"coverage_percent": 0
}
}Anti-Patterns
反模式
| Don't | Do Instead |
|---|---|
| Skip to quality review | Complete spec review first |
| Accept incomplete work | Return for fixes |
| Review code style here | Save for quality review |
| Approve without tests | Require test coverage |
| Let scope creep pass | Flag over-engineering |
| 禁止操作 | 正确做法 |
|---|---|
| 直接跳至质量审查 | 先完成规范审查 |
| 接受未完成的工作 | 返回要求修复 |
| 在此审查代码风格 | 留到质量审查阶段 |
| 无测试就批准 | 要求达到测试覆盖率 |
| 允许范围蔓延 | 标记过度设计问题 |
Cross-Task Integration Issues
跨任务集成问题
If an issue spans multiple tasks:
- Classify as "cross-task integration"
- Create fix task specifying ALL affected tasks
- Dispatch fix to implementer with context from all affected tasks
- Mark original tasks as blocked until cross-task fix completes
若问题涉及多个任务:
- 归类为"跨任务集成"问题
- 创建修复任务并指定所有受影响的任务
- 将修复任务派发给实现者,并提供所有受影响任务的上下文
- 将原任务标记为阻塞,直至跨任务修复完成
State Management
状态管理
On Review Complete
审查完成后
Pass:
action: "set", featureId: "<id>", updates: {
"reviews": { "spec-review": { "status": "pass", "summary": "...", "issues": [] } }
}Fail:
action: "set", featureId: "<id>", updates: {
"reviews": { "spec-review": { "status": "fail", "summary": "...", "issues": [{ "severity": "...", "file": "...", "description": "..." }] } }
}Important: The review value MUST be an object with afield (e.g.,status), not a flat string (e.g.,{ "status": "pass" }). The"pass"guard silently ignores non-object entries. Accepted statuses:all-reviews-passed,pass,passed,approved.fixes-applied
通过:
action: "set", featureId: "<id>", updates: {
"reviews": { "spec-review": { "status": "pass", "summary": "...", "issues": [] } }
}未通过:
action: "set", featureId: "<id>", updates: {
"reviews": { "spec-review": { "status": "fail", "summary": "...", "issues": [{ "severity": "...", "file": "...", "description": "..." }] } }
}重要提示: 审查结果必须是包含字段的对象(例如status),而非扁平字符串(例如{ "status": "pass" })。"pass"守卫会静默忽略非对象条目。认可的状态值包括:all-reviews-passed,pass,passed,approved。fixes-applied
Phase Transitions and Guards
阶段转换与守卫
For the full transition table, consult .
@skills/workflow-state/references/phase-transitions.mdQuick reference:
- →
reviewrequires guardsynthesize— allall-reviews-passedmust be passingreviews.{name}.status - →
reviewrequires guarddelegate— triggers fix cycle when any review failsany-review-failed
完整的转换表请参考。
@skills/workflow-state/references/phase-transitions.md快速参考:
- →
review需要synthesize守卫——所有all-reviews-passed必须为通过状态reviews.{name}.status - →
review需要delegate守卫——当任何审查未通过时触发修复循环any-review-failed
Schema Discovery
模式发现
Use for
parameter schemas and
for phase transitions, guards, and playbook guidance. Use
for orchestrate action schemas.
exarchos_workflow({ action: "describe", actions: ["set", "init"] })exarchos_workflow({ action: "describe", playbook: "feature" })exarchos_orchestrate({ action: "describe", actions: ["check_tdd_compliance", "check_static_analysis"] })使用获取参数模式,使用获取阶段转换、守卫和手册指南。使用获取编排操作的模式。
exarchos_workflow({ action: "describe", actions: ["set", "init"] })exarchos_workflow({ action: "describe", playbook: "feature" })exarchos_orchestrate({ action: "describe", actions: ["check_tdd_compliance", "check_static_analysis"] })Transition
转换流程
All transitions happen immediately without user confirmation:
所有转换均立即进行,无需用户确认:
Pre-Chain Validation (MANDATORY)
预链验证(强制要求)
Before invoking quality-review:
- Verify in workflow state (all tasks passed)
reviews["spec-review"].status === "pass" - If not: "Spec review did not pass, cannot proceed to quality review"
Guard shape: Theguard requiresall-reviews-passedto be an object with areviews["spec-review"]field set to a passing value (status,pass,passed,approved). Flat strings likefixes-appliedare silently ignored and will block thereviews: { "spec-review": "pass" }transition.review → synthesize
调用quality-review前:
- 验证工作流状态中(所有任务均通过)
reviews["spec-review"].status === "pass" - 若未通过:"规范审查未通过,无法进入质量审查阶段"
守卫格式:守卫要求all-reviews-passed是包含reviews["spec-review"]字段且值为通过状态(status,pass,passed,approved)的对象。类似fixes-applied的扁平字符串会被静默忽略,并阻止reviews: { "spec-review": "pass" }转换。review → synthesize
If PASS:
若通过:
- Record results — the reviews value MUST be an object with a field, not a flat string:
statusexarchos_workflow({ action: "set", featureId: "<id>", updates: { reviews: { "spec-review": { status: "pass", summary: "...", issues: [] } } }}) - Output: "Spec review passed. Auto-continuing to quality review..."
- Orchestrator dispatches quality-review subagent immediately
Gate events: Do NOT manually emitevents viagate.executed. Gate events are automatically emitted by theexarchos_eventorchestrate handler. Manual emission causes duplicates.check_review_verdict
- 记录结果——审查值必须是包含字段的对象,而非扁平字符串:
statusexarchos_workflow({ action: "set", featureId: "<id>", updates: { reviews: { "spec-review": { status: "pass", summary: "...", issues: [] } } }}) - 输出:"规范审查通过。自动进入质量审查阶段..."
- 编排器立即调度quality-review子代理
网关事件: 请勿通过手动触发exarchos_event事件。网关事件由gate.executed编排处理器自动触发。手动触发会导致重复事件。check_review_verdict
If FAIL:
若未通过:
- Record results with failing status and issue details:
exarchos_workflow({ action: "set", featureId: "<id>", updates: { reviews: { "spec-review": { status: "fail", summary: "...", issues: [{ severity: "HIGH", file: "...", description: "..." }] } } }}) - Output: "Spec review found [N] issues. Auto-continuing to fixes..."
- Auto-invoke delegate with fix tasks:
typescript
[Invoke the exarchos:delegate skill with args: --fixes <plan-path>]
This is NOT a human checkpoint - workflow continues autonomously.
- 记录包含未通过状态和问题详情的结果:
exarchos_workflow({ action: "set", featureId: "<id>", updates: { reviews: { "spec-review": { status: "fail", summary: "...", issues: [{ severity: "HIGH", file: "...", description: "..." }] } } }}) - 输出:"规范审查发现[N]个问题。自动进入修复流程..."
- 自动调用委托功能创建修复任务:
typescript
[Invoke the exarchos:delegate skill with args: --fixes <plan-path>]
此流程无需人工干预——工作流将自动继续。
Troubleshooting
故障排查
| Issue | Cause | Resolution |
|---|---|---|
| Test file not found | Task didn't create expected test | Check plan for test file paths, verify worktree contents |
| Coverage below threshold | Implementation incomplete or tests superficial | Add missing test cases, verify assertions are meaningful |
| TDD compliance check fails | Implementation committed before tests | Check git log order — test commits must precede or accompany implementation |
| Diff too large for context | Many tasks with large changes | Generate per-worktree diffs with |
| 问题 | 原因 | 解决方法 |
|---|---|---|
| 测试文件未找到 | 任务未创建预期的测试文件 | 检查计划中的测试文件路径,验证工作树内容 |
| 覆盖率低于阈值 | 实现不完整或测试过于表面 | 添加缺失的测试用例,验证断言的有效性 |
| TDD合规性检查失败 | 实现代码先于测试代码提交 | 检查git日志顺序——测试提交必须先于或伴随实现提交 |
| 差异过大超出上下文限制 | 多个任务存在大量变更 | 使用 |
Performance Notes
性能说明
- Use the integrated diff () instead of reading full files — reduces context by 80-90%
exarchos_orchestrate({ action: "review_diff" }) - Review per-task when the combined diff exceeds 2,000 lines
- Run TDD compliance check () in parallel with spec tracing
exarchos_orchestrate({ action: "check_tdd_compliance" })
- 使用合并差异()而非读取完整文件——将上下文消耗减少80-90%
exarchos_orchestrate({ action: "review_diff" }) - 当合并差异超过2000行时,按任务分别审查
- 并行运行TDD合规性检查()与规范追踪
exarchos_orchestrate({ action: "check_tdd_compliance" })