spec-review

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Spec 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.md
.
MANDATORY: Before accepting any rationalization for approving without full verification, consult
references/rationalization-refutation.md
. Every common excuse is catalogued with a counter-argument and the correct action.
两阶段审查的第一阶段:验证实现是否符合规范并遵循TDD。
完整示例可参考
references/worked-example.md
强制要求: 在接受任何未完全验证就批准的理由之前,请查阅
references/rationalization-refutation.md
。其中收录了所有常见借口的反驳论据及正确处理方式。

Triggers

触发条件

Activate this skill when:
  • User runs
    /review
    command (first stage)
  • 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
    exarchos_orchestrate({ action: "review_diff" })
    (context-efficient)
  • 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:
  1. Generate diff:
    exarchos_orchestrate({ action: "review_diff", worktreePath: "<worktree-path>", baseBranch: "main" })
  2. Pass diff content in the subagent dispatch prompt
  3. Include state file path for artifact resolution
Subagent responsibilities:
  1. Receive diff content from dispatch prompt (do NOT re-generate)
  2. Read state file for design/plan artifact paths
  3. Run verification commands against the working tree
  4. Return structured JSON verdict
编排器负责在调度规范审查子代理前生成差异文件。子代理不会自行生成差异。
编排器职责:
  1. 生成差异:
    exarchos_orchestrate({ action: "review_diff", worktreePath: "<worktree-path>", baseBranch: "main" })
  2. 在子代理调度提示中传递差异内容
  3. 包含状态文件路径以解析工件
子代理职责:
  1. 从调度提示接收差异内容(请勿重新生成)
  2. 读取状态文件获取设计/计划工件路径
  3. 针对工作树运行验证命令
  4. 返回结构化JSON格式的评审结论

Context-Efficient Input

上下文高效输入

Instead of per-worktree diffs, receive an integrated diff from the integration branch (e.g.,
feature/integration-branch
) against main:
bash
undefined
无需按工作树生成差异,可接收集成分支(如
feature/integration-branch
)与main分支的合并差异:
bash
undefined

Generate 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:
    exarchos_orchestrate({ action: "runbook", id: "review-strategy" })
    to determine the review approach based on diff scope, prior fix cycles, and review stage.
评估前,查询审查策略手册以确定合适的评估方法:
  • 评估策略: 执行
    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.md
.
Verification:
bash
npm run test:run
npm run test:coverage
npm run typecheck
typescript
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 typecheck
typescript
exarchos_orchestrate({
  action: "check_tdd_compliance",
  featureId: "<featureId>",
  taskId: "<taskId>",
  branch: "<branch>"
})

Fix Loop

修复循环

If review FAILS:
  1. Create fix task with specific issues
  2. Dispatch to implementer (same or new)
  3. Re-review after fixes
  4. Repeat until PASS
typescript
// Return to implementer
Task({
  model: "opus",
  description: "Fix spec review issues",
  prompt: `
若审查不通过:
  1. 创建包含具体问题的修复任务
  2. 派发给实现者(原实现者或新实现者)
  3. 修复完成后重新审查
  4. 重复直至通过
typescript
// 返回给实现者
Task({
  model: "opus",
  description: "Fix spec review issues",
  prompt: `

Fix Required: Spec Review Failed

需修复:规范审查未通过

Issues to Fix

待修复问题

  1. Missing rate limiting implementation
    • Add rate limiter middleware
    • Test: RateLimiter_ExceedsLimit_Returns429
  2. Email validation incomplete
    • Add MX record check
    • Test: ValidateEmail_InvalidDomain_ReturnsError
  1. 缺少限流实现
    • 添加限流中间件
    • 测试用例:RateLimiter_ExceedsLimit_Returns429
  2. 邮箱验证不完整
    • 添加MX记录检查
    • 测试用例:ValidateEmail_InvalidDomain_ReturnsError

Success Criteria

成功标准

  • All tests pass
  • Coverage >80%
  • All issues resolved ` })
undefined
  • 所有测试通过
  • 覆盖率>80%
  • 所有问题已解决 ` })
undefined

Required 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'tDo Instead
Skip to quality reviewComplete spec review first
Accept incomplete workReturn for fixes
Review code style hereSave for quality review
Approve without testsRequire test coverage
Let scope creep passFlag over-engineering
禁止操作正确做法
直接跳至质量审查先完成规范审查
接受未完成的工作返回要求修复
在此审查代码风格留到质量审查阶段
无测试就批准要求达到测试覆盖率
允许范围蔓延标记过度设计问题

Cross-Task Integration Issues

跨任务集成问题

If an issue spans multiple tasks:
  1. Classify as "cross-task integration"
  2. Create fix task specifying ALL affected tasks
  3. Dispatch fix to implementer with context from all affected tasks
  4. Mark original tasks as blocked until cross-task fix completes
若问题涉及多个任务:
  1. 归类为"跨任务集成"问题
  2. 创建修复任务并指定所有受影响的任务
  3. 将修复任务派发给实现者,并提供所有受影响任务的上下文
  4. 将原任务标记为阻塞,直至跨任务修复完成

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 a
status
field (e.g.,
{ "status": "pass" }
), not a flat string (e.g.,
"pass"
). The
all-reviews-passed
guard silently ignores non-object entries. Accepted statuses:
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.md
.
Quick reference:
  • review
    synthesize
    requires guard
    all-reviews-passed
    — all
    reviews.{name}.status
    must be passing
  • review
    delegate
    requires guard
    any-review-failed
    — triggers fix cycle when any review fails
