AGENT SKILL

快速并行代码审查

shallow-review

使用 6 个专家代理并行开展浅层(快速)集成式 bug 查找审查。每个专家通过不同视角审查同一补丁:逻辑与类型、边界与 I/O、并发与状态、资源与序列化、缺失分析以及 API 完整性。发现的问题会被合并并去重。最适合:补丁的快速初审、diff 分诊、广泛的表层 bug 扫描。如需以文件为中心、包含完整模式目录和代码库调查的更深入审查,请改用 deep-review 技能。

License 许可
Apache-2.0
所属仓库
apache/cassandra
最近更新
2026-11-14
Stars
★ 1.0w
Forks
4.1k

01 前言 Front Matter

name
shallow-review
version
1.0.0
description
Shallow (quick) ensemble bug-finding review using 6 specialist agents in parallel. Each specialist reviews the same patch through a different lens: Logic & Types, Boundaries & I/O, Concurrency & State, Resources & Serialization, Absence Analysis, and API Completeness. Findings are merged and deduplicated. Best for: quick first-pass review of patches, triage of diffs, broad surface-level bug scan. For deeper file-focused review with full pattern catalogs and codebase investigation, use the deep-review skill instead.

02 资源文件 7

03 SKILL.md 正文

Ensemble Code Review

Six specialist agents review the same patch in parallel. Each applies Phase 0 (understand the change, form hypotheses) then a focused checklist. Their findings are merged and deduplicated.

                    +------------------+
                    |   Input Patch    |
                    +--------+---------+
                             |
    +-------+------+---------+---------+-----------+
    |       |      |         |         |           |
+---v--+ +--v--+ +-v-----+ +-v------+ +v-----+ +---v-------+
|Logic | |Bound| |Concurr| |Resource| |Absenc| | Complete. |
|&Type | | &I/O| |&State | |& Serde | |(2-ph)| | & Contr.  |
+--+---+ +--+--+ +---+---+ +---+----+ +--+---+ +---+-------+
   |        |        |         |          |        |
   +--------+--------+---------+----------+--------+
                               |
                    +----------v----------+
                    |  Pass 3: Symmetry   |
                    |  (serial, optional) |
                    +----------+----------+
                               |
                    +----------v----------+
                    |   Merge & Dedup     |
                    |   (main agent)      |
                    +---------------------+

Quick Start

  1. Identify target — patch, diff, file, or subsystem
  2. Launch 6 specialists in parallel (see prompts below)
  3. Run Pass 3 Symmetry check (serial, after specialists complete)
  4. Merge findings: deduplicate, rank by confidence
  5. Report in unified format

Phase 0: Understand Before Checking

Every specialist runs Phase 0 BEFORE touching the checklist:

  1. Summarize the patch in 2–3 sentences (feature, fix, refactor, move?)
  2. Hypothesize — list 3–5 things that could go wrong with this type of change
  3. Note code shapes that warrant deeper investigation

This switches the review from bottom-up (checklist→code) to top-down (code→hypotheses→verification). The checklist then verifies and extends the hypotheses.


The Six Specialists

1. Logic & Types (52% of bugs)

Priority: wrong comparisons, missing returns, wrong constants, boolean polarity, sentinel ambiguity.

Reference: references/general/specialists/logic.md

Prompt:

You are a LOGIC specialist reviewing a patch for correctness bugs.

PHASE 0 — Understand the patch first (before reading checklist):
Read the patch: `{PATCH_PATH}`
1. Summarize what this patch does in 2-3 sentences.
2. List 3-5 things that could go wrong with this type of change.
3. Note any suspicious code shapes (control flow, comparisons, constants, sentinels).

PHASE 1 — Apply checklist:
Read your checklist: `{SKILL_DIR}/references/general/specialists/logic.md`
Apply questions that match your hypotheses and code shapes. Check all 30 items
against the patch but spend the most effort where your hypotheses pointed.

