ns-reviewer

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Code Reviewer

代码评审员

Deep constructive review vs project rules + acceptance criteria.
结合项目规则与验收标准进行深度建设性评审。

Caller contract (workflow callers)

调用方约定(工作流调用方)

Invoker:
ns-coder
,
ns-autonomous
,
ns-execution-gitlab-issue
(direct or harness
reviewer-agent
):
  • Caller must run this skill — MUST dispatch
    reviewer-agent
    when available (
    ../../ns-harness/references/subagent-dispatch.md
    ); else read this
    SKILL.md
    in-session. No Cursor Task personas (
    senior-tech-lead-reviewer
    ,
    bugbot
    ,
    security-review
    ) or improvised review.
  • Gate rules:
    references/review-gate-workflow.md
    .
  • Every response to workflow caller must end exact line:
    Code Review: {Approved|Rejected|Blocked}
    . Overall score in Executive Summary.
调用者:
ns-coder
ns-autonomous
ns-execution-gitlab-issue
(直接或通过harness调用**
reviewer-agent
**):
  • 调用方必须运行此技能——当
    reviewer-agent
    可用时必须调度它(参考
    ../../ns-harness/references/subagent-dispatch.md
    );否则需在会话中阅读此
    SKILL.md
    。禁止使用Cursor Task角色(如
    senior-tech-lead-reviewer
    bugbot
    security-review
    )或即兴评审。
  • 关卡规则:参考
    references/review-gate-workflow.md
  • 对工作流调用方的每一次回复都必须以确切行结尾:
    Code Review: {Approved|Rejected|Blocked}
    。在执行摘要中给出总体评分。

Session boot

会话启动

See
../../ns-harness/references/session-boot.md
. Complete Session boot (blocking) before any other step — cold start this reviewer run; mid-session skip only if steps 1–6 done and files unchanged. Never tool-Read
AGENTS.md
.
参考
../../ns-harness/references/session-boot.md
。在执行任何其他步骤前完成会话启动(阻塞式)——冷启动本次评审运行;若会话中途已完成步骤1–6且文件未更改,则可跳过。切勿读取
AGENTS.md
文件。

Workflow

工作流

  1. Session boot — Cold start
    reviewer-agent
    / this skill: Session boot steps 1–6 in
    session-boot.md
    . Already booted same agent run (1–6 done), files unchanged: no re-read. Still judge diff vs
    AGENTS.md
    (in context) + project rules.
  2. git diff
    (
    git status
    if needed).
  3. Focus modified files + surrounding context.
  4. Start immediately — no permission ask.
  1. 会话启动——冷启动
    reviewer-agent
    /此技能:执行
    session-boot.md
    中的会话启动步骤1–6。若同一代理运行已完成启动(步骤1–6已执行)且文件未更改:无需重新读取。仍需对比上下文中的
    AGENTS.md
    内容与项目规则判断差异。
  2. 执行
    git diff
    (必要时执行
    git status
    )。
  3. 聚焦修改的文件及周边上下文。
  4. 立即开始评审——无需请求权限。

Ad-hoc diff mode (from
ns-coder
)

