AGENT SKILL

指定文件深度代码审查

deep-review

面向文件的深度代码审查,专注于正确性 Bug。与在整个补丁上并行运行 6 个专家的 shallow-review 不同,deep-review 聚焦用户指定的文件,使用完整的模式目录(500+ 种模式)、代码库调查和源码级上下文收集。适用场景:用户指定特定文件进行聚焦审查;浅层审查标记出需要深入调查的区域;审查关键路径的代码变更;检查复杂的序列化/生命周期/状态机变更。由用户指定要聚焦的文件(通常是补丁中文件的子集)。

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

01 前言 Front Matter

name
deep-review
version
1.0.0
description
Deep file-focused code review for correctness bugs. Unlike shallow-review which runs 6 specialists in parallel across the entire patch, deep-review focuses on user-specified files with full pattern catalogs (500+ patterns), codebase investigation, and source-level context gathering. Use when: the user specifies particular files for focused review, a shallow review flagged areas that need deeper investigation, reviewing critical-path code changes, examining complex serialization/lifecycle/state-machine changes. The user instructs which files to focus on (typically a subset of files in the patch).

02 资源文件 9

03 SKILL.md 正文

Deep Code Review

Focused, thorough review of user-specified files using the full 500+ pattern catalog. Each file is reviewed with context gathering (reading source, not just diff), codebase searches, and cross-referencing against the complete pattern database.

                    +------------------+
                    |   Input Patch    |
                    +--------+---------+
                             |
                    +--------v---------+
                    | User selects     |
                    | focus files      |
                    +--------+---------+
                             |
              +--------------+--------------+
              |                             |
    +---------v---------+       +-----------v-----------+
    | Phase 0: Context  |       | Phase 0: Context      |
    | (read full files, |       | (read full files,     |
    |  callers, types)  |       |  callers, types)      |
    +---------+---------+       +-----------+-----------+
              |                             |
    +---------v---------+       +-----------v-----------+
    | Phase 1: Deep     |       | Phase 1: Deep         |
    | specialist review |       | specialist review     |
    | (full checklists) |       | (full checklists)     |
    +---------+---------+       +-----------+-----------+
              |                             |
    +---------v---------+       +-----------v-----------+
    | Phase 2: Codebase |       | Phase 2: Codebase     |
    | investigation     |       | investigation         |
    +---------+---------+       +-----------+-----------+
              |                             |
              +--------------+--------------+
                             |
                    +--------v---------+
                    | Phase 3: Cross-  |
                    | file symmetry &  |
                    | merge findings   |
                    +------------------+

Quick Start

  1. Receive patch and user's file focus list
  2. For each focus file: run Phase 0 (context), Phase 1 (deep checklists), Phase 2 (search)
  3. Cross-file symmetry pass across all focus files
  4. Merge & report with confidence ranking

Phase 0: Context Gathering (per focus file)

Before touching any checklist, deeply understand each focus file. This is the key difference from shallow review — you read the actual source, not just the diff.

Prompt template:

Read the full source of the focus file: `{FILE_PATH}`
Read the patch for context: `{PATCH_PATH}`

For this file, gather:
1. CLASS HIERARCHY: What does it extend? What interfaces? Read the parent class/interface.
2. SIBLING CLASSES: Are there parallel implementations? Read at least one sibling.
3. CALLERS: Who calls the modified methods? How do they use return values? (grep + read)
4. LIFECYCLE: When is this object created, used, destroyed?
5. STATE MACHINE (if applicable): Map every state and every transition. What events are handled
   in each state? What events are *not* handled (missing transitions)? What states are never
   reached? Where is this state enum pattern-matched — are all states covered at every match site?
6. INVARIANTS: Read Javadoc, assertions, and any test files for this class.
7. SERIALIZATION: If it serializes — read serialize, deserialize, serializedSize together.

Output a structured context summary for use by the deep review phases.

Phase 1: Deep Specialist Review (per focus file)

Each focus file is reviewed against the FULL domain checklists (not the trimmed shallow versions). The reviewer selects which domains apply based on Phase 0 context.

Domain Selection

Based on Phase 0 context, load the relevant deep checklists:

File contains Load checklist
Conditions, comparisons, control flow, types references/deep/deep-logic.md
Arithmetic, indices, ranges, ByteBuffer, I/O references/deep/deep-boundary.md
Shared state, locks, lifecycle, state machines references/deep/deep-concurrency.md
Serialization, resources, metrics, config references/deep/deep-resources.md
New classes, new fields, registrations references/deep/deep-absence-completeness.md
Refactoring, merges, shell scripts, parsing references/deep/deep-cross-cutting.md

Typically 2-4 domains are relevant per file. Load all relevant ones.

Prompt template:

You are performing a DEEP REVIEW of: `{FILE_PATH}`

CONTEXT (from Phase 0):
{CONTEXT_SUMMARY}

PATCH (the changes being reviewed):
Read: `{PATCH_PATH}`

