quality-gate

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Quality Gate

质量门禁

!IMPORTANT: Follow this process exactly. Do not skip steps.
Arguments:
$0
(optional) — base branch to diff against. If omitted, auto-detect.
!重要提示:请严格遵循此流程,不要跳过任何步骤。
参数:
$0
(可选)——用于对比的基准分支。如果省略,将自动检测。

Step 1: Get the Diff

步骤1:获取差异内容

Detect the base branch:
bash
git rev-parse --verify main >/dev/null 2>&1 && echo "main" || (git rev-parse --verify master >/dev/null 2>&1 && echo "master" || echo "develop")
Then get the full diff and changed file list:
bash
git diff <base>...HEAD --name-only
git diff <base>...HEAD
Store the diff output — you will pass it to review agents.
Also detect the project stack:
bash
undefined
检测基准分支:
bash
git rev-parse --verify main >/dev/null 2>&1 && echo "main" || (git rev-parse --verify master >/dev/null 2>&1 && echo "master" || echo "develop")
然后获取完整差异内容和已更改文件列表:
bash
git diff <base>...HEAD --name-only
git diff <base>...HEAD
保存差异输出——你需要将其传递给审查Agent。
同时检测项目技术栈:
bash
undefined

Check if React/Next.js project

检查是否为React/Next.js项目

cat package.json 2>/dev/null | jq -r '.dependencies // {} | keys[]' | grep -E '^(react|next)$'
undefined
cat package.json 2>/dev/null | jq -r '.dependencies // {} | keys[]' | grep -E '^(react|next)$'
undefined

Step 2: Parallel Review (Agent Team)

步骤2:并行审查(Agent团队)

2a. Create Team

2a. 创建团队

TeamCreate  team_name: "quality-gate"  description: "Parallel quality review of branch changes"
TeamCreate  team_name: "quality-gate"  description: "Parallel quality review of branch changes"

2b. Create Review Tasks

2b. 创建审查任务

Create one
TaskCreate
per review dimension. Skip Task 1 if the project does not use React/Next.js.
Each task
description
MUST include:
  1. The full diff from Step 1 (if diff exceeds ~50KB, list changed files and instruct teammate to read files directly)
  2. The list of changed files
  3. The skill command to invoke and review instructions (see table below)
  4. The classification rules (see below)
  5. The required output format (see below)
  6. Instruction: Do NOT modify any files. Report findings only.
  7. Instruction: Send findings to the lead via
    SendMessage
    with
    type: "message"
    and
    recipient: "lead"
  8. Instruction: Mark task completed via
    TaskUpdate
    with
    status: "completed"
    after sending findings
TasksubjectactiveFormSkill command & instructions
1Review React/Next.js best practicesReviewing React best practices
/vercel-react-best-practices Review ONLY the changed code in the diff against the rules. Categorize each finding as FIX or NITPICK
2Review SOLID principlesReviewing SOLID principles
/applying-solid-principles Review ONLY the changed code in the diff against SOLID principles and clean code practices. Categorize each finding as FIX or NITPICK
3Review securityReviewing security
/security-review Review ONLY the changed code in the diff against the security checklist. Categorize each finding as FIX or NITPICK
4Review simplification opportunitiesReviewing simplification
/simplify Review ONLY the changed code in the diff for simplification opportunities (clarity, consistency, maintainability). Categorize each finding as FIX or NITPICK. Do NOT modify any files — report only.
5Review code slopReviewing code slop
/code-slop
but override: Do NOT modify any files. Instead, identify all slop issues and report them in FIX/NITPICK format below.
为每个审查维度创建一个
TaskCreate
如果项目不使用React/Next.js,请跳过任务1。
每个任务的
description
必须包含:
  1. 步骤1中的完整差异内容(如果差异超过约50KB,请列出已更改文件并指示团队成员直接读取文件)
  2. 已更改文件列表
  3. 要调用的skill命令和审查说明(见下表)
  4. 分类规则(见下文)
  5. 要求的输出格式(见下文)
  6. 说明:请勿修改任何文件。仅报告发现的问题。
  7. 说明:通过
    SendMessage
    将发现的问题发送给负责人,参数为
    type: "message"
    recipient: "lead"
  8. 说明:发送发现的问题后,通过
    TaskUpdate
    将任务状态标记为
    status: "completed"
任务主题活动状态Skill命令 & 说明
1审查React/Next.js最佳实践正在审查React最佳实践
/vercel-react-best-practices 仅针对差异中的已更改代码,对照规则进行审查。将每个发现的问题分类为FIX(必须修复)或NITPICK(可选优化)
2审查SOLID原则正在审查SOLID原则
/applying-solid-principles 仅针对差异中的已更改代码,对照SOLID原则和整洁代码实践进行审查。将每个发现的问题分类为FIX或NITPICK
3安全审查正在进行安全审查
/security-review 仅针对差异中的已更改代码,对照安全检查清单进行审查。将每个发现的问题分类为FIX或NITPICK
4审查简化优化机会正在审查简化优化
/simplify 仅针对差异中的已更改代码,寻找简化优化机会(清晰度、一致性、可维护性)。将每个发现的问题分类为FIX或NITPICK。请勿修改任何文件——仅报告问题。
5审查冗余代码正在审查冗余代码
/code-slop
需覆盖默认设置:请勿修改任何文件。相反,识别所有冗余代码问题并按照下文的FIX/NITPICK格式报告。

