Community程式設計與開發github.com

審查代碼

透過基於原則的問題驅動分析,進行深度代碼審查,並生成 PR 評論。

審查代碼 是什麼?

這個「審查代碼」技能是一個專為 AI 輔助代碼審查設計的高階技能。它透過系統性的提問與回答流程,從 PR 中挖掘出潛在問題。技能核心在於將審查視為「訊問」過程:首先根據審查原則生成問題,然後徹底回答這些問題,最後將發現的問題按類別(如正確性、假設、類型系統、意圖)組織成具體的 PR 評論。它支援多種問題類型(事實、研究、設計、正確性、意圖),並能調用專門的子代理(如 `fact-find`、`deep-research`)來處理。該技能會產生完整的工作文件(如問題清單、問答記錄、提交審查),最終輸出一個內部使用的 `REVIEW.md` 文件,供開發者手動操作,不會自動發布到 GitHub。其最大優點是生成可驗證的審查產物,確保每個問題都有明確的答案或標記為「需作者澄清」,從而提高審查的深度和透明度。

相容平台✓Claude Code~Codex CLI~Cursor
npx skills add https://github.com/cbgbt/bottlerocket-forest/tree/main/skills/review-code

Installed? Explore more 程式設計與開發 skills: steipete/bluebubbles, steipete/eightctl, steipete/blucli · View all 6 →

在你喜歡的 AI 中提問

開啟一個已預先載入此 Agent Skill 的新對話。

說明文件

代碼審查技能

透過生成並回答從審查原則衍生出的所有問題來審查 PR。最終產出一份包含特定 PR 評論及推理依據參考文件的文件。

運作方式

代碼審查就是訊問:生成問題,回答所有問題,找出不明確或有疑慮的地方。

此技能會產出:

  • 從審查原則衍生出的問題
  • 每個問題的答案(或明確標示「需作者澄清」)
  • 從答案中推斷出的影響
  • 按類別組織的已揭露疑慮

此技能不會產出:

  • 嚴重性等級(嚴重/主要/次要)
  • 阻塞性與非阻塞性分類
  • 核准建議

流程: 0. 設定 - 在本地檢出 PR 分支

  1. 探查 - 繪製 PR 範圍圖,生成初步問題(可能較淺顯)
  2. 精煉問題 - 填補知識缺口,生成真正的問題清單,並分類
  3. 回答問題 - 將每個問題路由至適當的處理器,產出問答文件
  4. 整體預評估 - 使用問答評估方法(與步驟 5 平行進行)
  5. 逐提交審查 - 使用問答審查每個提交(平行進行) 5.5. 過濾影響 - 二元浮現決策 + 分類
  6. 整體後評估 - 重新評估,檢查需求滿足情況
  7. 綜合 - 將疑慮按類別整合

問題類型與處理器:

  • FACT (事實) → fact-find 技能(附引用答案)
  • RESEARCH (研究) → deep-research 技能(教育性文件)
  • DESIGN (設計) → 設計評估(提出替代方案,根據原則評估)
  • CORRECTNESS (正確性) → 正確性分析(追蹤程式碼,驗證行為)
  • INTENT (意圖) → 標記為「需作者澄清」(無法自行回答)

關鍵洞察: 每個問題都必須有明確、有文件記錄的答案(或明確標示「需作者澄清」)。這建立了可驗證的產物。

輸入

  • PR 參考(URL、編號或分支)
  • 可選:使用者標記的關鍵問題或文件

設定

開始前,協調器會檢出 PR:

# 在目標儲存庫目錄中
gh pr checkout <PR編號>

先決條件:

  • 工作目錄必須是包含 PR 的儲存庫
  • 沒有未提交的更改(若工作目錄不乾淨則提前失敗)
  • GitHub CLI 已認證

檢出後,所有子代理從本地檔案系統讀取代碼,而不是使用 gh CLI 來取得差異。

工作區

