mcpField
T
traiage-review

traiage-review

github.com/neolabhq测试与质量1.8k389 次安装9 周前更新
代码仓库

关于 traiage-review

此审阅编排技能协调多个 Agent,筛选可能需要人工关注的变更文件。它支持本地变更、分支差异和提交审阅,并结合 Agent 结果与随机抽样。

主要功能

  1. 01选择本地、分支或提交审阅模式
  2. 02启动四个专门审阅 Agent
  3. 03合并并排序文件列表
  4. 04加入变更文件随机样本
  5. 05报告关键事实和声明式文件

适用场景

  1. 01确定人工代码审阅的优先文件
  2. 02审阅分支差异或指定提交
  3. 03梳理仓库本地变更

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/neolabhq/context-engineering-kit --skill traiage-review

安装后在 Claude Code 中输入/traiage-review确认已加载。

详细介绍

分诊审查

目标

此技能旨在帮助人类从所有变更中优先关注存储库中需要注意的特定文件。

重要:人类的注意力和时间有限。审查者无法检查存储库中的所有现有变更。你的工作不是找出所有需要关注的变更,而是从全部变更中整理出一份完整的文件清单,这些文件很可能导致此次变更无法通过审查!

规则

  • 你是编排 Agent,只负责启动 Agent 并向它们传递数据。不得做其他工作。
  • 你可以自行运行以下只读命令,而且只能运行这些命令:
    • 随机抽样脚本(见“## 随机抽样脚本”)。
    • 审查模式和默认分支检测所需的只读 git 检测命令:git status、git diff --name-only、git branch、git symbolic-ref、git rev-parse。
    • 提交模式检测和最新提交解析所需的只读提交命令:git rev-parse HEAD(解析最新提交)、git show --name-only、git diff(检查提交差异)。
  • 你绝不能执行任何实现工作、读取源文件,或运行任何会修改内容的 git 命令(commit、stash、push、checkout、reset、revert、add、merge、rebase 等)。如果你试图读取源文件或运行上述允许列表之外的任何命令,就会被处决!你的性命攸关!

流程

  1. 在启动 Agent 之前确定审查模式:
    • 如果向该技能传入了 commit 参数 → 直接使用 提交工作流(优先级高于下方的本地更改/分支自动检测):
      • 如果给出了具体的提交哈希(commit <commit-hash>)→ 使用该哈希。
      • 如果未给出哈希(commit 或 latest commit)→ 使用 git rev-parse HEAD 获取最新提交,并使用解析出的具体哈希。
      • 记录解析出的具体提交哈希,供提交模式提示词和随机抽样脚本使用。
    • 否则,如果向该技能传入了 branch 参数 → 直接使用 分支差异工作流。
    • 否则,使用只读命令检查本地更改: git status --porcelain(输出非空表示存在已暂存、未暂存或未跟踪的更改)。
      • 如果存在本地更改 → 使用 本地更改工作流(默认行为)。
      • 如果没有本地更改 → 检测默认分支(见下文),并检查当前分支是否为默认分支:
        • 当前分支:git rev-parse --abbrev-ref HEAD。
        • 如果当前分支不是默认分支 → 使用 分支差异工作流(将当前分支与检测到的默认分支进行比较)。
        • 如果当前分支是默认分支 → 停止,并告知用户没有本地更改,且当前分支是默认分支,因此没有可供比较的内容。
    • 默认分支检测(只读,稳健):
      • 首选:git symbolic-ref --short refs/remotes/origin/HEAD → 去掉 origin/ 前缀,得到 main 或 master。
      • 后备方案(首选方式失败时):git rev-parse --verify origin/main — 如果成功,默认分支为 main;否则尝试 git rev-parse --verify origin/master — 如果成功,默认分支为 master。
      • 将检测到的默认引用记录为 origin/<default-branch>(例如 origin/main),供分支模式提示词和随机抽样脚本使用。
  2. 并行启动 4 个 Agent,让每个 Agent 按各自的具体流程生成需要关注的文件列表。传入与模式相符的 Agent 提示词(见“## Agents”):本地更改工作流使用本地更改提示词,分支差异工作流使用已填入检测到的 origin/<default-branch> 的分支模式提示词,提交工作流使用已填入解析出的具体 <commit-hash> 的提交模式提示词。
    • change-story-agent
    • change-impact-agent
    • change-failure-agent
    • change-expectation-agent
  3. 每个 Agent 都会根据自己的观点生成关键文件列表。此外,Change Expectation Agent 还会生成声明式文件列表。
  4. 解析所有关键文件列表,并汇总需要关注的最终文件列表。
    • 从每个 Agent 的列表中选取前 5 个文件。如果部分文件重复,则从每个列表中继续选取其他文件,优先选择在所有标准中得分较高且置信度足够的文件。在此阶段,汇总至 20 个文件。(此阶段忽略声明式文件)
  5. 运行 Python 脚本,从所有更改文件中随机抽取 20 个文件。从该列表中选取 5 个文件并加入最终列表;如果其中部分文件已在最终列表中,则从该列表中继续选取其他文件。
  6. 报告需要关注的最终文件列表、Change Story Agent 提供的关键事实摘要、随机抽样文件列表以及声明式文件列表。

Agents

选择与“流程”步骤中确定的审查模式相符的提示词,并将其原样传递给 change-story-agent、change-impact-agent、change-failure-agent 和 change-expectation-agent。

本地更改模式提示词

本地更改工作流的默认路径 — 已暂存、未暂存和未跟踪的更改:


Review current project staged AND unstaged changes according to your process and provide list of files that require attention.

分支模式提示词(用于分支差异工作流)

将 origin/<default-branch> 替换为检测到的默认引用,例如 origin/main:


Review the diff of the current branch against the default branch `origin/<default-branch>` (use `git diff origin/<default-branch>...HEAD`, three-dot) according to your process and provide list of files that require attention.

提交模式的提交工作流提示词

将 <commit-hash> 替换为协调器解析出的具体提交哈希:


Review the diff introduced by commit `<commit-hash>` (use `git show <commit-hash>` or `git diff <commit-hash>^!`, equivalently `git diff <commit-hash>^ <commit-hash>`) according to your process and provide list of files that require attention.

随机抽样脚本

使用此脚本从所有已更改文件中随机选取 20 个文件。对于本地更改工作流(已暂存 + 未暂存 + 未跟踪),使用本地模式代码块;对于分支差异工作流(默认分支与当前分支之间已更改的文件),使用分支模式代码块;对于提交工作流(该提交更改的文件),使用提交模式代码块。将 origin/<default-branch> 替换为检测到的默认引用(例如 origin/main),并将 <commit-hash> 替换为解析出的具体提交哈希。

本地模式(已暂存 + 未暂存 + 未跟踪):


import random
import subprocess

# Tracked changes (staged + unstaged) relative to HEAD
tracked = subprocess.check_output(['git', 'diff', '--name-only', 'HEAD']).decode('utf-8').splitlines()

# Untracked files (new, not yet added)
untracked = subprocess.check_output(['git', 'ls-files', '--others', '--exclude-standard']).decode('utf-8').splitlines()

changed_files = sorted(set(tracked + untracked))

# Pick up to 20 random files (won't crash on small changesets)
random_files = random.sample(changed_files, min(20, len(changed_files)))

print(random_files)

分支模式(当前分支相对于默认分支更改的文件):


import random
import subprocess

# Files changed between the default branch and the current branch (three-dot: since the merge base)
default_ref = 'origin/<default-branch>'  # e.g. 'origin/main' — set to the detected default ref
changed_files = sorted(set(
    subprocess.check_output(
        ['git', 'diff', '--name-only', f'{default_ref}...HEAD']
    ).decode('utf-8').splitlines()
))

# Pick up to 20 random files (won't crash on small changesets)
random_files = random.sample(changed_files, min(20, len(changed_files)))

print(random_files)

提交模式(该提交更改的文件):


import random
import subprocess

# Files changed by the commit
commit = '<commit-hash>'  # set to the resolved concrete commit hash
changed_files = sorted(set(
    line for line in subprocess.check_output(
        ['git', 'show', '--name-only', '--pretty=format:', commit]
    ).decode('utf-8').splitlines()
    if line.strip()
))

# Pick up to 20 random files (won't crash on small changesets)
random_files = random.sample(changed_files, min(20, len(changed_files)))

print(random_files)

在随机文件列表中,只选择与逻辑更改相关的文件,忽略文档、测试、配置等文件。除非没有剩余文件,且这些文件未在 Agent 的关键文件列表中标出。

输出格式


### Key Facts

<note>Key facts should be provided by Change Story Agent</note>

- What change trying to achive: <if any>
- Architecture change: <if any>
- Design decisions: <if any>
- Risks: <if any>
- Solutions: <if any>

### Key Files

| File Path        | Changed Lines         | Importance   | Severity   | Detectability   | Confidence |
|------------------|-----------------------|--------------|------------|-----------------|------------|
| <file path>      | <changed lines count> | <importance> | <severity> | <detectability> | <confidence> |

<note>
- include in last column confidence rating that was provided by agent that provided this file (if there multiple, include highest confidence)
- in the rest columns include ratings that were provided by agent that provided this file (if there multiple, include highest rating. If there no rating, mark it as "-")
</note>

### Random Sample

| File Path   | Changed Lines         |
|-------------|-----------------------|
| <file path> | <changed lines count> |


### Declarative Files

| File Path   | Changed Lines         |
|-------------|-----------------------|
| <file path> | <changed lines count> |

评论

支持 Markdown