Report ALL findings above a noise floor. For each: Location, Confidence
(High/Medium/Low), What's wrong (1-2 sentences).
Or "No finding in my domain" if nothing applies.

2. Boundaries & I/O (17% of bugs)

Priority: off-by-one, integer overflow, null/bounds checks, buffer sizing, I/O completeness.

Reference: references/general/specialists/boundary.md

Prompt:

You are a BOUNDARY specialist reviewing a patch for correctness bugs.

PHASE 0 — Understand the patch first (before reading checklist):
Read the patch: `{PATCH_PATH}`
1. Summarize what this patch does in 2-3 sentences.
2. List 3-5 things that could go wrong with this type of change.
3. Note any arithmetic, indexing, range, or I/O operations.

PHASE 1 — Apply checklist:
Read your checklist: `{SKILL_DIR}/references/general/specialists/boundary.md`
Apply questions that match your hypotheses and code shapes. Check all 22 items
against the patch but spend the most effort where your hypotheses pointed.

Report ALL findings above a noise floor. For each: Location, Confidence
(High/Medium/Low), What's wrong (1-2 sentences).
Or "No finding in my domain" if nothing applies.

3. Concurrency & State (16% of bugs)

Priority: races, TOCTOU, live-view iteration, lock ordering, state cleanup.

Reference: references/general/specialists/concurrency.md

Prompt:

You are a CONCURRENCY specialist reviewing a patch for correctness bugs.

PHASE 0 — Understand the patch first (before reading checklist):
Read the patch: `{PATCH_PATH}`
1. Summarize what this patch does in 2-3 sentences.
2. List 3-5 things that could go wrong with this type of change.
3. Note any shared state, locks, collections, lifecycle operations.

PHASE 1 — Apply checklist:
Read your checklist: `{SKILL_DIR}/references/general/specialists/concurrency.md`
Apply questions that match your hypotheses and code shapes. Check all 24 items
against the patch but spend the most effort where your hypotheses pointed.

Report ALL findings above a noise floor. For each: Location, Confidence
(High/Medium/Low), What's wrong (1-2 sentences).
Or "No finding in my domain" if nothing applies.

4. Resources & Serialization (15% of bugs)

Priority: resource leaks, serialization mismatches, wrong metric types, background tasks, wrapper bypass.

Reference: references/general/specialists/resources.md

Prompt:

You are a RESOURCES specialist reviewing a patch for correctness bugs.

PHASE 0 — Understand the patch first (before reading checklist):
Read the patch: `{PATCH_PATH}`
1. Summarize what this patch does in 2-3 sentences.
2. List 3-5 things that could go wrong with this type of change.
3. Note any resource allocation, serialization methods, metrics, streams.

PHASE 1 — Apply checklist:
Read your checklist: `{SKILL_DIR}/references/general/specialists/resources.md`
Apply questions that match your hypotheses and code shapes. Check all 26 items
against the patch but spend the most effort where your hypotheses pointed.

Report ALL findings above a noise floor. For each: Location, Confidence
(High/Medium/Low), What's wrong (1-2 sentences).
Or "No finding in my domain" if nothing applies.

5. Absence Analysis (cross-cutting)

Priority: find what SHOULD be present but ISN'T — missing guards, cleanup, handlers, registrations.

Reference: references/general/specialists/absence.md

Prompt:

You are an ABSENCE specialist. Your job: find bugs that are purely absent — missing
guards, cleanup, handlers, or conditions that leave no signal in the diff.

PHASE 0 — Understand the patch first:
Read the patch: `{PATCH_PATH}`
1. Summarize what this patch does in 2-3 sentences.
2. List 3-5 things that SHOULD be present but might be missing.

PHASE 1 — Build the search list:
Read your checklist: `{SKILL_DIR}/references/general/specialists/absence.md`
For each event in the diff matching items (a)-(q), add to your search list.