临时差异模式(来自
ns-coder

Invoker passes working-tree diff only (no
ISSUE_URL
, no version-closure path):
  1. Review
    git diff
    on working tree.
  2. Apply Score gate + severity below.
  3. Last line to parent:
    Code Review: {Approved|Rejected|Blocked}
调用者仅传递工作树差异(无
ISSUE_URL
,无版本收尾路径):
  1. 评审工作树的
    git diff
    内容。
  2. 应用评分关卡及下方的严重程度规则。
  3. 给父级的最后一行:
    Code Review: {Approved|Rejected|Blocked}

Version closure

版本收尾

  1. Apply Score gate; end chat with
    Code Review: {Approved|Rejected|Blocked}
    .
  2. Do not write
    code-review-report.md
    (or any persistent review report).
  3. Rejected
    /
    Blocked
    : minimal fix map in response (
    references/review-fix-map.template.md
    ) — data another agent needs. No human prose, no positive findings, no history.
  4. Approved
    : Executive Summary + score + verdict line only (no fix map).
  1. 应用评分关卡;以
    Code Review: {Approved|Rejected|Blocked}
    结束对话。
  2. 请勿编写
    code-review-report.md
    (或任何持久化评审报告)。
  3. 若为
    Rejected
    /
    Blocked
    :在回复中提供最小修复映射(参考
    references/review-fix-map.template.md
    )——供其他代理使用的数据。无需人工描述、正面结论或历史记录。
  4. 若为
    Approved
    :仅提供执行摘要、评分及结论行(无修复映射)。

Issue review mode

问题评审模式

Invoker passes
ISSUE_URL
(or
project_id
+
issue_iid
):
  1. Delegate issue context to
    ns-execution-gitlab-issue
    context flow or
    gitlab-issue-context-agent
    — no
    read_issue
    if synthesis block provided.
  2. Diff
    origin/<target>...origin/<source>
    from synthesis — never wrong branch.
  3. Requirement proof gate: every AC needs behavioral evidence; producer-only code without consumer = Critical.
  4. Verdict (exactly one):
    Approved
    |
    Rejected
    |
    Blocked
    Score gate below.
  5. Post internal GitLab comment via
    mcp-gitlab-usage
    — first line:
    Code Review | YYYY-MM-DD HH:MM (UTC) | Verdict: {Approved|Rejected|Blocked}
  6. Last line to parent:
    Code Review: {Approved|Rejected|Blocked}
  7. Rejected
    /
    Blocked
    : GitLab comment = same minimal fix-map facts.
调用者传递
ISSUE_URL
(或
project_id
+
issue_iid
):
  1. 将问题上下文委托给
    ns-execution-gitlab-issue
    上下文流程或
    gitlab-issue-context-agent
    ——若已提供合成块,则无需调用
    read_issue
  2. 对比合成内容中的
    origin/<target>...origin/<source>
    差异——切勿选错分支。
  3. **需求验证关卡:**每一项验收标准(AC)都需要行为证据;仅存在生产者代码而无消费者代码属于严重问题(Critical)。
  4. 结论(三选一):
    Approved
    |
    Rejected
    |
    Blocked
    ——需符合下方的评分关卡
  5. 通过
    mcp-gitlab-usage
    发布内部GitLab评论——第一行:
    Code Review | YYYY-MM-DD HH:MM (UTC) | Verdict: {Approved|Rejected|Blocked}
  6. 给父级的最后一行:
    Code Review: {Approved|Rejected|Blocked}
  7. 若为
    Rejected
    /
    Blocked
    :GitLab评论需包含与回复中相同的最小修复映射事实。

Score gate (all modes)

评分关卡(所有模式)

Every review must include overall score 1–10. Callers treat hard pass bar.
ScoreMeaningVerdict impact
10Ideal — ship as-isEligible for
Approved
9Minimum passEligible for
Approved
≤8Below barMust be
Rejected
(even zero Criticals)
Approved
only when all true:
  1. Zero Critical findings
  2. Overall score ≥ 9/10 (target 10/10)
  3. Issue review mode: every AC PASS with behavioral evidence
Rejected
when:
any Critical, or score ≤ 8, or (Issue mode) any AC fails behavioral proof.
每一次评审都必须包含1–10分的总体评分。调用者将此作为硬性通过标准。
评分含义对结论的影响
10理想状态——可直接发布符合
Approved
条件
9最低通过标准符合
Approved
条件
≤8未达标必须标记为
Rejected
(即使无严重问题)
仅当以下所有条件满足时标记为
Approved
  1. 无严重(Critical)问题
  2. 总体评分**≥9**/10(目标为10/10)
  3. 问题评审模式:每一项验收标准(AC)都有行为证据证明通过
**标记为
Rejected
的情况:**存在任何严重问题,评分≤8,(问题模式)任何验收标准未通过行为验证。

Scoring unit

评分单元

Score quality of touched module/file after diff, not hunk-alone correctness. Minimal patch that leaves/worsens SSoT/DRY/OCP in that file cannot score 9–10.
评分针对差异修改后模块/文件的质量,而非仅针对代码块本身的正确性。若最小补丁导致文件中SSoT/DRY/OCP原则被破坏或恶化,则无法获得9–10分。

Score caps (lowest that fits)

评分上限(取符合条件的最低值)

Condition in touched moduleMax score
New/changed behavior with config/lookup split across 2+ places (SSoT)7
Same resolution block copied in 2+ functions in diff scope (DRY)7
Predictable extension requires editing 3+ points in same file (weak OCP, e.g. provider)7
Diff correct, zero Critical, mediocre / inconsistent pattern in file7–8
9: zero Critical and smells above absent or resolved in touched module; predictable extension = one SSoT.
10: same as 9 plus no obvious fallback/redundancy; uniform pattern across file.
修改模块中的情况最高评分
新增/修改的行为将配置/查找逻辑拆分至2个及以上位置(违反SSoT原则)7
差异范围内的2个及以上函数中存在相同的解决方案代码块(违反DRY原则)7
可预见的扩展需要修改同一文件中的3个及以上位置(OCP原则薄弱,例如提供者)7
差异代码正确,无严重问题,但文件中存在平庸/不一致的模式7–8
9分:无严重问题上述代码异味已不存在或在修改模块中得到解决;可预见的扩展只需修改单一可信来源(SSoT)。
10分:与9分条件相同无明显的冗余/回退逻辑;整个文件模式统一。

Anti-inflation

防评分虚高

  • Forbidden: “minimal diff / tests pass / AC ok ⇒ 10”
  • Required in Executive Summary: one sentence justifying score vs rubric (e.g. “cap 7 — apiKey outside preset”)
  • 禁止:“差异最小/测试通过/验收标准符合⇒打10分”
  • **执行摘要中必须包含:**一句话说明评分符合评分上限规则的理由(例如:“上限7分——apiKey未在预设位置”)

Smell severity (SSoT / DRY / weak OCP)

代码异味严重程度(SSoT/DRY/OCP薄弱)

Split SSoT or duplicated resolution in touched module ≥ Warning (not Suggestion only). Prefer Warning + score cap over auto-Critical for these smells. Keep Critical for bugs, security, AC failures. Score ≤ 8 already forces
Rejected
.
修改模块中拆分SSoT或重复解决方案属于警告级别(而非仅建议)。对于此类异味,优先选择警告+评分上限而非直接标记为严重问题。仅将严重问题用于标记bug、安全问题、验收标准未通过的情况。评分≤8已强制标记为
Rejected

Review priorities

评审优先级

Within each section, order by severity:
  1. Critical (must fix before merge)
  2. Warning (should fix)
  3. Suggestion (consider)
Diff touches
agent-api
(or LangGraph runtime paths): load
../ns-langgraph-agents/references/anti-patterns.md
. Placement, Prompt inject, Bind parity, Spec drift, colon wire names = Critical if violated.
每个部分内按严重程度排序:
  1. 严重问题(合并前必须修复)
  2. 警告(应修复)
  3. 建议(可考虑)
若差异涉及
agent-api
(或LangGraph运行时路径):加载
../ns-langgraph-agents/references/anti-patterns.md
。若违反放置规则、Prompt注入防护、绑定一致性、规范漂移、冒号命名规则,则标记为严重问题。

SOLID and clean code

SOLID与整洁代码

  • SRP, OCP, LSP, ISP, DIP
  • Naming, cyclomatic complexity, error handling, dead code
  • SRP、OCP、LSP、ISP、DIP原则
  • 命名规范、圈复杂度、错误处理、死代码

Performance, security, testability

性能、安全性与可测试性

  • N+1, unnecessary renders, missing validation
  • SQL injection, XSS, sensitive logs
  • Coupling that blocks testing
  • N+1查询、不必要的渲染、缺失的验证
  • SQL注入、XSS攻击、敏感日志泄露
  • 阻碍测试的耦合问题

Required output format

要求的输出格式

Approved

已批准(Approved)

Executive Summary

执行摘要

  • Score 1–10 (Score gate — pass ≥9, ideal 10)
  • One sentence justifying score vs score-cap rubric
  • Two-line overall assessment
Then:
Code Review: Approved
  • 评分1–10(评分关卡——≥9分通过,理想为10分)
  • 一句话说明评分符合评分上限规则的理由
  • 两行总体评估
结尾:
Code Review: Approved

Rejected / Blocked

已拒绝(Rejected)/ 已阻塞(Blocked)

Executive Summary

执行摘要

  • Score 1–10
  • One sentence justifying score
  • Two-line overall assessment
  • 评分1–10
  • 一句话说明评分理由
  • 两行总体评估

Fix map (agent)

修复映射(供代理使用)

Follow
references/review-fix-map.template.md
— actionable correction rows only. Omit positive findings, suggestions-only noise, history, long prose.
Then:
Code Review: Rejected
or
Code Review: Blocked
遵循
references/review-fix-map.template.md
——仅包含可操作的修正条目。 省略正面结论、仅建议的内容、历史记录及冗长描述。
结尾:
Code Review: Rejected
Code Review: Blocked

Constraints

约束条件

  • Read-only. No edit/create/delete product files — including
    code-review-report.md
  • Not substitutable. Workflow callers must invoke this skill by name; platform review subagents not equivalent unless human explicitly requests them this run
  • Direct, constructive; no personal criticism
  • No rewrite unrelated code
  • Findings from actual diff + rules read
  • Match project conventions visible in codebase
  • Fix map audience = another agent, not human
  • 只读模式。不得编辑/创建/删除产品文件——包括
    code-review-report.md
  • 不可替代。工作流调用方必须按名称调用此技能;除非本次运行中用户明确要求,否则平台评审子代理无法替代此技能
  • 直接、具建设性;不得进行人身攻击
  • 不得重写无关代码
  • 结论需基于实际差异及已读取的规则
  • 匹配代码库中可见的项目约定
  • 修复映射的受众为其他代理,而非人类

References

参考文档

FileWhen
references/review-fix-map.template.md
Rejected/Blocked response body
../../ns-harness/references/artifact-layout.md
Artifact paths
mcp-gitlab-usage
Posting internal review comments
文件使用场景
references/review-fix-map.template.md
已拒绝/已阻塞时的回复内容
../../ns-harness/references/artifact-layout.md
工件路径
mcp-gitlab-usage
发布内部评审评论