為所有產物建立 planning/<pr-slug>/ 目錄。請勿提交這些產物——它們是工作文件,而非最終交付物。

planning/<pr-slug>/
├── 00-scout.md           # 初始範圍圖
├── 01-questions.md       # 精煉且分類後的問題清單
├── 02-answers.md         # 統一的問答文件
├── answers/              # 個別答案產物
│   ├── fact-Q1.md
│   ├── design-Q2.md
│   └── ...
├── 03-commit-NN.md       # 逐提交審查
├── 04-holistic-pre.md
├── filtered-implications.md  # 分類後要揭露的影響
├── 05-holistic-post.md
└── REVIEW.md             # 最終輸出

子代理協定

要傳遞的檔案: PRINCIPLES.md、代理指令檔案、先前階段的產物

要傳遞的資料: workspace 路徑、特定階段的資料

回應:

OUTPUT: <檔案名稱>
STATUS: ok | problems
NOTES: <若有問題>

信任 STATUS: ok。若為 problems,則讀取筆記並決定下一步。

儲存庫存取

PR 在審查開始前已本地檢出。子代理會收到:

  • repo_path:已檢出 PR 的儲存庫路徑
  • base_ref:基礎分支(例如 main)
  • head_ref:PR 分支(已檢出)

子代理直接從 repo_path 讀取檔案。使用 git diff {base_ref}...HEAD 取得差異。

階段

0. 設定

在任何分析之前,先在本地檢出 PR:

gh pr checkout <PR編號>

從 PR 元資料中取得 base_ref,供差異指令使用。

1. 探查

代理: agents/01-scout.md 檔案: PRINCIPLES.md、代理檔案 資料: workspace、repo_path、base_ref、pr_number、使用者上下文 輸出: 00-scout.md

2. 精煉問題

代理: agents/02-refine-questions.md 檔案: PRINCIPLES.md、代理檔案、00-scout.md 資料: workspace、repo_path、base_ref、關聯的問題/文件 輸出: 01-questions.md

此階段使用 fact-find 來填補知識缺口,並產生分類後的問題清單。

3. 回答問題

針對 01-questions.md 中的每個問題,啟動適當的回應代理:

類型代理輸出
FACTagents/03-answer-fact.mdanswers/fact-{id}.md
RESEARCHagents/04-answer-research.mdanswers/research-{id}.md
DESIGNagents/05-answer-design.mdanswers/design-{id}.md
CORRECTNESSagents/06-answer-correctness.mdanswers/correctness-{id}.md
INTENT(略過—標記為「需作者澄清」)

儘可能平行執行回應代理。

全部完成後,整合到 02-answers.md:

# 已回答問題

| ID | 類型 | 問題 | 答案摘要 | 詳細資訊 |
|----|------|------|----------|----------|
| Q1 | FACT | ... | ... | [answers/fact-Q1.md] |

## 需作者澄清
| ID | 問題 | 無法回答的原因 |

4. 整體預評估

代理: agents/07-holistic-pre.md 檔案: PRINCIPLES.md、代理檔案、01-questions.md、02-answers.md 資料: workspace、PR 描述、提交訊息 輸出: 04-holistic-pre.md

可以與階段 5 平行執行。

5. 逐提交審查

代理: agents/08-commit-review.md(每個提交一個,平行執行) 檔案: PRINCIPLES.md、代理檔案、01-questions.md、02-answers.md 資料: workspace、repo_path、base_ref、commit_sha、commit_message、commit_number、total_commits、all_commit_messages 輸出: 03-commit-NN.md

for each commit in PR:
    spawn commit_reviewer(
        commit_diff=commit.diff,
        commit_number=N,
        ...
    ) → 03-commit-{N}.md
# 每個提交一個代理 - 不要批次處理

5.5. 過濾影響

代理: agents/085-filter-implications.md 檔案: PRINCIPLES.md、代理檔案、所有 03-commit-*.md 資料: workspace 輸出: filtered-implications.md

