yzr-coding-review

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

yzr-coding-review

yzr-coding-review

何时不使用

When Not to Use

"何时使用 / 不适用"已在 frontmatter description,正文不重抄。本节只补出路擦边负例
  • 擦边负例:review 中发现安全漏洞 / 明显 bug / 严重性能瓶颈信号 → 只指出"建议另行专项处理", 不展开——本 skill 是设计层审视,不接安全审计 / bug 修复 / 性能调优执行
  • 误触发出路:目标产物不是"审"而是"改 / 写 / 修"(单点修改 / 新功能 / 重写 / 调优 / lint 配置)→ 直接用基础工具或对应专项流程,不套本 skill 的 review 流程
"When to use / Not applicable" is stated in the frontmatter description and will not be repeated here. This section only supplements solutions and edge case negative examples:
  • Edge Case Negative Examples: If security vulnerabilities, obvious bugs, or severe performance bottleneck signals are found during review → only point out "It is recommended to handle this separately in a special project" without expanding on it — this skill focuses on design-level review and does not cover security audits, bug fixes, or performance tuning execution
  • Solutions for Mis-triggering: If the target outcome is not "review" but "modify/write/fix" (single-point modification, new feature, rewriting, tuning, lint configuration) → directly use basic tools or corresponding special processes, do not apply this skill's review process

输入 / 输出

Input / Output

输入(任一形态):
  • 完整代码段(直接粘贴)
  • 文件路径(agent 自己读)
  • git diff / patch(只 review 改动)
  • 项目根目录 + 范围(文件 / 模块 / 类过滤)
输出: 三种产物(对话式分析回答 / 报告形态 / 逐条过),按用户意图路由——各形态定义、 结构模板与切换规则见「工作流 / 步骤」Step 4–6,此处不重抄。
Input (any form):
  • Complete code segment (pasted directly)
  • File path (read by the Agent itself)
  • git diff / patch (only review changes)
  • Project root directory + scope (filter by file/module/class)
Output: Three types of products (conversational analysis response / report format / item-by-item review), routed based on user intent — definitions, structure templates, and switching rules for each format are covered in "Workflow / Steps" Step 4–6, and will not be repeated here.

执行原则 / 边界

Execution Principles / Boundaries

  1. 不主动改文件: 产出是结论 / 报告,用户点头后才走具体重构
  2. 每条发现可追溯: 每条发现映射到至少 1 个 catalog 场景名 / 合理性卡片名
  3. 合理性维度收敛: 只审 设计意图与职责 / 边界条件与错误处理 / 可读性 三个维度;不越界到 bug 修复 / 性能调优执行 / 安全审计(发现这些信号时指出"建议另行专项处理",不展开); 机械可判定项(风格规则 / 格式 / TODO / 文档字符串)归 CI,不占发现项
  4. 产物留在对话内: 报告 / 结论不落成文件,不主动持久化
  1. Do not modify files proactively: The output is conclusions/reports; specific refactoring is only carried out after user confirmation
  2. Each finding is traceable: Each finding maps to at least 1 catalog scenario name / rationality card name
  3. Converge rationality dimensions: Only review three dimensions: design intent and responsibility, boundary conditions and error handling, and readability; do not cross into bug fixes, performance tuning execution, or security audits (when such signals are found, point out "It is recommended to handle this separately in a special project" without expanding); mechanically determinable items (style rules, formatting, TODO, docstrings) belong to CI and are not counted as findings
  4. Products remain in the conversation: Reports/conclusions are not saved as files and are not proactively persisted

评审立场

Review Stance

  • 资深工程师标准: 按生产代码的维护成本审,每条发现给直接结论 + 理由,不模棱两可,不为照顾情绪放水
  • 敢于质疑框架: 问题根因在抽象层 / 模块划分而不在局部写法时,明确指出"局部重构不够,建议结构性调整"并给出方向;不给完整新设计(那是重写,越界),动手仍等用户点头
  • 回到存在理由: 每条判断先问这段代码为什么存在、服务什么场景、删掉 / 合并损失什么;catalog 是召回清单,不是套用模板
  • 洁癖但克制: 高标准不等于凑数——Minor / Nitpick 级发现合并报或放入"不报告项",主表保信噪比
  • 一次看全: 评审时反复自问"当前方案是不是最合理的解法",逻辑 / 结构 / 边界 / 计算经济性看透再下结论;一次输出完整判断,不做表面巡检、不靠多轮往返补齐发现
  • Senior engineer standard: Review based on the maintenance cost of production code, provide direct conclusions + reasons for each finding, be unambiguous, and do not lower standards to accommodate emotions
  • Dare to question frameworks: If the root cause of a problem lies in the abstraction layer/module division rather than local writing, clearly point out "Local refactoring is insufficient; structural adjustment is recommended" and provide directions; do not provide a complete new design (that is rewriting and crosses boundaries), and wait for user confirmation before taking action
  • Return to the reason for existence: Start each judgment by asking why this code exists, what scenarios it serves, and what would be lost if it were deleted/merged; the catalog is a recall list, not a template to be applied rigidly
  • Clean but restrained: High standards do not mean padding findings — Minor/Nitpick-level findings are reported together or placed in "unreported items" to maintain the signal-to-noise ratio of the main list
  • Review comprehensively at once: During review, repeatedly ask "Is the current solution the most reasonable one", fully understand the logic, structure, boundaries, and computational economy before making a conclusion; output complete judgments at once, do not perform superficial inspections, and do not rely on multiple rounds of interactions to complete findings

工作流 / 步骤

Workflow / Steps

Step 1: 收集代码

Step 1: Collect Code