CHECKLISTS (load each relevant one):
Read: `{SKILL_DIR}/references/deep/deep-logic.md`
Read: `{SKILL_DIR}/references/deep/deep-boundary.md`
[... load relevant domains ...]

For EVERY checklist item that could apply to this file:
1. Check whether the pattern exists in the code
2. If the pattern matches: search the codebase for confirming/refuting evidence
3. Rate confidence: High (confirmed by evidence), Medium (pattern matches but
   uncertain), Low (possible but speculative)

Report ALL findings. For each:
- Pattern ID and name
- Location (file:line)
- Confidence (High/Medium/Low)
- What's wrong (2-3 sentences with reasoning)
- Evidence gathered (what you searched for, what you found/didn't find)
- Suggested fix

Or "No finding in this domain for this file" if nothing applies.

Phase 2: Codebase Investigation (per focus file)

For each finding from Phase 1, and for absence/completeness patterns, execute targeted codebase searches.

Search patterns to execute:

For new fields:

grep -rn "serialize\|deserialize\|serializedSize\|equals\|hashCode\|toString" {FILE_DIR}/

For new registrations:

grep -rn "addListener\|register\|subscribe\|addMetric\|removeSensor\|deregister" {FILE_DIR}/

For new enum constants:

grep -rn "switch.*{ENUM_TYPE}\|case.*{CONSTANT}" --include="*.java" {PROJECT_ROOT}/

For interface implementations:

grep -rn "implements {INTERFACE}" --include="*.java" {PROJECT_ROOT}/

For method callers:

grep -rn "{METHOD_NAME}" --include="*.java" {PROJECT_ROOT}/

For parallel paths:

grep -rn "class.*extends.*{PARENT_CLASS}" --include="*.java" {PROJECT_ROOT}/

Prompt template:

You are investigating findings from the deep review of: `{FILE_PATH}`

FINDINGS TO INVESTIGATE:
{PHASE_1_FINDINGS}

For each finding:
1. Execute the relevant codebase searches (grep, read files)
2. Confirm or refute the finding based on evidence
3. If confirmed: search for additional instances of the same pattern
4. If refuted: explain why with evidence

For absence patterns:
1. Build the search list from the diff events
2. Execute each search
3. If no match found: report as confirmed finding
4. If match found: report as refuted (the symmetric code exists)

Report updated findings with evidence.

Phase 3: Cross-File Symmetry & Merge

After all focus files are reviewed:

Prompt template:

Review findings across all focus files for cross-file patterns:

1. CROSS-FILE SYMMETRY: For each change in file A, is there a structurally parallel
   change needed in file B? Check:
   - Serialization families (if serialize changed, did deserialize change?)
   - Interface implementations (if one implementation changed, do siblings need it?)
   - Version-gated paths (if one version branch changed, do others?)
   - Test coverage (does the test file cover the changed behavior?)

2. FINDING REINFORCEMENT: Do findings across files reinforce each other?
   - Logic + Absence at same conceptual location → boost to High
   - Concurrency + Resources on same lifecycle → boost to High
   - Pattern flagged in multiple files → likely systematic issue

3. MERGE & DEDUP: Combine all findings, deduplicate, rank.

4. THREE-POINT TEST each finding:
   - The code construct actually exists (not inferred)
   - The bug is possible given visible context (not speculative)
   - The finding is actionable (what specifically should change)

Report Format

## Deep Review: [target]

### Focus Files
- `path/to/File1.java` — [brief description of changes]
- `path/to/File2.java` — [brief description of changes]

### Context Summary
[Key facts from Phase 0: class hierarchy, lifecycle, shared state, invariants]

### Findings (ranked by confidence)

#### Finding 1: [title]
- **Location**: [file:line]
- **Confidence**: High / Medium / Low
- **Domain**: [Logic / Boundary / Concurrency / Resources / Absence / Completeness]
- **Pattern**: [pattern name from checklist]
- **What's wrong**: [2-3 sentences with reasoning]
- **Evidence**: [what was searched, what was found]
- **Suggested fix**: [specific change]

#### Finding 2: ...

### Domain Coverage (per file)
| File | Logic | Boundary | Concurrency | Resources | Absence | Completeness |
|---|---|---|---|---|---|---|
| File1.java | 2 findings | - | 1 finding | - | checked | checked |
| File2.java | - | 1 finding | - | 3 findings | checked | checked |

### Cross-File Symmetry
- [Any asymmetries found]
- [Any reinforcing patterns]

Reference Files

Deep specialist checklists

  • references/deep/deep-logic.md — Full logic, types, constants, filtering patterns
  • references/deep/deep-boundary.md — Full boundary, overflow, null, I/O patterns
  • references/deep/deep-concurrency.md — Full concurrency, state, lifecycle patterns
  • references/deep/deep-resources.md — Full serialization, resource, crash-safety patterns
  • references/deep/deep-absence-completeness.md — Full absence + completeness with search methodology
  • references/deep/deep-cross-cutting.md — Refactoring, parsing, platform, dispatch patterns

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

快速并行代码审查

shallow-review

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

软件开发工程师测试与质量保障
★ 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