2c. Spawn Teammates (all in parallel)

2c. 生成团队成员(全部并行)

Spawn all teammates in a single response using the
Task
tool with
team_name: "quality-gate"
and each teammate's
name
:
nameAssigned task
react-reviewer
Task 1 (skip if not React)
solid-reviewer
Task 2
security-reviewer
Task 3
simplify-reviewer
Task 4
slop-cleaner
Task 5
Each teammate's prompt must instruct them to:
  1. Check
    TaskList
    and claim their assigned task via
    TaskUpdate
    with
    status: "in_progress"
    and
    owner: "<their-name>"
  2. Invoke the designated skill via the
    Skill
    tool with the review instructions
  3. Format findings per the output format below
  4. Send findings to the lead via
    SendMessage
    with
    type: "message"
    ,
    recipient: "lead"
    , and
    summary: "<reviewer-name> findings"
  5. Mark task completed via
    TaskUpdate
    with
    status: "completed"
在单个响应中使用
Task
工具生成所有团队成员,参数为
team_name: "quality-gate"
以及每个成员的
name
名称分配的任务
react-reviewer
任务1(非React项目则跳过)
solid-reviewer
任务2
security-reviewer
任务3
simplify-reviewer
任务4
slop-cleaner
任务5
每个团队成员的提示必须指示他们:
  1. 查看
    TaskList
    并通过
    TaskUpdate
    认领分配的任务,参数为
    status: "in_progress"
    owner: "<their-name>"
  2. 通过
    Skill
    工具调用指定的skill,并遵循审查说明
  3. 按照下文的输出格式整理发现的问题
  4. 通过
    SendMessage
    将发现的问题发送给负责人,参数为
    type: "message"
    recipient: "lead"
    summary: "<reviewer-name> findings"
  5. 通过
    TaskUpdate
    将任务状态标记为
    status: "completed"

2d. Assign Tasks

2d. 分配任务

After spawning, assign each task to its teammate via
TaskUpdate
with
owner: "<teammate-name>"
.
生成团队成员后,通过
TaskUpdate
将每个任务分配给对应的成员,参数为
owner: "<teammate-name>"

Classification Rules (include in each task description)

分类规则(需包含在每个任务描述中)

FIX (will be auto-applied):
  • Bugs or logic errors
  • Security vulnerabilities
  • Performance issues with measurable impact
  • Clear violations of critical rules
  • Obvious simplifications that reduce complexity without trade-offs
NITPICK (user decides):
  • Style preferences or minor readability tweaks
  • Debatable architectural choices
  • Low-impact optimizations
  • "Nice to have" improvements
FIX(将自动应用):
  • 漏洞或逻辑错误
  • 安全漏洞
  • 有可衡量影响的性能问题
  • 明显违反关键规则的情况
  • 无需权衡即可降低复杂度的明显简化优化
NITPICK(由用户决定):
  • 风格偏好或可读性小调整
  • 有争议的架构选择
  • 低影响的优化
  • “锦上添花”的改进

Required Output Format (include in each task description)

要求的输出格式(需包含在每个任务描述中)

undefined
undefined

FIX

FIX

  • file/path.ts:42
    — [RULE-ID] Description of the issue. Suggested fix: <concrete suggestion>
  • file/path.ts:85
    — [RULE-ID] Description. Suggested fix: <suggestion>
  • file/path.ts:42
    — [规则ID] 问题描述。建议修复方案:<具体建议>
  • file/path.ts:85
    — [规则ID] 问题描述。建议修复方案:<建议>

NITPICK

NITPICK

  • file/path.ts:15
    — [RULE-ID] Description. Suggestion: <suggestion>
  • file/path.ts:15
    — [规则ID] 问题描述。建议:<建议>

NO ISSUES

无问题

(use this section if nothing found in a category)

If no issues at all, return: `No issues found.`
(如果某类别未发现问题,则使用此部分)

如果完全没有发现问题,请返回:`未发现任何问题。`

Step 3: Consolidate Findings and Tear Down Team

步骤3:整合发现的问题并解散团队

3a. Collect Results

3a. 收集结果

Monitor
TaskList
until all review tasks reach
completed
status. Findings arrive automatically via
SendMessage
from each teammate.
监控
TaskList
,直到所有审查任务状态变为
completed
。每个团队成员将通过
SendMessage
自动发送发现的问题。

3b. Shut Down Team

3b. 解散团队

