review

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

/review - Comprehensive Code Review

/review - 全面代码审查

Description

描述

Full-spectrum code review using parallel specialist sub-agents. Each specialist analyzes a specific dimension, findings are aggregated, and
/qa-gate
produces the final gate decision.
Key Features:
  • Parallel specialist sub-agents for thorough analysis
  • Requirements traceability (AC → tests mapping)
  • Active refactoring when safe
  • Technical debt identification
  • Holistic findings aggregation
  • Automatic gate decision via
    /qa-gate
通过并行专项子代理开展全维度代码审查。每个专项代理负责分析特定维度,审查结果会被汇总,最终由
/qa-gate
给出准入决策。
核心特性:
  • 并行专项子代理,确保审查全面深入
  • 需求可追溯性(验收标准→测试用例映射)
  • 安全前提下主动重构代码
  • 识别技术债务
  • 全维度审查结果汇总
  • 通过
    /qa-gate
    自动生成准入决策

Usage

使用方法

bash
undefined
bash
undefined

Review a single story by number

根据需求编号审查单个需求

/review 3.1.5
/review 3.1.5

Review a single story by file path

根据文件路径审查单个需求

/review docs/stories/epic-6-wishlist/wish-2002-add-item-flow.md
/review docs/stories/epic-6-wishlist/wish-2002-add-item-flow.md

Review current branch (no story)

审查当前分支(无关联需求)

/review --branch
/review --branch

Review all stories in an epic directory (shorthand)

审查某史诗目录下的所有需求(简写形式)

/review epic-6-wishlist
/review epic-6-wishlist

Review all stories in a directory (full path)

审查某目录下的所有需求(完整路径)

/review docs/stories/epic-6-wishlist/
/review docs/stories/epic-6-wishlist/

Review directory, only stories with specific status

审查目录下指定状态的需求

/review epic-6-wishlist --status=Draft
/review epic-6-wishlist --status=Draft

Quick review (skip deep specialists)

快速审查(跳过深度专项代理)

/review 3.1.5 --quick
/review 3.1.5 --quick

Review with auto-fix enabled

启用自动修复功能进行审查

/review 3.1.5 --fix
/review 3.1.5 --fix

Review specific files only

仅审查指定文件

/review --files src/auth/**/*.ts
/review --files src/auth/**/*.ts

Skip gate decision (findings only)

跳过准入决策(仅生成审查结果)

/review 3.1.5 --no-gate
undefined
/review 3.1.5 --no-gate
undefined

Parameters

参数

  • target - Story number (e.g.,
    3.1.5
    ), story file path, epic directory name (e.g.,
    epic-6-wishlist
    ), or full directory path
  • --branch - Review current branch without story reference
  • --status - Filter stories by status (e.g.,
    Draft
    ,
    In Progress
    ,
    Approved
    ) - only used with directory review
  • --quick - Run only required checks, skip deep specialists
  • --fix - Auto-fix issues when safe (refactoring)
  • --files - Review specific files only
  • --no-gate - Skip
    /qa-gate
    call, return findings only

  • target - 需求编号(如
    3.1.5
    )、需求文件路径、史诗目录名称(如
    epic-6-wishlist
    )或完整目录路径
  • --branch - 无需求关联时,审查当前分支
  • --status - 按状态过滤需求(如
    Draft
    In Progress
    Approved
    )- 仅在目录审查模式下生效
  • --quick - 仅运行必要检查,跳过深度专项代理
  • --fix - 安全前提下自动修复问题(重构代码)
  • --files - 仅审查指定文件
  • --no-gate - 跳过
    /qa-gate
    调用,仅返回审查结果

EXECUTION INSTRUCTIONS

执行说明

CRITICAL: Use Task tool to spawn parallel sub-agents. Use TodoWrite to track progress.

重要提示:使用Task工具生成并行子代理。使用TodoWrite跟踪进度。

Phase 0: Initialize & Determine Mode

阶段0:初始化与模式确定

Auto-detect operation mode based on target argument:
python
undefined
根据target参数自动检测操作模式:
python
undefined

Detection logic:

检测逻辑:

if target is None or target == "--branch": mode = "branch_review" elif target.endswith(".md"): mode = "single_story" # File path to specific story elif is_directory(target) or target.startswith("epic-"): mode = "directory_review" elif is_story_number(target): # e.g., "3.1.5" or "2002" mode = "single_story" else: # Try to resolve as story number, fall back to directory mode = "single_story"
undefined
if target is None or target == "--branch": mode = "branch_review" elif target.endswith(".md"): mode = "single_story" # 指向特定需求的文件路径 elif is_directory(target) or target.startswith("epic-"): mode = "directory_review" elif is_story_number(target): # 例如 "3.1.5" 或 "2002" mode = "single_story" else: # 尝试解析为需求编号,失败则默认目录审查 mode = "single_story"
undefined

Mode A: Single Story Review (default)

模式A:单个需求审查(默认)

Triggered by:
  • Story number (e.g.,
    3.1.5
    ,
    2002
    )
  • Story file path (e.g.,
    docs/stories/epic-6-wishlist/wish-2002-add-item-flow.md
    )
  • --branch
    flag