PHASE 2 — Execute searches and report:
For each item in your search list:
  - Use Grep and Read tools to gather evidence from the codebase
  - If match found (remove/deregister exists): discard
  - If no match found: report as finding

Report ALL findings above a noise floor. For each: what's missing, where it should
be, what evidence you searched for, Confidence (High/Medium/Low).
Or "No absence finding" if nothing applies.

6. API Completeness & Contracts

Priority: missing fields, missing overrides, registration symmetry, visibility, event coverage.

Reference: references/general/specialists/completeness.md

Prompt:

You are an API COMPLETENESS specialist reviewing a patch for correctness bugs.

PHASE 0 — Understand the patch first (before reading checklist):
Read the patch: `{PATCH_PATH}`
1. Summarize what this patch does in 2-3 sentences.
2. List 3-5 things that could be incomplete about this change.
3. Note any new classes, new fields, new registrations, visibility changes.

PHASE 1 — Apply checklist:
Read your checklist: `{SKILL_DIR}/references/general/specialists/completeness.md`
Apply questions that match your hypotheses and code shapes. Check all 22 items
against the patch but spend the most effort where your hypotheses pointed.

Report ALL findings above a noise floor. For each: Location, Confidence
(High/Medium/Low), What's wrong (1-2 sentences).
Or "No finding in my domain" if nothing applies.

Pass 3: Cross-Path Symmetry (serial, after specialists complete)

Prompt:

You are a SYMMETRY specialist. For each code path modified in this patch, identify
whether a structurally parallel path (same class, interface, event family, version range)
was NOT modified. For each asymmetry:
- Where path A was changed
- Where parallel path B exists
- What was changed on A that is absent on B
- Whether the asymmetry is intentional or suspicious

Read the patch: `{PATCH_PATH}`
Search the codebase as needed using Grep and Read.
Report all asymmetries, Confidence High/Medium/Low.

Merge & Dedup

After all specialists report:

  1. Collect all findings from 6 specialists + symmetry
  2. Deduplicate — same code location + related reasons → combine
  3. Rank by confidence — findings confirmed by multiple specialists rank highest
  4. Cross-check reinforcement:
    • Logic + Absence at same location → boost to High
    • Concurrency + Resources on same lifecycle → boost to High
    • Any finding flagged by 3+ specialists → treat as confirmed
  5. 3-point test each finding:
    • The code construct actually exists in the diff (not inferred)
    • The bug is possible given the visible context (not speculative)
    • The finding is actionable (what specifically should change)
  6. Specialist Silence Rule: If Absence or Completeness reports nothing on a >100-line diff, note: "Consider verifying Phase 2 searches executed for registration symmetry, handler coverage, and field completeness."

Report Format

## Review: [target]

### Findings (ranked by confidence)

#### Finding 1: [title]
- **Location**: [file:line]
- **Confidence**: High / Medium / Low
- **Flagged by**: [specialists]
- **What's wrong**: [1-2 sentences]

### Specialist Coverage
- Logic: [N findings / no finding]
- Boundary: [N findings / no finding]
- Concurrency: [N findings / no finding]
- Resources: [N findings / no finding]
- Absence: [N findings / no finding]
- Completeness: [N findings / no finding]
- Symmetry: [N asymmetries / none]

Statistical Priors

Category Share Specialist
Logic error in condition 26% Logic
Wrong constant / default 15% Logic
Missing null / bounds check 13% Boundary
Incorrect filtering / result 11% Logic
Race condition 9% Concurrency
Wrong serialization 8% Resources
State not cleaned up 7% Concurrency
Off-by-one 4% Boundary
Resource leak 3% Resources

Reference Files

Specialist checklists (trimmed, ensemble mode)

  • references/general/specialists/logic.md — 30 items, Logic specialist
  • references/general/specialists/boundary.md — 22 items, Boundary specialist
  • references/general/specialists/concurrency.md — 24 items, Concurrency specialist
  • references/general/specialists/resources.md — 26 items, Resources specialist
  • references/general/specialists/absence.md — Phase 1/2 search patterns, Absence specialist
  • references/general/specialists/completeness.md — 22 items, Completeness specialist