完整的转换表请参考
@skills/workflow-state/references/phase-transitions.md
快速参考:
  • review
    synthesize
    需要
    all-reviews-passed
    守卫——所有
    reviews.{name}.status
    必须为通过状态
  • review
    delegate
    需要
    any-review-failed
    守卫——当任何审查未通过时触发修复循环

Schema Discovery

模式发现

Use
exarchos_workflow({ action: "describe", actions: ["set", "init"] })
for parameter schemas and
exarchos_workflow({ action: "describe", playbook: "feature" })
for phase transitions, guards, and playbook guidance. Use
exarchos_orchestrate({ action: "describe", actions: ["check_tdd_compliance", "check_static_analysis"] })
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"] })
获取编排操作的模式。

Transition

转换流程

All transitions happen immediately without user confirmation:
所有转换均立即进行,无需用户确认:

Pre-Chain Validation (MANDATORY)

预链验证(强制要求)

Before invoking quality-review:
  1. Verify
    reviews["spec-review"].status === "pass"
    in workflow state (all tasks passed)
  2. If not: "Spec review did not pass, cannot proceed to quality review"
Guard shape: The
all-reviews-passed
guard requires
reviews["spec-review"]
to be an object with a
status
field set to a passing value (
pass
,
passed
,
approved
,
fixes-applied
). Flat strings like
reviews: { "spec-review": "pass" }
are silently ignored and will block the
review → synthesize
transition.
调用quality-review前:
  1. 验证工作流状态中
    reviews["spec-review"].status === "pass"
    (所有任务均通过)
  2. 若未通过:"规范审查未通过,无法进入质量审查阶段"
守卫格式:
all-reviews-passed
守卫要求
reviews["spec-review"]
是包含
status
字段且值为通过状态(
pass
,
passed
,
approved
,
fixes-applied
)的对象。类似
reviews: { "spec-review": "pass" }
的扁平字符串会被静默忽略,并阻止
review → synthesize
转换。

If PASS:

若通过:

  1. Record results — the reviews value MUST be an object with a
    status
    field, not a flat string:
    exarchos_workflow({ action: "set", featureId: "<id>", updates: {
      reviews: { "spec-review": { status: "pass", summary: "...", issues: [] } }
    }})
  2. Output: "Spec review passed. Auto-continuing to quality review..."
  3. Orchestrator dispatches quality-review subagent immediately
Gate events: Do NOT manually emit
gate.executed
events via
exarchos_event
. Gate events are automatically emitted by the
check_review_verdict
orchestrate handler. Manual emission causes duplicates.
  1. 记录结果——审查值必须是包含
    status
    字段的对象,而非扁平字符串:
    exarchos_workflow({ action: "set", featureId: "<id>", updates: {
      reviews: { "spec-review": { status: "pass", summary: "...", issues: [] } }
    }})
  2. 输出:"规范审查通过。自动进入质量审查阶段..."
  3. 编排器立即调度quality-review子代理
网关事件: 请勿通过
exarchos_event
手动触发
gate.executed
事件。网关事件由
check_review_verdict
编排处理器自动触发。手动触发会导致重复事件。

If FAIL:

若未通过:

  1. 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: "..." }] } }
    }})
  2. Output: "Spec review found [N] issues. Auto-continuing to fixes..."
  3. 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.
  1. 记录包含未通过状态和问题详情的结果:
    exarchos_workflow({ action: "set", featureId: "<id>", updates: {
      reviews: { "spec-review": { status: "fail", summary: "...", issues: [{ severity: "HIGH", file: "...", description: "..." }] } }
    }})
  2. 输出:"规范审查发现[N]个问题。自动进入修复流程..."
  3. 自动调用委托功能创建修复任务:
    typescript
    [Invoke the exarchos:delegate skill with args: --fixes <plan-path>]
此流程无需人工干预——工作流将自动继续。

Troubleshooting

故障排查

IssueCauseResolution
Test file not foundTask didn't create expected testCheck plan for test file paths, verify worktree contents
Coverage below thresholdImplementation incomplete or tests superficialAdd missing test cases, verify assertions are meaningful
TDD compliance check failsImplementation committed before testsCheck git log order — test commits must precede or accompany implementation
Diff too large for contextMany tasks with large changesGenerate per-worktree diffs with
exarchos_orchestrate({ action: "review_diff", worktreePath: "<task-worktree>" })
to review incrementally
问题原因解决方法
测试文件未找到任务未创建预期的测试文件检查计划中的测试文件路径,验证工作树内容
覆盖率低于阈值实现不完整或测试过于表面添加缺失的测试用例,验证断言的有效性
TDD合规性检查失败实现代码先于测试代码提交检查git日志顺序——测试提交必须先于或伴随实现提交
差异过大超出上下文限制多个任务存在大量变更使用
exarchos_orchestrate({ action: "review_diff", worktreePath: "<task-worktree>" })
按工作树生成差异,逐步审查

Performance Notes

性能说明

  • Use the integrated diff (
    exarchos_orchestrate({ action: "review_diff" })
    ) instead of reading full files — reduces context by 80-90%
  • Review per-task when the combined diff exceeds 2,000 lines
  • Run TDD compliance check (
    exarchos_orchestrate({ action: "check_tdd_compliance" })
    ) in parallel with spec tracing
  • 使用合并差异(
    exarchos_orchestrate({ action: "review_diff" })
    )而非读取完整文件——将上下文消耗减少80-90%
  • 当合并差异超过2000行时,按任务分别审查
  • 并行运行TDD合规性检查(
    exarchos_orchestrate({ action: "check_tdd_compliance" })
    )与规范追踪