触发场景:
  • 需求编号(如
    3.1.5
    2002
  • 需求文件路径(如
    docs/stories/epic-6-wishlist/wish-2002-add-item-flow.md
  • --branch
    标志

Mode B: Directory Review (new)

模式B:目录审查(新增)

Triggered by:
  • Epic directory name (e.g.,
    epic-6-wishlist
    ) - auto-prepends
    docs/stories/
  • Full directory path (e.g.,
    docs/stories/epic-6-wishlist/
    )
  • Any path that resolves to a directory containing
    .md
    files
TodoWrite([
  { content: "Scan directory for stories", status: "in_progress", activeForm: "Scanning directory" },
  { content: "Filter stories by status", status: "pending", activeForm: "Filtering stories" },
  { content: "Review each story sequentially", status: "pending", activeForm: "Reviewing stories" },
  { content: "Generate summary report", status: "pending", activeForm: "Generating summary" }
])
Directory scanning:
  1. Resolve directory path:
    • If starts with
      epic-
      : prepend
      docs/stories/
      docs/stories/epic-6-wishlist/
    • If full path provided: use as-is
    • If relative path: resolve from working directory
  2. Verify directory exists, error if not
  3. Find all
    .md
    files in directory:
    Glob(pattern: "*.md", path: {DIR_PATH})
  4. Filter out excluded files/directories:
    • Skip files in
      _legacy/
      subdirectories
    • Skip
      IMPLEMENTATION_ORDER.md
    • Skip
      README.md
    • Skip any file starting with
      EPIC-
      (epic definition files)
  5. For each remaining file, read and extract:
    • Frontmatter (if present)
    • Status field (from frontmatter or
      status:
      line in file)
  6. If
    --status
    filter provided, only include stories where status matches
  7. Sort stories by filename (natural sort order)
  8. Create todo list with one item per story
Proceed to Phase 0A for single story or Phase 0B for directory.

触发场景:
  • 史诗目录名称(如
    epic-6-wishlist
    )- 自动补全前缀
    docs/stories/
    docs/stories/epic-6-wishlist/
  • 完整目录路径(如
    docs/stories/epic-6-wishlist/
  • 任何指向包含
    .md
    文件的目录路径
TodoWrite([
  { content: "扫描目录中的需求", status: "in_progress", activeForm: "正在扫描目录" },
  { content: "按状态过滤需求", status: "pending", activeForm: "正在过滤需求" },
  { content: "依次审查每个需求", status: "pending", activeForm: "正在审查需求" },
  { content: "生成汇总报告", status: "pending", activeForm: "正在生成汇总报告" }
])
目录扫描流程:
  1. 解析目录路径:
    • 若以
      epic-
      开头:添加前缀
      docs/stories/
      docs/stories/epic-6-wishlist/
    • 若提供完整路径:直接使用
    • 若为相对路径:基于工作目录解析
  2. 验证目录是否存在,不存在则抛出错误
  3. 查找目录下所有
    .md
    文件:
    Glob(pattern: "*.md", path: {DIR_PATH})
  4. 过滤排除文件/目录:
    • 跳过
      _legacy/
      子目录下的文件
    • 跳过
      IMPLEMENTATION_ORDER.md
    • 跳过
      README.md
    • 跳过所有以
      EPIC-
      开头的文件(史诗定义文件)
  5. 对剩余每个文件,读取并提取:
    • 前置元数据(若存在)
    • 状态字段(来自前置元数据或文件中的
      status:
      行)
  6. 若提供
    --status
    过滤条件,仅保留状态匹配的需求
  7. 按文件名自然排序需求
  8. 为每个需求创建待办事项
单个需求审查进入阶段0A,目录审查进入阶段0B。

Phase 0A: Gather Context (Single Story)

阶段0A:收集上下文(单个需求)

For single story review:
TodoWrite([
  { content: "Gather review context", status: "in_progress", activeForm: "Gathering context" },
  { content: "Run required checks", status: "pending", activeForm: "Running checks" },
  { content: "Spawn specialist sub-agents", status: "pending", activeForm: "Spawning specialists" },
  { content: "Aggregate findings", status: "pending", activeForm: "Aggregating findings" },
  { content: "Run qa-gate", status: "pending", activeForm: "Running qa-gate" },
  { content: "Update story file", status: "pending", activeForm: "Updating story" }
])
Gather context:
  1. If story provided, read story file and extract:
    • Acceptance criteria
    • Tasks list
    • File list (if present)
    • Previous QA results
  2. Get list of changed files:
    git diff --name-only origin/main
  3. Read CLAUDE.md for project guidelines
  4. Determine review scope (files to analyze)
Risk assessment (determines review depth): Auto-escalate to deep review if:
  • Auth/payment/security files touched
  • No tests added
  • Diff > 500 lines
  • Previous gate was FAIL or CONCERNS
  • Story has > 5 acceptance criteria
Proceed to Phase 1.

单个需求审查流程:
TodoWrite([
  { content: "收集审查上下文", status: "in_progress", activeForm: "正在收集上下文" },
  { content: "运行必要检查", status: "pending", activeForm: "正在运行检查" },
  { content: "生成专项子代理", status: "pending", activeForm: "正在生成专项代理" },
  { content: "汇总审查结果", status: "pending", activeForm: "正在汇总结果" },
  { content: "运行qa-gate", status: "pending", activeForm: "正在运行准入检查" },
  { content: "更新需求文件", status: "pending", activeForm: "正在更新需求文件" }
])
收集上下文:
  1. 若指定需求,读取需求文件并提取:
    • 验收标准
    • 任务列表
    • 文件列表(若存在)
    • 历史QA结果
  2. 获取变更文件列表:
    git diff --name-only origin/main
  3. 读取CLAUDE.md获取项目规范
  4. 确定审查范围(待分析文件)
风险评估(决定审查深度): 出现以下情况时自动升级为深度审查:
  • 涉及认证/支付/安全相关文件
  • 未添加新测试用例
  • 代码变更超过500行
  • 上次准入结果为FAIL或CONCERNS
  • 需求包含超过5条验收标准
进入阶段1。

Phase 0B: Process Directory (Multiple Stories)

阶段0B:处理目录(多需求)

For directory review:
stories_to_review = [{story_path}, {story_path}, ...]  # From Phase 0

TodoWrite([
  { content: "Review {story_1}", status: "in_progress", activeForm: "Reviewing {story_1}" },
  { content: "Review {story_2}", status: "pending", activeForm: "Reviewing {story_2}" },
  { content: "Review {story_3}", status: "pending", activeForm: "Reviewing {story_3}" },
  # ... one per story
  { content: "Generate summary report", status: "pending", activeForm: "Generating summary" }
])
For each story in stories_to_review:
  1. Read story file and extract:
    • Story ID/number
    • Title
    • Status
    • Acceptance criteria
    • Tasks list
    • Previous review findings (if any)
  2. Run Phases 0A through 7 for this story (see below for modified Phase 7)
  3. Mark todo as completed, move to next story
  4. After all stories processed, proceed to Phase 8B (Summary Report)
CRITICAL: Process stories sequentially, not in parallel. This allows findings to be appended to each story file before moving to the next.
Proceed to Phase 0A for each story, then continue through phases.

目录审查流程:
stories_to_review = [{story_path}, {story_path}, ...]  # 来自阶段0

TodoWrite([
  { content: "审查 {story_1}", status: "in_progress", activeForm: "正在审查 {story_1}" },
  { content: "审查 {story_2}", status: "pending", activeForm: "正在审查 {story_2}" },
  { content: "审查 {story_3}", status: "pending", activeForm: "正在审查 {story_3}" },
  # ... 每个需求对应一项
  { content: "生成汇总报告", status: "pending", activeForm: "正在生成汇总报告" }
])
对stories_to_review中的每个需求:
  1. 读取需求文件并提取:
    • 需求ID/编号
    • 标题
    • 状态
    • 验收标准
    • 任务列表
    • 历史审查结果(若有)
  2. 为该需求执行阶段0A至阶段7(阶段7有修改,见下文)
  3. 标记待办事项为完成,继续下一个需求
  4. 所有需求处理完成后,进入阶段8B(汇总报告)
重要提示:按顺序处理需求,而非并行处理。这样可确保在处理下一个需求前,当前需求文件已更新审查结果。
为每个需求执行阶段0A,之后继续后续阶段。

Phase 1: Required Checks

阶段1:必要检查

Run these first (blocking if they fail):
bash
pnpm test --filter='...[origin/main]'
pnpm check-types --filter='...[origin/main]'
pnpm lint --filter='...[origin/main]'
If any fail and --fix is set:
  • Try to auto-fix lint issues:
    pnpm lint --fix
  • Re-run checks
If still failing: Report and continue (will affect gate decision)

首先运行以下检查(若失败则阻塞流程):
bash
pnpm test --filter='...[origin/main]'
pnpm check-types --filter='...[origin/main]'
pnpm lint --filter='...[origin/main]'
若任意检查失败且启用--fix:
  • 尝试自动修复lint问题:
    pnpm lint --fix
  • 重新运行检查
若仍失败: 记录问题并继续(将影响准入决策)

Phase 2: Spawn Specialist Sub-Agents

阶段2:生成专项子代理

CRITICAL: Spawn all specialists in parallel using run_in_background: true
重要提示:使用run_in_background: true并行生成所有专项代理

2.1 Requirements Traceability Specialist

2.1 需求可追溯性专项代理

Task(
  subagent_type: "general-purpose",
  model: "haiku",
  description: "Requirements traceability",
  run_in_background: true,
  prompt: "You are a requirements traceability specialist.

           Story file: {STORY_FILE_PATH}
           Changed files: {CHANGED_FILES}

           For each acceptance criterion in the story:
           1. Find the test(s) that validate it
           2. Document the mapping using Given-When-Then format
           3. Identify any AC without test coverage

           T-SHIRT SIZE ESTIMATE (from requirements perspective):
           Based on the number of acceptance criteria, their complexity, and test coverage gaps:
           - XS: 1-2 simple ACs, all covered
           - S: 3-4 ACs, mostly covered
           - M: 5-7 ACs, some gaps
           - L: 8-10 ACs, significant gaps
           - XL: 11+ ACs, many gaps
           - XXL: 15+ ACs, extensive gaps or highly complex criteria

           Output format:
           ```yaml
           traceability:
             t_shirt_size: XS|S|M|L|XL|XXL
             size_rationale: 'Brief explanation of size estimate'
             covered:
               - ac: 1
                 test_file: src/__tests__/auth.test.ts
                 test_name: 'should validate login credentials'
                 given_when_then: 'Given valid credentials, When login called, Then returns token'
             gaps:
               - ac: 3
                 description: 'No test for session timeout handling'
                 severity: medium
                 suggested_test: 'Add test for session expiry behavior'
           ```"
)
Task(
  subagent_type: "general-purpose",
  model: "haiku",
  description: "需求可追溯性",
  run_in_background: true,
  prompt: "你是需求可追溯性专家。

           需求文件:{STORY_FILE_PATH}
           变更文件:{CHANGED_FILES}

           针对需求中的每条验收标准:
           1. 找到验证该标准的测试用例
           2. 用Given-When-Then格式记录映射关系
           3. 识别无测试覆盖的验收标准

           T恤尺寸估算(从需求角度):
           根据验收标准数量、复杂度及测试覆盖缺口:
           - XS: 1-2条简单标准,全部覆盖
           - S: 3-4条标准,大部分覆盖
           - M: 5-7条标准,存在部分缺口
           - L: 8-10条标准,缺口显著
           - XL: 11+条标准,大量缺口
           - XXL: 15+条标准,缺口广泛或标准高度复杂

           输出格式:
           ```yaml
           traceability:
             t_shirt_size: XS|S|M|L|XL|XXL
             size_rationale: '尺寸估算简要说明'
             covered:
               - ac: 1
                 test_file: src/__tests__/auth.test.ts
                 test_name: 'should validate login credentials'
                 given_when_then: 'Given valid credentials, When login called, Then returns token'
             gaps:
               - ac: 3
                 description: '无会话超时处理测试'
                 severity: medium
                 suggested_test: '添加会话过期行为测试'
           ```"
)

2.2 Code Quality Specialist

2.2 代码质量专项代理

Task(
  subagent_type: "general-purpose",
  model: "haiku",
  description: "Code quality review",
  run_in_background: true,
  prompt: "You are a code quality specialist.

           Project guidelines: {CLAUDE_MD_CONTENT}
           Changed files: {CHANGED_FILES}

           Analyze for:
           1. Architecture and design patterns
           2. Code duplication
           3. Refactoring opportunities
           4. Best practices adherence
           5. CLAUDE.md compliance (Zod schemas, @repo/ui, @repo/logger, no barrel files)

           T-SHIRT SIZE ESTIMATE (from code quality/complexity perspective):
           Based on code complexity, architectural impact, and refactoring needs:
           - XS: Simple, isolated changes, minimal complexity
           - S: Straightforward implementation, few files touched
           - M: Moderate complexity, some architectural considerations
           - L: Complex logic, multiple components/patterns involved
           - XL: Significant architectural changes, cross-cutting concerns
           - XXL: Major refactoring or system-wide impact

           For each finding:
           - id: QUAL-{NNN}
           - severity: low|medium|high
           - finding: Description
           - file: File path
           - line: Line number
           - suggested_action: How to fix
           - can_auto_fix: true|false

           Output format:
           ```yaml
           code_quality:
             t_shirt_size: XS|S|M|L|XL|XXL
             size_rationale: 'Brief explanation of size estimate'
             complexity_score: 1-10
             findings:
               - id: QUAL-001
                 severity: medium
                 finding: '...'
                 # ... rest of fields
           ```"
)
Task(
  subagent_type: "general-purpose",
  model: "haiku",
  description: "代码质量审查",
  run_in_background: true,
  prompt: "你是代码质量专家。

           项目规范:{CLAUDE_MD_CONTENT}
           变更文件:{CHANGED_FILES}

           分析维度:
           1. 架构与设计模式
           2. 代码重复
           3. 重构机会
           4. 最佳实践遵循情况
           5. CLAUDE.md合规性(Zod schemas、@repo/ui、@repo/logger、无桶文件)

           T恤尺寸估算(从代码质量/复杂度角度):
           根据代码复杂度、架构影响及重构需求:
           - XS: 简单独立变更,复杂度极低
           - S: 实现直接,涉及少量文件
           - M: 复杂度中等,需考虑架构因素
           - L: 逻辑复杂,涉及多个组件/模式
           - XL: 架构变更显著,存在跨领域关注点
           - XXL: 大规模重构或系统级影响

           每个问题需包含:
           - id: QUAL-{NNN}
           - severity: low|medium|high
           - finding: 问题描述
           - file: 文件路径
           - line: 行号
           - suggested_action: 修复方案
           - can_auto_fix: true|false

           输出格式:
           ```yaml
           code_quality:
             t_shirt_size: XS|S|M|L|XL|XXL
             size_rationale: '尺寸估算简要说明'
             complexity_score: 1-10
             findings:
               - id: QUAL-001
                 severity: medium
                 finding: '...'
                 # ... 其他字段
           ```"
)

2.3 Security Specialist

2.3 安全性专项代理

Task(
  subagent_type: "general-purpose",
  model: "haiku",
  description: "Security review",
  run_in_background: true,
  prompt: "You are a security specialist.

           Changed files: {CHANGED_FILES}

           Check for:
           - Authentication/authorization issues
           - Injection vulnerabilities (SQL, XSS, command)
           - Sensitive data exposure
           - OWASP Top 10 issues
           - Hardcoded secrets or credentials
           - Insecure dependencies

           T-SHIRT SIZE ESTIMATE (from security risk perspective):
           Based on security surface area, risk level, and required mitigations:
           - XS: No security implications, read-only operations
           - S: Minor security considerations, standard auth checks
           - M: Moderate security requirements, data validation needed
           - L: Significant security impact, auth/authz critical
           - XL: High-risk features (payments, PII, admin functions)
           - XXL: Critical security features requiring extensive hardening

           For each finding:
           - id: SEC-{NNN}
           - severity: low|medium|high
           - finding: Description
           - file: File path
           - line: Line number
           - cwe: CWE reference if applicable
           - suggested_action: How to fix

           Output format:
           ```yaml
           security:
             t_shirt_size: XS|S|M|L|XL|XXL
             size_rationale: 'Brief explanation of size estimate'
             risk_level: low|medium|high|critical
             findings:
               - id: SEC-001
                 severity: high
                 finding: '...'
                 # ... rest of fields
           ```"
)
Task(
  subagent_type: "general-purpose",
  model: "haiku",
  description: "安全性审查",
  run_in_background: true,
  prompt: "你是安全专家。

           变更文件:{CHANGED_FILES}

           检查维度:
           - 认证/授权问题
           - 注入漏洞(SQL、XSS、命令注入)
           - 敏感数据泄露
           - OWASP Top 10问题
           - 硬编码密钥或凭证
           - 不安全依赖

           T恤尺寸估算(从安全风险角度):
           根据安全暴露面、风险等级及所需缓解措施:
           - XS: 无安全影响,仅只读操作
           - S: 轻微安全考量,标准认证检查
           - M: 中等安全要求,需数据验证
           - L: 安全影响显著,认证/授权至关重要
           - XL: 高风险功能(支付、PII、管理功能)
           - XXL: 关键安全功能,需全面加固

           每个问题需包含:
           - id: SEC-{NNN}
           - severity: low|medium|high
           - finding: 问题描述
           - file: 文件路径
           - line: 行号
           - cwe: CWE参考编号(若适用)
           - suggested_action: 修复方案

           输出格式:
           ```yaml
           security:
             t_shirt_size: XS|S|M|L|XL|XXL
             size_rationale: '尺寸估算简要说明'
             risk_level: low|medium|high|critical
             findings:
               - id: SEC-001
                 severity: high
                 finding: '...'
                 # ... 其他字段
           ```"
)

2.4 Performance Specialist

2.4 性能专项代理

Task(
  subagent_type: "general-purpose",
  model: "haiku",
  description: "Performance review",
  run_in_background: true,
  prompt: "You are a performance specialist.

           Changed files: {CHANGED_FILES}

           Check for:
           - N+1 query patterns
           - Missing database indexes
           - Unnecessary re-renders in React
           - Large bundle imports
           - Missing memoization (useMemo, useCallback, React.memo)
           - Inefficient algorithms
           - Memory leaks

           T-SHIRT SIZE ESTIMATE (from performance optimization perspective):
           Based on performance complexity and optimization requirements:
           - XS: Minimal performance considerations, simple operations
           - S: Basic performance best practices sufficient
           - M: Some optimization needed (memoization, indexes)
           - L: Significant performance work (query optimization, caching)
           - XL: Complex performance requirements (real-time, large datasets)
           - XXL: Critical performance engineering (sub-second SLAs, scale challenges)

           For each finding:
           - id: PERF-{NNN}
           - severity: low|medium|high
           - finding: Description
           - file: File path
           - estimated_impact: Description of performance impact
           - suggested_action: How to fix

           Output format:
           ```yaml
           performance:
             t_shirt_size: XS|S|M|L|XL|XXL
             size_rationale: 'Brief explanation of size estimate'
             performance_risk: low|medium|high
             findings:
               - id: PERF-001
                 severity: medium
                 finding: '...'
                 # ... rest of fields
           ```"
)
Task(
  subagent_type: "general-purpose",
  model: "haiku",
  description: "性能审查",
  run_in_background: true,
  prompt: "你是性能专家。

           变更文件:{CHANGED_FILES}

           检查维度:
           - N+1查询模式
           - 缺失数据库索引
           - React中不必要的重渲染
           - 过大的包导入
           - 缺失记忆化处理(useMemo、useCallback、React.memo)
           - 低效算法
           - 内存泄漏

           T恤尺寸估算(从性能优化角度):
           根据性能复杂度及优化需求:
           - XS: 性能考量极少,操作简单
           - S: 基础性能最佳实践即可满足
           - M: 需部分优化(记忆化、索引)
           - L: 需显著性能优化(查询优化、缓存)
           - XL: 复杂性能需求(实时、大数据集)
           - XXL: 关键性能工程(亚秒级SLA、规模挑战)

           每个问题需包含:
           - id: PERF-{NNN}
           - severity: low|medium|high
           - finding: 问题描述
           - file: 文件路径
           - estimated_impact: 性能影响描述
           - suggested_action: 修复方案

           输出格式:
           ```yaml
           performance:
             t_shirt_size: XS|S|M|L|XL|XXL
             size_rationale: '尺寸估算简要说明'
             performance_risk: low|medium|high
             findings:
               - id: PERF-001
                 severity: medium
                 finding: '...'
                 # ... 其他字段
           ```"
)

2.5 Accessibility Specialist

2.5 可访问性专项代理

Task(
  subagent_type: "general-purpose",
  model: "haiku",
  description: "Accessibility review",
  run_in_background: true,
  prompt: "You are an accessibility specialist.

           Changed files: {CHANGED_FILES}

           Check for:
           - WCAG 2.1 AA compliance
           - Keyboard navigation support
           - Screen reader compatibility
           - Missing ARIA labels/roles
           - Color contrast issues
           - Focus management
           - Form labels and error messages

           T-SHIRT SIZE ESTIMATE (from accessibility perspective):
           Based on UI complexity and a11y requirements:
           - XS: No UI changes, or simple read-only content
           - S: Basic UI with standard components (buttons, text)
           - M: Interactive UI (forms, modals) requiring a11y attention
           - L: Complex UI (data tables, multi-step flows, drag-drop)
           - XL: Rich interactions (custom widgets, animations, dynamic content)
           - XXL: Highly complex UI requiring extensive a11y engineering

           For each finding:
           - id: A11Y-{NNN}
           - severity: low|medium|high
           - finding: Description
           - file: File path
           - wcag_criterion: WCAG reference (e.g., 1.4.3)
           - suggested_action: How to fix

           Output format:
           ```yaml
           accessibility:
             t_shirt_size: XS|S|M|L|XL|XXL
             size_rationale: 'Brief explanation of size estimate'
             ui_complexity: low|medium|high
             findings:
               - id: A11Y-001
                 severity: high
                 finding: '...'
                 # ... rest of fields
           ```"
)
Task(
  subagent_type: "general-purpose",
  model: "haiku",
  description: "可访问性审查",
  run_in_background: true,
  prompt: "你是可访问性专家。

           变更文件:{CHANGED_FILES}

           检查维度:
           - WCAG 2.1 AA合规性
           - 键盘导航支持
           - 屏幕阅读器兼容性
           - 缺失ARIA标签/角色
           - 颜色对比度问题
           - 焦点管理
           - 表单标签与错误提示

           T恤尺寸估算(从可访问性角度):
           根据UI复杂度及a11y需求:
           - XS: 无UI变更或简单只读内容
           - S: 基础UI,使用标准组件(按钮、文本)
           - M: 交互式UI(表单、模态框),需关注a11y
           - L: 复杂UI(数据表格、多步骤流程、拖拽)
           - XL: 丰富交互(自定义组件、动画、动态内容)
           - XXL: 高度复杂UI,需全面a11y工程

           每个问题需包含:
           - id: A11Y-{NNN}
           - severity: low|medium|high
           - finding: 问题描述
           - file: 文件路径
           - wcag_criterion: WCAG参考(如1.4.3)
           - suggested_action: 修复方案

           输出格式:
           ```yaml
           accessibility:
             t_shirt_size: XS|S|M|L|XL|XXL
             size_rationale: '尺寸估算简要说明'
             ui_complexity: low|medium|high
             findings:
               - id: A11Y-001
                 severity: high
                 finding: '...'
                 # ... 其他字段
           ```"
)

2.6 Test Coverage Specialist

2.6 测试覆盖率专项代理

Task(
  subagent_type: "general-purpose",
  model: "haiku",
  description: "Test coverage analysis",
  run_in_background: true,
  prompt: "You are a test coverage specialist.

           Changed files: {CHANGED_FILES}
           Test files: {TEST_FILES}

           Analyze:
           1. Test coverage for changed code
           2. Test quality and maintainability
           3. Edge cases and error scenarios
           4. Mock/stub appropriateness
           5. Test level appropriateness (unit vs integration vs e2e)

           T-SHIRT SIZE ESTIMATE (from testing perspective):
           Based on testing complexity and coverage requirements:
           - XS: Minimal testing needed, simple assertions
           - S: Basic unit tests sufficient (1-2 test files)
           - M: Moderate testing (unit + some integration tests)
           - L: Comprehensive testing (unit + integration + edge cases)
           - XL: Extensive testing (e2e, multiple scenarios, complex mocks)
           - XXL: Critical path requiring exhaustive test coverage

           For each finding:
           - id: TEST-{NNN}
           - severity: low|medium|high
           - finding: Description
           - file: File being tested (or missing tests)
           - suggested_action: What tests to add/improve

           Output format:
           ```yaml
           test_coverage:
             t_shirt_size: XS|S|M|L|XL|XXL
             size_rationale: 'Brief explanation of size estimate'
             test_complexity: low|medium|high
             findings:
               - id: TEST-001
                 severity: medium
                 finding: '...'
                 # ... rest of fields
           ```"
)
Task(
  subagent_type: "general-purpose",
  model: "haiku",
  description: "测试覆盖率分析",
  run_in_background: true,
  prompt: "你是测试覆盖率专家。

           变更文件:{CHANGED_FILES}
           测试文件:{TEST_FILES}

           分析维度:
           1. 变更代码的测试覆盖率
           2. 测试用例质量与可维护性
           3. 边缘场景与错误场景
           4. Mock/Stub的合理性
           5. 测试层级合理性(单元测试vs集成测试vs端到端测试)

           T恤尺寸估算(从测试角度):
           根据测试复杂度及覆盖需求:
           - XS: 测试需求极少,断言简单
           - S: 基础单元测试即可满足(1-2个测试文件)
           - M: 中等测试需求(单元测试+部分集成测试)
           - L: 全面测试需求(单元测试+集成测试+边缘场景)
           - XL: 广泛测试需求(端到端测试、多场景、复杂Mock)
           - XXL: 关键路径,需穷尽测试覆盖

           每个问题需包含:
           - id: TEST-{NNN}
           - severity: low|medium|high
           - finding: 问题描述
           - file: 被测文件(或缺失测试的文件)
           - suggested_action: 需添加/改进的测试内容

           输出格式:
           ```yaml
           test_coverage:
             t_shirt_size: XS|S|M|L|XL|XXL
             size_rationale: '尺寸估算简要说明'
             test_complexity: low|medium|high
             findings:
               - id: TEST-001
                 severity: medium
                 finding: '...'
                 # ... 其他字段
           ```"
)

2.7 Technical Debt Specialist

2.7 技术债务专项代理

Task(
  subagent_type: "general-purpose",
  model: "haiku",
  description: "Technical debt assessment",
  run_in_background: true,
  prompt: "You are a technical debt specialist.

           Changed files: {CHANGED_FILES}

           Identify:
           1. Accumulated shortcuts or TODOs
           2. Missing tests
           3. Outdated patterns or dependencies
           4. Architecture violations
           5. Code that should be refactored
           6. Documentation gaps

           T-SHIRT SIZE ESTIMATE (from tech debt/maintenance perspective):
           Based on long-term maintenance burden and tech debt:
           - XS: Clean implementation, no debt added
           - S: Minimal debt, well-documented
           - M: Some shortcuts taken, minor debt
           - L: Notable tech debt or maintenance concerns
           - XL: Significant debt that will require future cleanup
           - XXL: Major tech debt or legacy pattern perpetuation

           For each finding:
           - id: DEBT-{NNN}
           - severity: low|medium|high
           - finding: Description
           - file: File path
           - estimated_effort: small|medium|large
           - suggested_action: How to address

           Output format:
           ```yaml
           technical_debt:
             t_shirt_size: XS|S|M|L|XL|XXL
             size_rationale: 'Brief explanation of size estimate'
             maintenance_burden: low|medium|high
             findings:
               - id: DEBT-001
                 severity: low
                 finding: '...'
                 # ... rest of fields
           ```"
)

Task(
  subagent_type: "general-purpose",
  model: "haiku",
  description: "技术债务评估",
  run_in_background: true,
  prompt: "你是技术债务专家。

           变更文件:{CHANGED_FILES}

           识别维度:
           1. 累积的捷径或TODO项
           2. 缺失的测试用例
           3. 过时的模式或依赖
           4. 架构违规
           5. 需重构的代码
           6. 文档缺口

           T恤尺寸估算(从技术债务/维护角度):
           根据长期维护负担及技术债务:
           - XS: 实现整洁,无新增债务
           - S: 债务极少,文档完善
           - M: 存在部分捷径,轻微债务
           - L: 存在明显技术债务或维护隐患
           - XL: 显著债务,未来需大量清理
           - XXL: 重大技术债务或遗留模式延续

           每个问题需包含:
           - id: DEBT-{NNN}
           - severity: low|medium|high
           - finding: 问题描述
           - file: 文件路径
           - estimated_effort: small|medium|large
           - suggested_action: 解决方案

           输出格式:
           ```yaml
           technical_debt:
             t_shirt_size: XS|S|M|L|XL|XXL
             size_rationale: '尺寸估算简要说明'
             maintenance_burden: low|medium|high
             findings:
               - id: DEBT-001
                 severity: low
                 finding: '...'
                 # ... 其他字段
           ```"
)

Phase 3: Collect Results

阶段3:收集结果

Wait for all specialists to complete:
results = {
  traceability: TaskOutput(task_id: "{traceability_id}"),
  code_quality: TaskOutput(task_id: "{quality_id}"),
  security: TaskOutput(task_id: "{security_id}"),
  performance: TaskOutput(task_id: "{performance_id}"),
  accessibility: TaskOutput(task_id: "{accessibility_id}"),
  test_coverage: TaskOutput(task_id: "{coverage_id}"),
  technical_debt: TaskOutput(task_id: "{debt_id}")
}

等待所有专项代理完成:
results = {
  traceability: TaskOutput(task_id: "{traceability_id}"),
  code_quality: TaskOutput(task_id: "{quality_id}"),
  security: TaskOutput(task_id: "{security_id}"),
  performance: TaskOutput(task_id: "{performance_id}"),
  accessibility: TaskOutput(task_id: "{accessibility_id}"),
  test_coverage: TaskOutput(task_id: "{coverage_id}"),
  technical_debt: TaskOutput(task_id: "{debt_id}")
}

Phase 4: Aggregate Findings

阶段4:汇总结果

Combine all findings into unified structure:
yaml
review_summary:
  story: "{STORY_NUM}"
  reviewed_at: "{ISO-8601}"
  files_analyzed: {count}

  t_shirt_sizing:
    recommended_size: M  # Synthesized from all specialists
    confidence: high|medium|low
    specialist_estimates:
      requirements: { size: M, rationale: "..." }
      code_quality: { size: L, rationale: "..." }
      security: { size: S, rationale: "..." }
      performance: { size: M, rationale: "..." }
      accessibility: { size: M, rationale: "..." }
      test_coverage: { size: L, rationale: "..." }
      technical_debt: { size: M, rationale: "..." }
    size_breakdown:
      XS: 0 specialists
      S: 1 specialist
      M: 4 specialists
      L: 2 specialists
      XL: 0 specialists
      XXL: 0 specialists
    synthesis_rationale: |
      Final size recommendation based on:
      - Modal size: M (4/7 specialists)
      - Outliers: Code Quality (L), Test Coverage (L) due to [reason]
      - Risk factors: [key considerations]
      - Recommended: M with awareness of testing complexity

  checks:
    tests: { status: PASS|FAIL }
    types: { status: PASS|FAIL }
    lint: { status: PASS|FAIL }

  findings:
    total: {count}
    by_severity:
      high: {count}
      medium: {count}
      low: {count}
    by_category:
      security: {count}
      performance: {count}
      accessibility: {count}
      code_quality: {count}
      test_coverage: {count}
      technical_debt: {count}
      requirements: {count}

  traceability:
    ac_total: {count}
    ac_covered: {count}
    ac_gaps: {count}

  all_findings:
    - id: SEC-001
      category: security
      severity: high
      finding: "..."
      file: "..."
      suggested_action: "..."
    # ... all findings sorted by severity
Synthesize T-Shirt Size:
  1. Collect all specialist estimates:
    • Extract t_shirt_size from each specialist's output
    • Extract rationale for each estimate
  2. Calculate modal size (most common):
    • Count occurrences of each size
    • Identify the most frequent size
  3. Identify outliers:
    • Flag estimates more than 1 size away from modal
    • Document why specialists disagree
  4. Apply weighting logic:
    • Security/Requirements: Higher weight if XL or XXL (risk-based)
    • Code Quality: Higher weight if architectural complexity
    • Test Coverage: Consider for effort estimation
    • Technical Debt: Lower weight unless XXL
  5. Synthesize final recommendation:
    • Start with modal size
    • Adjust up if high-risk outliers (Security XL/XXL)
    • Adjust up if multiple specialists cite complexity
    • Set confidence based on agreement level:
      • High: 5+ specialists agree
      • Medium: 3-4 specialists agree
      • Low: Wide spread, no clear modal
  6. Document synthesis rationale:
    • Explain final size choice
    • Call out key risk factors
    • Note any caveats or warnings
Deduplicate findings:
  • Merge similar findings from different specialists
  • Keep highest severity when duplicated

将所有结果合并为统一结构:
yaml
review_summary:
  story: "{STORY_NUM}"
  reviewed_at: "{ISO-8601}"
  files_analyzed: {count}

  t_shirt_sizing:
    recommended_size: M  # 综合所有专项代理结果
    confidence: high|medium|low
    specialist_estimates:
      requirements: { size: M, rationale: "..." }
      code_quality: { size: L, rationale: "..." }
      security: { size: S, rationale: "..." }
      performance: { size: M, rationale: "..." }
      accessibility: { size: M, rationale: "..." }
      test_coverage: { size: L, rationale: "..." }
      technical_debt: { size: M, rationale: "..." }
    size_breakdown:
      XS: 0 specialists
      S: 1 specialist
      M: 4 specialists
      L: 2 specialists
      XL: 0 specialists
      XXL: 0 specialists
    synthesis_rationale: |
      最终尺寸推荐基于:
      - 众数尺寸:M(4/7个专项代理)
      - 异常值:代码质量(L)、测试覆盖率(L),原因是[具体原因]
      - 风险因素:[关键考量点]
      - 推荐:M,同时需注意测试复杂度

  checks:
    tests: { status: PASS|FAIL }
    types: { status: PASS|FAIL }
    lint: { status: PASS|FAIL }

  findings:
    total: {count}
    by_severity:
      high: {count}
      medium: {count}
      low: {count}
    by_category:
      security: {count}
      performance: {count}
      accessibility: {count}
      code_quality: {count}
      test_coverage: {count}
      technical_debt: {count}
      requirements: {count}

  traceability:
    ac_total: {count}
    ac_covered: {count}
    ac_gaps: {count}

  all_findings:
    - id: SEC-001
      category: security
      severity: high
      finding: "..."
      file: "..."
      suggested_action: "..."
    # ... 所有问题按严重程度排序
综合T恤尺寸:
  1. 收集所有专项代理估算:
    • 从每个专项代理输出中提取t_shirt_size
    • 提取每个估算的理由
  2. 计算众数尺寸(最常见):
    • 统计各尺寸出现次数
    • 确定出现频率最高的尺寸
  3. 识别异常值:
    • 标记与众数尺寸相差超过1级的估算
    • 记录专项代理意见分歧的原因
  4. 应用加权逻辑:
    • 安全性/需求:若为XL或XXL则权重更高(基于风险)
    • 代码质量:若涉及架构复杂度则权重更高
    • 测试覆盖率:纳入工作量估算考量
    • 技术债务:除非为XXL,否则权重较低
  5. 生成最终推荐:
    • 以众数尺寸为基础
    • 若存在高风险异常值(安全性XL/XXL)则上调
    • 若多个专项代理提及复杂度则上调
    • 根据共识程度设置置信度:
      • 高:5个及以上专项代理达成一致
      • 中:3-4个专项代理达成一致
      • 低:意见分散,无明确众数
  6. 记录综合理由:
    • 解释最终尺寸选择
    • 指出关键风险因素
    • 说明任何注意事项或警告
去重结果:
  • 合并不同专项代理发现的相似问题
  • 重复问题保留最高严重程度

Phase 5: Auto-Fix (if --fix enabled)

阶段5:自动修复(若启用--fix)

For findings with can_auto_fix: true:
Task(
  subagent_type: "general-purpose",
  description: "Apply safe refactoring",
  prompt: "Apply these safe fixes:

           {FIXABLE_FINDINGS}

           Project guidelines: {CLAUDE_MD_CONTENT}

           For each fix:
           1. Make the change
           2. Run tests to verify
           3. Commit with message: 'refactor: {description}'

           Report what was fixed and what was skipped."
)
Re-run required checks after fixes.

针对can_auto_fix: true的问题:
Task(
  subagent_type: "general-purpose",
  description: "应用安全重构",
  prompt: "应用以下安全修复:

           {FIXABLE_FINDINGS}

           项目规范:{CLAUDE_MD_CONTENT}

           每个修复需:
           1. 执行变更
           2. 运行测试验证
           3. 提交,提交信息为'refactor: {description}'

           报告已修复和跳过的内容。"
)
修复后重新运行必要检查。

Phase 6: Run QA Gate

阶段6:运行QA准入

Unless --no-gate specified:
Invoke /qa-gate skill with:
- Story number (if provided)
- Aggregated findings
- Check results

The /qa-gate skill will:
- Determine gate decision (PASS/CONCERNS/FAIL)
- Create gate file at docs/qa/gates/{story}-{slug}.yml
- Return gate status

除非指定--no-gate:
调用/qa-gate工具,传入:
- 需求编号(若提供)
- 汇总结果
- 检查结果

/qa-gate工具将:
- 确定准入决策(PASS/CONCERNS/FAIL)
- 在docs/qa/gates/{story}-{slug}.yml生成准入文件
- 返回准入状态

Phase 7: Update Story File

阶段7:更新需求文件

Append Review Findings section to story file:
Check if story file already has a
## Review Findings
section:
  • If yes: Replace it with updated findings
  • If no: Append to end of file
markdown
undefined
在需求文件末尾追加审查结果章节:
检查需求文件是否已存在
## 审查结果
章节:
  • 若存在:替换为最新结果
  • 若不存在:追加到文件末尾
markdown
undefined

Review Findings

审查结果

Review Date: {ISO-8601} Reviewed By: Claude Code Gate: {PASS|CONCERNS|FAIL} (score: {score}/100) Gate File: docs/qa/gates/{story}-{slug}.yml
审查日期: {ISO-8601} 审查者: Claude Code 准入状态: {PASS|CONCERNS|FAIL}(得分:{score}/100) 准入文件: docs/qa/gates/{story}-{slug}.yml

T-Shirt Size Estimate

T恤尺寸估算

Recommended Size: {M} (Confidence: {high|medium|low})
Specialist Breakdown:
SpecialistSizeRationale
RequirementsM5-7 ACs with some test gaps
Code QualityLModerate complexity, architectural considerations
SecuritySStandard auth checks, low risk
PerformanceMSome optimization needed (memoization)
AccessibilityMInteractive UI requiring a11y attention
Test CoverageLComprehensive testing needed (unit + integration)
Tech DebtMMinor shortcuts, well-documented
Size Distribution: XS: 0, S: 1, M: 4, L: 2, XL: 0, XXL: 0
Synthesis: Modal size is M (4/7 specialists). Code Quality and Test Coverage flagged as L due to architectural complexity and comprehensive testing requirements. Overall recommendation: M with awareness that testing effort may push toward upper end of estimate.

推荐尺寸:{M}(置信度:{high|medium|low})
专项代理细分:
专项代理尺寸理由
需求可追溯性M5-7条验收标准,存在部分测试缺口
代码质量L复杂度中等,需考虑架构因素
安全性S标准认证检查,风险较低
性能M需部分优化(记忆化处理)
可访问性M交互式UI,需关注a11y
测试覆盖率L需全面测试(单元+集成)
技术债务M存在轻微捷径,文档完善
尺寸分布:XS: 0, S: 1, M: 4, L: 2, XL: 0, XXL: 0
综合说明: 众数尺寸为M(4/7个专项代理)。代码质量和测试覆盖率标记为L,原因是架构复杂度和全面测试需求。总体推荐:M,同时需注意测试工作量可能接近该尺寸上限。

Summary

摘要

  • Files Analyzed: {count}
  • Total Findings: {count} (high: {N}, medium: {N}, low: {N})
  • Traceability: {N}/{M} acceptance criteria have test coverage
  • 分析文件数: {count}
  • 问题总数: {count}(高:{N},中:{N},低:{N})
  • 需求可追溯性: {N}/{M}条验收标准有测试覆盖

Required Checks

必要检查

CheckStatus
Tests{PASS/FAIL}
Types{PASS/FAIL}
Lint{PASS/FAIL}
检查项状态
测试{PASS/FAIL}
类型检查{PASS/FAIL}
Lint{PASS/FAIL}

Requirements Traceability

需求可追溯性

{If traceability gaps found:}
  • [REQ-001] {severity}: {finding}
    • File: {file or N/A}
    • Action: {suggested_action}
{If no gaps:} ✓ All acceptance criteria have test coverage
{若发现可追溯性缺口:}
  • [REQ-001] {severity}: {finding}
    • 文件: {file or N/A}
    • 行动: {suggested_action}
{若无缺口:} ✓ 所有验收标准均有测试覆盖

Code Quality

代码质量

{For each finding:}
  • [QUAL-001] {severity}: {finding}
    • File: {file}:{line}
    • Action: {suggested_action}
{If no findings:} ✓ No issues found
{每个问题:}
  • [QUAL-001] {severity}: {finding}
    • 文件: {file}:{line}
    • 行动: {suggested_action}
{若无问题:} ✓ 未发现问题

Security

安全性

{For each finding:}
  • [SEC-001] {severity}: {finding}
    • File: {file}:{line}
    • CWE: {cwe_reference}
    • Action: {suggested_action}
{If no findings:} ✓ No issues found
{每个问题:}
  • [SEC-001] {severity}: {finding}
    • 文件: {file}:{line}
    • CWE: {cwe_reference}
    • 行动: {suggested_action}
{若无问题:} ✓ 未发现问题

Performance

性能

{For each finding:}
  • [PERF-001] {severity}: {finding}
    • File: {file}:{line}
    • Impact: {estimated_impact}
    • Action: {suggested_action}
{If no findings:} ✓ No issues found
{每个问题:}
  • [PERF-001] {severity}: {finding}
    • 文件: {file}:{line}
    • 影响: {estimated_impact}
    • 行动: {suggested_action}
{若无问题:} ✓ 未发现问题

Accessibility

可访问性

{For each finding:}
  • [A11Y-001] {severity}: {finding}
    • File: {file}:{line}
    • WCAG: {wcag_criterion}
    • Action: {suggested_action}
{If no findings:} ✓ No issues found
{每个问题:}
  • [A11Y-001] {severity}: {finding}
    • 文件: {file}:{line}
    • WCAG: {wcag_criterion}
    • 行动: {suggested_action}
{若无问题:} ✓ 未发现问题

Test Coverage

测试覆盖率

{For each finding:}
  • [TEST-001] {severity}: {finding}
    • File: {file}
    • Action: {suggested_action}
{If no findings:} ✓ No issues found
{每个问题:}
  • [TEST-001] {severity}: {finding}
    • 文件: {file}
    • 行动: {suggested_action}
{若无问题:} ✓ 未发现问题

Technical Debt

技术债务

{For each finding:}
  • [DEBT-001] {severity}: {finding}
    • File: {file}:{line}
    • Effort: {estimated_effort}
    • Action: {suggested_action}
{If no findings:} ✓ No issues found
{If --fix was used:}
{每个问题:}
  • [DEBT-001] {severity}: {finding}
    • 文件: {file}:{line}
    • 工作量: {estimated_effort}
    • 行动: {suggested_action}
{若无问题:} ✓ 未发现问题
{若启用--fix:}

Refactoring Applied

已应用重构

  • {file}: {what was changed and why}
  • {file}: {变更内容及原因}

Recommendation

建议

{If PASS:} ✓ Ready for Done - All checks passed, no blocking issues.
{If CONCERNS:} ⚠ Review Required - Address medium-severity issues and proceed with awareness.
{If FAIL:} ✗ Changes Required - Address high-severity issues before proceeding.


**Important:**
- Use Edit tool to replace existing `## Review Findings` section if present
- Organize findings by specialist category
- Show "✓ No issues found" for categories with zero findings
- List findings in order of severity (high → medium → low)
- Include file paths and line numbers for easy navigation

---
{若PASS:} ✓ 可进入完成状态 - 所有检查通过,无阻塞问题。
{若CONCERNS:} ⚠ 需审查 - 解决中等严重程度问题后,可谨慎推进。
{若FAIL:} ✗ 需修改 - 解决高严重程度问题后再推进。


**注意事项:**
- 若存在现有`## 审查结果`章节,使用Edit工具替换
- 按专项代理类别组织问题
- 无问题的类别显示"✓ 未发现问题"
- 问题按严重程度排序(高→中→低)
- 包含文件路径和行号,便于定位

---

Phase 8A: Report to User (Single Story)

阶段8A:向用户报告(单个需求)

For single story review:
═══════════════════════════════════════════════════════════════════
  Code Review Complete: {STORY_NUM} - {STORY_TITLE}
═══════════════════════════════════════════════════════════════════

Files Analyzed: {N}
Time Taken: {duration}

T-SHIRT SIZE ESTIMATE
  Recommended: M (Confidence: high)
  Breakdown: XS:0 S:1 M:4 L:2 XL:0 XXL:0

  Requirements:    M  (5-7 ACs with some gaps)
  Code Quality:    L  (Moderate complexity, architectural considerations)
  Security:        S  (Standard auth, low risk)
  Performance:     M  (Some optimization needed)
  Accessibility:   M  (Interactive UI, a11y attention required)
  Test Coverage:   L  (Comprehensive testing needed)
  Tech Debt:       M  (Minor shortcuts, well-documented)

REQUIRED CHECKS
  Tests:    {PASS|FAIL}
  Types:    {PASS|FAIL}
  Lint:     {PASS|FAIL}

SPECIALIST FINDINGS ({total} total)
  Security:       {N} issues ({high}H {medium}M {low}L) → Size: S
  Performance:    {N} issues ({high}H {medium}M {low}L) → Size: M
  Accessibility:  {N} issues ({high}H {medium}M {low}L) → Size: M
  Code Quality:   {N} issues ({high}H {medium}M {low}L) → Size: L
  Test Coverage:  {N} issues ({high}H {medium}M {low}L) → Size: L
  Technical Debt: {N} issues ({high}H {medium}M {low}L) → Size: M

REQUIREMENTS TRACEABILITY
  {covered}/{total} acceptance criteria have test coverage
  {gaps} gaps identified

TOP ISSUES
  1. [SEC-001] high: {finding}
  2. [PERF-001] medium: {finding}
  ...

{If --fix was used:}
REFACTORING APPLIED
  - {file}: {change}
  ...

GATE DECISION
  Status: {PASS|CONCERNS|FAIL}
  Gate File: docs/qa/gates/{story}-{slug}.yml

{If FAIL:}
RECOMMENDATION: Address high-severity issues before proceeding.

{If CONCERNS:}
RECOMMENDATION: Review medium-severity issues and proceed with awareness.

{If PASS:}
RECOMMENDATION: Ready for merge.

FINDINGS LOCATION
  Story file updated: {STORY_FILE_PATH}

═══════════════════════════════════════════════════════════════════

单个需求审查报告:
═══════════════════════════════════════════════════════════════════
  代码审查完成:{STORY_NUM} - {STORY_TITLE}
═══════════════════════════════════════════════════════════════════

分析文件数:{N}
耗时:{duration}

T恤尺寸估算
  推荐:M(置信度:高)
  分布:XS:0 S:1 M:4 L:2 XL:0 XXL:0

  需求可追溯性:    M  (5-7条验收标准,存在部分缺口)
  代码质量:    L  (复杂度中等,需考虑架构因素)
  安全性:        S  (标准认证检查,风险较低)
  性能:     M  (需部分优化)
  可访问性:   M  (交互式UI,需关注a11y)
  测试覆盖率:  L  (需全面测试)
  技术债务:       M  (存在轻微捷径,文档完善)

必要检查
  测试:    {PASS|FAIL}
  类型检查:    {PASS|FAIL}
  Lint:     {PASS|FAIL}

专项代理问题汇总(共{total}个)
  安全性:       {N}个问题({high}高 {medium}中 {low}低)→ 尺寸: S
  性能:    {N}个问题({high}高 {medium}中 {low}低)→ 尺寸: M
  可访问性:  {N}个问题({high}高 {medium}中 {low}低)→ 尺寸: M
  代码质量:   {N}个问题({high}高 {medium}中 {low}低)→ 尺寸: L
  测试覆盖率:  {N}个问题({high}高 {medium}中 {low}低)→ 尺寸: L
  技术债务: {N}个问题({high}高 {medium}中 {low}低)→ 尺寸: M

需求可追溯性
  {covered}/{total}条验收标准有测试覆盖
  识别出{gaps}个缺口

顶级问题
  1. [SEC-001] 高: {finding}
  2. [PERF-001] 中: {finding}
  ...

{若启用--fix:}
已应用重构
  - {file}: {变更内容}
  ...

准入决策
  状态: {PASS|CONCERNS|FAIL}
  准入文件: docs/qa/gates/{story}-{slug}.yml

{若FAIL:}
建议:解决高严重程度问题后再推进。

{若CONCERNS:}
建议:审查中等严重程度问题后,谨慎推进。

{若PASS:}
建议:可合并。

问题位置
  已更新需求文件: {STORY_FILE_PATH}

═══════════════════════════════════════════════════════════════════

Phase 8B: Summary Report (Directory Review)

阶段8B:汇总报告(目录审查)

After all stories in directory have been reviewed:
═══════════════════════════════════════════════════════════════════
  Epic Review Complete: {EPIC_NAME}
═══════════════════════════════════════════════════════════════════

Stories Reviewed: {N}
Total Time: {duration}

GATE SUMMARY
  PASS:     {N} stories
  CONCERNS: {N} stories
  FAIL:     {N} stories

T-SHIRT SIZE DISTRIBUTION
  XS:  {N} stories
  S:   {N} stories
  M:   {N} stories
  L:   {N} stories
  XL:  {N} stories
  XXL: {N} stories

  Epic Effort Estimate: {sum of sizes} → ~{estimate} story points

FINDINGS BY STORY

┌─────────────────────────────────────────────────────────────────┐
│ {story-1-id} - {story-1-title}
├─────────────────────────────────────────────────────────────────┤
│ Size:     M (Confidence: high)
│ Gate:     {PASS|CONCERNS|FAIL}
│ Findings: {total} ({high}H {medium}M {low}L)
│ File:     {story_file_path}
│ Gate:     docs/qa/gates/{story-1}-{slug}.yml
└─────────────────────────────────────────────────────────────────┘

┌─────────────────────────────────────────────────────────────────┐
│ {story-2-id} - {story-2-title}
├─────────────────────────────────────────────────────────────────┤
│ Gate:     {PASS|CONCERNS|FAIL}
│ Findings: {total} ({high}H {medium}M {low}L)
│ File:     {story_file_path}
│ Gate:     docs/qa/gates/{story-2}-{slug}.yml
└─────────────────────────────────────────────────────────────────┘

{... for each story}

AGGREGATE STATISTICS

Total Findings: {total_across_all_stories}
  High:    {N}
  Medium:  {N}
  Low:     {N}

By Category:
  Security:       {N} findings across {M} stories
  Performance:    {N} findings across {M} stories
  Accessibility:  {N} findings across {M} stories
  Code Quality:   {N} findings across {M} stories
  Test Coverage:  {N} findings across {M} stories
  Technical Debt: {N} findings across {M} stories

MOST COMMON ISSUES (Top 5)

1. {issue_type}: {N} occurrences across {M} stories
2. {issue_type}: {N} occurrences across {M} stories
3. {issue_type}: {N} occurrences across {M} stories
4. {issue_type}: {N} occurrences across {M} stories
5. {issue_type}: {N} occurrences across {M} stories

RECOMMENDATION

{If any FAIL:}
⚠ {N} stories require changes before proceeding.
  → Review findings in each story file and address blocking issues.

{If any CONCERNS but no FAIL:}
⚠ {N} stories have concerns.
  → Review findings and proceed with awareness of identified issues.

{If all PASS:}
✓ All stories passed review! Ready for implementation or merge.

NEXT STEPS

Review detailed findings in each story file:
{For each story with FAIL or CONCERNS:}
  - {story_file_path}

═══════════════════════════════════════════════════════════════════
Aggregate Analysis:
  1. Count stories by gate status (PASS/CONCERNS/FAIL)
  2. Sum total findings across all stories
  3. Identify most common issue types across stories
  4. Provide actionable next steps

目录下所有需求审查完成后:
═══════════════════════════════════════════════════════════════════
  史诗审查完成: {EPIC_NAME}
═══════════════════════════════════════════════════════════════════

已审查需求数: {N}
总耗时: {duration}

准入汇总
  PASS:     {N}个需求
  CONCERNS: {N}个需求
  FAIL:     {N}个需求

T恤尺寸分布
  XS:  {N}个需求
  S:   {N}个需求
  M:   {N}个需求
  L:   {N}个需求
  XL:  {N}个需求
  XXL: {N}个需求

  史诗工作量估算: {sum of sizes} → ~{estimate}故事点

各需求问题汇总

┌─────────────────────────────────────────────────────────────────┐
│ {story-1-id} - {story-1-title}
├─────────────────────────────────────────────────────────────────┤
│ 尺寸:     M(置信度:高)
│ 准入状态:     {PASS|CONCERNS|FAIL}
│ 问题数: {total}({high}高 {medium}中 {low}低)
│ 文件:     {story_file_path}
│ 准入文件:     docs/qa/gates/{story-1}-{slug}.yml
└─────────────────────────────────────────────────────────────────┘

┌─────────────────────────────────────────────────────────────────┐
│ {story-2-id} - {story-2-title}
├─────────────────────────────────────────────────────────────────┤
│ 准入状态:     {PASS|CONCERNS|FAIL}
│ 问题数: {total}({high}高 {medium}中 {low}低)
│ 文件:     {story_file_path}
│ 准入文件:     docs/qa/gates/{story-2}-{slug}.yml
└─────────────────────────────────────────────────────────────────┘

{... 每个需求对应一项}

汇总统计

总问题数: {total_across_all_stories}
  高:    {N}
  中:  {N}
  低:     {N}

按类别分:
  安全性:       {N}个问题,涉及{M}个需求
  性能:    {N}个问题,涉及{M}个需求
  可访问性:  {N}个问题,涉及{M}个需求
  代码质量:   {N}个问题,涉及{M}个需求
  测试覆盖率:  {N}个问题,涉及{M}个需求
  技术债务: {N}个问题,涉及{M}个需求

最常见问题(前5)

1. {问题类型}: {N}次出现,涉及{M}个需求
2. {问题类型}: {N}次出现,涉及{M}个需求
3. {问题类型}: {N}次出现,涉及{M}个需求
4. {问题类型}: {N}次出现,涉及{M}个需求
5. {问题类型}: {N}次出现,涉及{M}个需求

建议

{若存在FAIL:}
⚠ {N}个需求需修改后再推进。
  → 查看各需求文件中的问题,解决阻塞问题。

{若存在CONCERNS但无FAIL:}
⚠ {N}个需求存在需关注的问题。
  → 查看问题后,谨慎推进。

{若全部PASS:}
✓ 所有需求均通过审查!可进入实现或合并阶段。

下一步

查看各需求文件中的详细问题:
{每个FAIL或CONCERNS的需求:}
  - {story_file_path}

═══════════════════════════════════════════════════════════════════
汇总分析:
  1. 按准入状态统计需求数(PASS/CONCERNS/FAIL)
  2. 汇总所有需求的问题总数
  3. 识别跨需求的最常见问题类型
  4. 提供可操作的下一步建议

Sub-Agent Architecture

子代理架构

Main Orchestrator (/review)
    ├─▶ Context Gathering (inline)
    ├─▶ Required Checks (inline)
    │   ├── pnpm test
    │   ├── pnpm check-types
    │   └── pnpm lint
    ├─▶ Specialist Sub-Agents (parallel, haiku)
    │   ├── Requirements Traceability
    │   ├── Code Quality
    │   ├── Security
    │   ├── Performance
    │   ├── Accessibility
    │   ├── Test Coverage
    │   └── Technical Debt
    ├─▶ Aggregation (inline)
    ├─▶ Auto-Fix (optional, general-purpose)
    └─▶ /qa-gate (produces gate file)

主编排器(/review)
    ├─▶ 上下文收集(内联)
    ├─▶ 必要检查(内联)
    │   ├── pnpm test
    │   ├── pnpm check-types
    │   └── pnpm lint
    ├─▶ 专项子代理(并行,haiku模型)
    │   ├── 需求可追溯性
    │   ├── 代码质量
    │   ├── 安全性
    │   ├── 性能
    │   ├── 可访问性
    │   ├── 测试覆盖率
    │   └── 技术债务
    ├─▶ 结果汇总(内联)
    ├─▶ 自动修复(可选,通用代理)
    └─▶ /qa-gate(生成准入文件)

Issue ID Prefixes

问题ID前缀

PrefixSpecialist
SEC-Security
PERF-Performance
A11Y-Accessibility
QUAL-Code Quality
TEST-Test Coverage
DEBT-Technical Debt
REQ-Requirements Traceability

前缀专项代理
SEC-安全性
PERF-性能
A11Y-可访问性
QUAL-代码质量
TEST-测试覆盖率
DEBT-技术债务
REQ-需求可追溯性

When to Use

使用场景

/review (comprehensive)

/review(全面审查)

  • Pre-merge reviews
  • Story completion reviews
  • Major feature reviews
  • Security-sensitive changes
  • 合并前审查
  • 需求完成审查
  • 重大功能审查
  • 安全敏感变更审查

/review --quick

/review --quick(快速审查)

  • Small changes
  • Documentation updates
  • Minor fixes
  • 小型变更
  • 文档更新
  • 轻微修复

/qa-gate (standalone)

/qa-gate(独立使用)

  • Quick pass/fail decision
  • CI/CD integration
  • Automated checks only
  • 快速通过/失败决策
  • CI/CD集成
  • 仅自动检查