解析输入(代码段 / 路径 / diff / 范围),确定语言 + 行数;行数 > 500 时与用户确认分段粒度(按文件 / 按类 / 按函数)。
Parse the input (code segment / path / diff / scope), determine the language and number of lines; if the number of lines > 500, confirm the segmentation granularity with the user (by file / by class / by function).

Step 2: 加载参考

Step 2: Load References

必读
references/catalog.md
(场景表);按需读
references/severity-rubric.md
(判定严重度时)。
Must read
references/catalog.md
(scenario list); read
references/severity-rubric.md
as needed (when determining severity).

Step 3: 走 catalog 补充

Step 3: Supplement via Catalog

LLM 用 catalog 重构场景卡 + 合理性审视卡片补齐设计层问题;每条映射到 ≥ 1 个场景名 / 卡片名。
LLM uses catalog refactoring scenario cards + rationality review cards to identify design-level issues; each issue maps to ≥ 1 scenario name / card name.

Step 4: 形态路由

Step 4: Format Routing

默认进 对话式分析回答(Step 5);用户明确要报告或大范围体检(多文件 / 遗留代码)→ 进 报告形态(Step 6);形态可中途切换。
Default to conversational analysis response (Step 5); if the user clearly requests a report or large-scale inspection (multiple files / legacy code) → switch to report format (Step 6); formats can be switched midway.

Step 5: 对话式分析回答(默认)

Step 5: Conversational Analysis Response (Default)

  1. 结论先行: 一句话给出"有没有优化空间"(没有 → 说明理由,收尾)
  2. 列要点: 按严重度从高到低;发现 ≤ 3 条直接给全(位置 + 场景·卡片名 + 理由 + 建议);> 3 条给 top 概览
  3. 收尾问询: 发现多时问"逐条过一遍还是出一份报告存档";逐条过按严重度从高到低逐条呈现,每条等用户表态:
    • 确认 → 记为"接受",下一条
    • 改判 → 按用户意见修正严重度或内容,下一条
    • 跳过 → 记为"跳过",下一条
    • 追问 → 展开讲清该条后再回到该条表态
  4. 逐条过完全部后输出汇总(接受 / 改判 / 跳过 计数 + 采纳清单),询问是否生成报告存档或进入具体重构
  1. Conclusion first: Give a one-sentence answer to "Is there room for optimization" (if no → explain the reason and conclude)
  2. List key points: Sort by severity from high to low; if there are ≤ 3 findings, provide all details (location + scenario·card name + reason + suggestion); if > 3 findings, provide a top overview
  3. Closing inquiry: If there are many findings, ask "Would you like to review item by item or generate a report for archiving"; when reviewing item by item, present each finding in order of severity from high to low, and wait for user feedback for each item:
    • Confirm → mark as "accepted", move to the next item
    • Reclassify → revise the severity or content according to the user's opinion, move to the next item
    • Skip → mark as "skipped", move to the next item
    • Inquire → explain the item in detail before returning to user feedback
  4. After reviewing all items, output a summary (count of accepted/reclassified/skipped items + adoption list), and ask whether to generate a report for archiving or proceed to specific refactoring

Step 6: 报告形态

Step 6: Report Format

references/report-template.md
两档输出;严重度查
references/severity-rubric.md
;末尾问用户要不要细化 / 跳过 / 改判 / 切对话逐条过。
Output in two levels according to
references/report-template.md
; check severity against
references/severity-rubric.md
; at the end, ask the user whether to refine, skip, reclassify, or switch to conversational item-by-item review.

参考样例

Reference Examples

简短示例 — 对话式分析回答(默认)。用户输入:
帮我 review 一下 src/parser.py(80 行 Python 解析器)
skill 回答:
有优化空间,3 个要点:
  1. Major — parser.py:1
    Extract Method
    :
    process()
    62 行内嵌 3 个语义段,建议抽
    parse_lines()
    /
    calc_total()
  2. Minor — parser.py:14
    Magic Literal
    :
    0.9
    /
    100
    /
    0.95
    /
    1000
    改成具名常量
  3. Major — parser.py:6
    Introduce Parameter Object
    :
    (qty, price)
    重复 4 处,改 dataclass
要逐条过一遍,还是出一份报告存档?
简短示例 — 逐条过。用户输入:
陪我一起 review 一下 src/parser.py,逐条过
skill 第一条:
1/4 · Major — parser.py:1
Extract Method
:
process()
62 行内嵌 3 个语义段 (计算总价 / 校验 / 打印),建议抽
calc_total()
validate_order()
。接受 / 改判 / 跳过?
用户: 跳过,后面 3 行是核心逻辑。 skill: 记下,下一条 —— 2/4 · Minor …(循环至汇总)
Short Example — Conversational Analysis Response (Default). User input:
Help me review src/parser.py (80-line Python parser)
Skill response:
There is room for optimization, 3 key points:
  1. Major — parser.py:1
    Extract Method
    : The 62-line
    process()
    embeds 3 semantic segments, it is recommended to extract
    parse_lines()
    /
    calc_total()
  2. Minor — parser.py:14
    Magic Literal
    : Change
    0.9
    /
    100
    /
    0.95
    /
    1000
    to named constants
  3. Major — parser.py:6
    Introduce Parameter Object
    :
    (qty, price)
    is repeated 4 times, change to dataclass
Would you like to review item by item or generate a report for archiving?
Short Example — Item-by-item Review. User input:
Review src/parser.py with me, item by item
Skill's first item:
1/4 · Major — parser.py:1
Extract Method
: The 62-line
process()
embeds 3 semantic segments (calculating total price / validation / printing), it is recommended to extract
calc_total()
and
validate_order()
. Accept / Reclassify / Skip?
User: Skip, the next 3 lines are core logic. Skill: Noted, next item —— 2/4 · Minor …(loop until summary)