04 同仓库更多 Skills

apache
apache/cassandra

Bug复现程序编写

write-reproducer

为任何项目编写最小化、可靠的 bug 复现程序(repro)。使用时机:(1) bug 报告或 issue 需要一个能够可靠演示失败的测试;(2) 将描述的失败场景转换为可运行代码;(3) 将现有复杂测试最小化为必要的触发条件。涵盖完整的复现工作流:失败特征化、范围选择、编写复现程序、验证其因正确的原因失败,以及最小化到尽可能小的触发条件。

软件开发工程师调试与故障排查
★ 1.0w
apache
apache/cassandra

TLA+形式化验证

tla-plus

创建、运行和验证 TLA+ 与 PlusCal 形式化规约。用于对分布式系统、协议、并发算法和状态机进行建模。可以从代码编写规约、发现规约与实现之间的分歧、识别并发 bug 和不变量违规。当用户要求“write a TLA+ spec”、“model check”、“verify protocol”、“find race conditions”或“formal verification”时使用。

软件开发工程师测试与质量保障
★ 1.0w
apache
apache/cassandra

定向代码审查

targeted-review

发现驱动的定向代码审查。通过 patch-explainer 理解补丁,通过 codebase-analysis 理解周边代码,然后查阅 bug 模式目录(references/categories/ 下约 11 个类别)。仅挑选 diff 信号与补丁匹配的类别,以及“look for”提示与实际代码形态匹配的条目,按审查重点(函数/文件/特性)分组,并生成并行子代理——每个子代理都有紧凑的范围和经过挑选的清单。适用于中大型补丁(50-1000 行代码),可作为整补丁集成式审查或整文件深度审查的聚焦替代方案。触发条件包括:“review this patch/diff/change”、“find bugs in this change”、“scoped review”、“what could go wrong here”、“review using findings”,或主动进行 PR 审查。

软件开发工程师测试与质量保障
★ 1.0w
apache
apache/cassandra

代码补丁可视化解析

patch-explainer

深度代码分析,通过 ASCII 可视化展示代码结构、流程和状态转换。适用于分析补丁/diff、解释类或子系统、理解代码架构、审查变更中的不一致之处,或被要求可视化代码的工作原理时。提供前后对比图、数据/控制流、并发分析、假设条件和失败模式。触发词:explain this patch/code/class、how does X work、show me the flow、visualize this change、代码审查请求,或在 PR 审查期间主动分析。

软件开发工程师开发参考
★ 1.0w
apache
apache/cassandra

大型补丁多轮深度代码审查

mega-review

针对大型补丁(1000+ 行代码)的多轮深度代码审查,最大化真实 Bug 的检出率。并行编排 targeted-review、shallow-review 和 deep-review,覆盖所有高风险(HIGH)和中风险(MEDIUM)文件与提交:从整体上理解特性,按文件和提交拆分,对每个 HIGH/MEDIUM 文件运行深度审查,在同一范围内运行定向审查,并对每个提交执行浅层审查,随后进行交叉一致性检查。适用场景:审查大型补丁(特性分支、多提交或单个大型 diff,1000+ 行代码);进行彻底的合并前审查;或当浅层审查因补丁规模过大而漏掉 Bug 时。触发词:"review this branch"、"review these commits"、"review this feature"、"mega review"、"thorough review"、"full review of X commits",或当用户指定提交范围或特性进行审查时。

软件开发工程师测试与质量保障
★ 1.0w
apache
apache/cassandra

Git 代码热力图分析

heatmap

使用 Git 热力图分析识别高变动量的文件和代码行,作为深入审查或 Bug 排查的候选对象。适用于 PR 审查、安全审计、Bug 排查或任何代码分析任务。

软件开发工程师代码仓库协作管理
★ 1.0w