代理從提交審查檔案中直接解析影響和作者問題。

二元浮現決策(浮現或不浮現)加上分類:

  • correctness (正確性) - 邏輯錯誤、錯誤、不正確的行為
  • assumption (假設) - 未說明的假設,可能不成立
  • type-system (類型系統) - 類型安全問題、遺漏的約束
  • intent (意圖) - 關於作者意圖的問題,需要澄清
spawn implication_filter(workspace=workspace) → filtered-implications.md
# 代理從 03-commit-*.md 檔案中提取影響

6. 整體後評估

代理: agents/09-holistic-post.md 檔案: PRINCIPLES.md、代理檔案、01-questions.md、02-answers.md、04-holistic-pre.md、所有 03-commit-*.md、filtered-implications.md 資料: workspace 輸出: 05-holistic-post.md

7. 綜合

代理: agents/10-synthesize.md 檔案: PRINCIPLES.md、代理檔案、所有產物 資料: workspace 輸出: REVIEW.md

按類別(正確性、假設、類型系統、意圖)組織已揭露的疑慮,而非按嚴重性。

8. 交付

向使用者呈現 REVIEW.md。

**⚠️ 僅限本地:**此技能僅產出本地產物。除了初始的 gh pr checkout 之外,請勿提議將評論發佈到 GitHub 或與 GitHub 進行任何互動。審查輸出供使用者手動操作。

符記保留

您負責協調;子代理負責分析。信任狀態回應。

除非下列情況,否則不要讀取中間產物:

  • STATUS: problems → 讀取筆記
  • 使用者提出問題
  • 除錯失敗

務必讀取: 狀態回應、REVIEW.md 最終輸出。

技能檔案

skills/review-code/
├── SKILL.md
├── PRINCIPLES.md
└── agents/
    ├── 01-scout.md
    ├── 02-refine-questions.md
    ├── 03-answer-fact.md
    ├── 04-answer-research.md
    ├── 05-answer-design.md
    ├── 06-answer-correctness.md
    ├── 07-holistic-pre.md
    ├── 08-commit-review.md
    ├── 085-filter-implications.md
    ├── 09-holistic-post.md
    └── 10-synthesize.md

Individual skills in this repo

This repo contains 19 individual skills — each has its own dedicated page.

ad-hoc-implementation-plan

Transform a rough plan into implement-commit ready artifacts. Allows rigorous review while implementing.

build-kit-locally

Build a kit and publish it to a locally hosted registry for development testing

build-variant-from-local-kits

Build a variant using locally published kits for development validation

deep-research

Create educational documents that build understanding progressively with citations

edit-spec-file

Edit Bottlerocket RPM spec files following project style conventions

fact-find

Quick lookup of specific facts about Bottlerocket with citations

idea-honing

Clarify feature ideas through iterative Q&A, recording insights to guide concept development

implement-commit

Implement commits from an implementation plan using a TDD pipeline

local-registry

Start and manage a local OCI registry for Bottlerocket kit development

prepare-core-kit-release

Prepare bottlerocket-core-kit for release by bumping version and updating changelog

propose-feature-concept

Create a new feature concept document to pitch the idea and explain the problem/solution

propose-feature-design

Create or update feature technical design document with architecture and implementation guidance

propose-feature-requirements

Create or update feature requirements specification using EARS notation with examples and appendices

propose-feature-test-plan

Create a test plan mapping EARS requirements and Critical Constraints to specific tests

propose-implementation-plan

Create an implementation plan with atomic commits that build toward a complete feature

review-scope

Verify code changes match intended scope and requirements without exceeding boundaries

review-style

Verify code follows project style guides without providing improvement suggestions

test-local-twoliter

Build and test local changes to twoliter before releasing

update-twoliter

Update all Bottlerocket repositories to a new Twoliter version

相關技能