quality-gate
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseQuality Gate
质量门禁
!IMPORTANT: Follow this process exactly. Do not skip steps.
Arguments: (optional) — base branch to diff against. If omitted, auto-detect.
$0!重要提示:请严格遵循此流程,不要跳过任何步骤。
参数: (可选)——用于对比的基准分支。如果省略,将自动检测。
$0Step 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>...HEADStore 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
undefinedCheck if React/Next.js project
检查是否为React/Next.js项目
cat package.json 2>/dev/null | jq -r '.dependencies // {} | keys[]' | grep -E '^(react|next)$'
undefinedcat package.json 2>/dev/null | jq -r '.dependencies // {} | keys[]' | grep -E '^(react|next)$'
undefinedStep 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 per review dimension. Skip Task 1 if the project does not use React/Next.js.
TaskCreateEach task MUST include:
description- The full diff from Step 1 (if diff exceeds ~50KB, list changed files and instruct teammate to read files directly)
- The list of changed files
- The skill command to invoke and review instructions (see table below)
- The classification rules (see below)
- The required output format (see below)
- Instruction: Do NOT modify any files. Report findings only.
- Instruction: Send findings to the lead via with
SendMessageandtype: "message"recipient: "lead" - Instruction: Mark task completed via with
TaskUpdateafter sending findingsstatus: "completed"
| Task | subject | activeForm | Skill command & instructions |
|---|---|---|---|
| 1 | Review React/Next.js best practices | Reviewing React best practices | |
| 2 | Review SOLID principles | Reviewing SOLID principles | |
| 3 | Review security | Reviewing security | |
| 4 | Review simplification opportunities | Reviewing simplification | |
| 5 | Review code slop | Reviewing code slop | |
为每个审查维度创建一个。如果项目不使用React/Next.js,请跳过任务1。
TaskCreate每个任务的必须包含:
description- 步骤1中的完整差异内容(如果差异超过约50KB,请列出已更改文件并指示团队成员直接读取文件)
- 已更改文件列表
- 要调用的skill命令和审查说明(见下表)
- 分类规则(见下文)
- 要求的输出格式(见下文)
- 说明:请勿修改任何文件。仅报告发现的问题。
- 说明:通过将发现的问题发送给负责人,参数为
SendMessage和type: "message"recipient: "lead" - 说明:发送发现的问题后,通过将任务状态标记为
TaskUpdatestatus: "completed"
| 任务 | 主题 | 活动状态 | Skill命令 & 说明 |
|---|---|---|---|
| 1 | 审查React/Next.js最佳实践 | 正在审查React最佳实践 | |
| 2 | 审查SOLID原则 | 正在审查SOLID原则 | |
| 3 | 安全审查 | 正在进行安全审查 | |
| 4 | 审查简化优化机会 | 正在审查简化优化 | |
| 5 | 审查冗余代码 | 正在审查冗余代码 | |
2c. Spawn Teammates (all in parallel)
2c. 生成团队成员(全部并行)
Spawn all teammates in a single response using the tool with and each teammate's :
Taskteam_name: "quality-gate"name| name | Assigned task |
|---|---|
| Task 1 (skip if not React) |
| Task 2 |
| Task 3 |
| Task 4 |
| Task 5 |
Each teammate's prompt must instruct them to:
- Check and claim their assigned task via
TaskListwithTaskUpdateandstatus: "in_progress"owner: "<their-name>" - Invoke the designated skill via the tool with the review instructions
Skill - Format findings per the output format below
- Send findings to the lead via with
SendMessage,type: "message", andrecipient: "lead"summary: "<reviewer-name> findings" - Mark task completed via with
TaskUpdatestatus: "completed"
在单个响应中使用工具生成所有团队成员,参数为以及每个成员的:
Taskteam_name: "quality-gate"name| 名称 | 分配的任务 |
|---|---|
| 任务1(非React项目则跳过) |
| 任务2 |
| 任务3 |
| 任务4 |
| 任务5 |
每个团队成员的提示必须指示他们:
- 查看并通过
TaskList认领分配的任务,参数为TaskUpdate和status: "in_progress"owner: "<their-name>" - 通过工具调用指定的skill,并遵循审查说明
Skill - 按照下文的输出格式整理发现的问题
- 通过将发现的问题发送给负责人,参数为
SendMessage、type: "message"和recipient: "lead"summary: "<reviewer-name> findings" - 通过将任务状态标记为
TaskUpdatestatus: "completed"
2d. Assign Tasks
2d. 分配任务
After spawning, assign each task to its teammate via with .
TaskUpdateowner: "<teammate-name>"生成团队成员后,通过将每个任务分配给对应的成员,参数为。
TaskUpdateowner: "<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)
要求的输出格式(需包含在每个任务描述中)
undefinedundefinedFIX
FIX
- — [RULE-ID] Description of the issue. Suggested fix: <concrete suggestion>
file/path.ts:42 - — [RULE-ID] Description. Suggested fix: <suggestion>
file/path.ts:85
- — [规则ID] 问题描述。建议修复方案:<具体建议>
file/path.ts:42 - — [规则ID] 问题描述。建议修复方案:<建议>
file/path.ts:85
NITPICK
NITPICK
- — [RULE-ID] Description. Suggestion: <suggestion>
file/path.ts:15
- — [规则ID] 问题描述。建议:<建议>
file/path.ts:15
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 until all review tasks reach status. Findings arrive automatically via from each teammate.
TaskListcompletedSendMessage监控,直到所有审查任务状态变为。每个团队成员将通过自动发送发现的问题。
TaskListcompletedSendMessage3b. Shut Down Team
3b. 解散团队
Send with to each teammate. After all teammates confirm shutdown, call .
SendMessagetype: "shutdown_request"TeamDelete通过向每个团队成员发送的消息。所有成员确认解散后,调用。
SendMessagetype: "shutdown_request"TeamDelete3c. Consolidate
3c. 整合结果
- Collect all FIX items across all reviewers
- Deduplicate overlapping findings on the same file:line
- Display a summary:
undefined- 收集所有审查人员提交的FIX项
- 对同一文件:行的重复发现进行去重
- 显示汇总信息:
undefinedQuality 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项
undefinedStep 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:
undefinedNitpicks for your review
待你审查的可选优化项
React/Next.js:
- — description — suggestion
file:line
SOLID:
- — description — suggestion
file:line
Security:
- — description — suggestion
file:line
Simplification:
- — description — suggestion
file:line
Slop Cleaner:
- — description — suggestion
file:line
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 pushExecution Notes
执行说明
- Requires: environment variable in settings
CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1 - Total teammates: 4-5 (skip react-reviewer if not a React project)
- Team lifecycle: at Step 2a,
TeamCreateat Step 3bTeamDelete - 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中创建,步骤3b中调用
TeamCreateTeamDelete - 所有审查团队成员均为只读——他们通过SendMessage报告问题,由负责人应用修复
- 团队成员处于空闲状态是正常的——成员在每轮操作后会进入空闲状态;请勿将空闲通知视为错误
- 去重很重要——多个审查人员可能会以不同方式标记同一问题;仅应用一次修复
- 保留原有功能——修复不得改变功能,仅提升代码质量
- 精准操作——仅修改原始差异中的代码,不要重构无关代码