Send
SendMessage
with
type: "shutdown_request"
to each teammate. After all teammates confirm shutdown, call
TeamDelete
.
通过
SendMessage
向每个团队成员发送
type: "shutdown_request"
的消息。所有成员确认解散后,调用
TeamDelete

3c. Consolidate

3c. 整合结果

  1. Collect all FIX items across all reviewers
  2. Deduplicate overlapping findings on the same file:line
  3. Display a summary:
undefined
  1. 收集所有审查人员提交的FIX
  2. 对同一文件:行的重复发现进行去重
  3. 显示汇总信息:
undefined

Quality Gate Results

质量门禁结果

Fixes to auto-apply: N items
  • [React] file:line — description (x items)
  • [SOLID] file:line — description (x items)
  • [Security] file:line — description (x items)
  • [Simplify] file:line — description (x items)
  • [Slop Cleaner] file:line — description (x items) Nitpicks for review: N items
undefined
将自动应用的修复项: N项
  • [React] 文件:行 — 描述(共x项)
  • [SOLID] 文件:行 — 描述(共x项)
  • [安全] 文件:行 — 描述(共x项)
  • [简化优化] 文件:行 — 描述(共x项)
  • [冗余代码清理] 文件:行 — 描述(共x项) 待审查的可选优化项: N项
undefined

Step 4: Auto-Fix

步骤4:自动修复

Apply all FIX items to the codebase:
  • Read each affected file
  • Apply the suggested fixes using the Edit tool
  • After all fixes, run the project's linter/formatter if configured (check package.json scripts for lint/format)
将所有FIX项应用到代码库:
  • 读取每个受影响的文件
  • 使用Edit工具应用建议的修复方案
  • 所有修复完成后,如果项目配置了代码检查/格式化工具,请运行项目的linter/formatter(检查package.json的scripts中的lint/format命令)

Step 5: Present Nitpicks

步骤5:展示可选优化项

If there are nitpicks, display them grouped by category and use AskUserQuestion:
undefined
如果存在可选优化项,请按类别分组展示,并使用AskUserQuestion:
undefined

Nitpicks for your review

待你审查的可选优化项

React/Next.js:
  • file:line
    — description — suggestion
SOLID:
  • file:line
    — description — suggestion
Security:
  • file:line
    — description — suggestion
Simplification:
  • file:line
    — description — suggestion
Slop Cleaner:
  • file:line
    — description — suggestion

Ask: "Which nitpicks should I apply?" with options:
- All of them
- None
- Let me pick (then list individually)
React/Next.js:
  • 文件:行
    — 描述 — 建议
SOLID:
  • 文件:行
    — 描述 — 建议
安全:
  • 文件:行
    — 描述 — 建议
简化优化:
  • 文件:行
    — 描述 — 建议
冗余代码清理:
  • 文件:行
    — 描述 — 建议

提问:“应应用哪些可选优化项?”,选项包括:
- 全部应用
- 都不应用
- 让我选择(然后逐个列出)

Step 6: Apply Selected Nitpicks

步骤6:应用选定的可选优化项

Apply whichever nitpicks the user selected.
应用用户选择的所有可选优化项。

Step 7: Commit & Push (if changes made)

步骤7:提交并推送(如果有更改)

If any changes were applied (fixes or nitpicks):
bash
git add .
git commit -m "refactor: apply quality gate fixes"
If a remote branch exists and the branch was already pushed:
bash
git push
如果应用了任何更改(修复项或可选优化项):
bash
git add .
git commit -m "refactor: apply quality gate fixes"
如果远程分支已存在且当前分支已推送过:
bash
git push

Execution Notes

执行说明

  • Requires:
    CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1
    environment variable in settings
  • Total teammates: 4-5 (skip react-reviewer if not a React project)
  • Team lifecycle:
    TeamCreate
    at Step 2a,
    TeamDelete
    at Step 3b
  • All review teammates are read-only — they report findings via SendMessage, the lead applies fixes
  • Teammate idle is normal — teammates go idle after each turn; do not treat idle notifications as errors
  • Deduplication matters — multiple reviewers may flag the same issue differently; apply only once
  • Preserve behavior — fixes must not change functionality, only improve quality
  • Be surgical — only modify code that was part of the original diff, do not refactor unrelated code
  • 要求:设置中需包含环境变量
    CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1
  • 团队成员总数:4-5人(非React项目则跳过react-reviewer)
  • 团队生命周期:步骤2a中创建
    TeamCreate
    ,步骤3b中调用
    TeamDelete
  • 所有审查团队成员均为只读——他们通过SendMessage报告问题,由负责人应用修复
  • 团队成员处于空闲状态是正常的——成员在每轮操作后会进入空闲状态;请勿将空闲通知视为错误
  • 去重很重要——多个审查人员可能会以不同方式标记同一问题;仅应用一次修复
  • 保留原有功能——修复不得改变功能,仅提升代码质量
  • 精准操作——仅修改原始差异中的代码,不要重构无关代码