Community程式設計與開發github.com

審查風格

驗證程式碼是否符合專案風格指南,但不會提供改進建議。

審查風格 是什麼?

這個「審查風格」技能是一個嚴格的通過/失敗閘門,用於驗證程式碼是否完全遵循專案風格指南。它的設計目的是作為自動化審查流程中的二進位檢查點,特別適用於TDD(測試驅動開發)驗證階段、合併請求(PR)風格審查,或任何需要嚴格風格驗證的程式碼審查。該技能支援多個開發階段(設計者、測試者、實作者),並根據當前階段動態套用不同的風格指南。它會產出結構化結果,明確標示「接受」或列出違規事項,其中包含檔案、行號與描述。其關鍵功能之一是「帳本感知」(Ledger Awareness):當提供帳本檔案時,它能讀取先前的審查週期,驗證已解決的問題,尊重有爭議的項目,並僅報告新的違規事項,從而實現多循環審查工作流程。該技能明確不提供改進建議或不屬於風格指南的偏好,確保其作為中立、自動化閘門的角色。它主要設計用於Claude Code等AI代理平台,並可與Orchestrator等工具整合以解析結果並引導後續步驟。

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

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

在你喜歡的 AI 中提問

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

說明文件

審查風格技能

目的

驗證程式碼是否符合所有專案風格指南。 這是一個通過/失敗閘門,而非回饋環節。

使用時機

  • TDD 驗證階段
  • 合併請求的風格審查
  • 任何需要風格驗證的程式碼審查

必要輸入

context_files

  • 當前審查階段的風格指南(例如:docs/style/rust-design.md)
  • 要審查的變更檔案
  • 帳本檔案(選擇性,用於多循環審查)

context_data

  • phase:當前階段(設計者/測試者/實作者)——決定套用哪些風格指南規則
  • changed_files:要審查的檔案列表

回應格式

回傳符合此架構的結構化回應:

class StyleResult(BaseModel):
    status: Literal["accept", "violations"]
    violations: list[str] = []  # 每個項目:"file:line - 描述"
    themes: str | None = None   # 選擇性,違規事項的共同模式

如果所有檢查通過:

StyleResult(status="accept")

如果任何檢查失敗:

StyleResult(
    status="violations",
    violations=[
        "src/config.rs:23 - snafu 選擇器在模組層級匯入;應放在函式內部",
        "src/parser.rs:45 - 測試中缺少 Given/When/Then 註解",
    ],
    themes="多項違規源自不一致的錯誤處理方式"
)

帳本感知

當 context_files 中提供帳本檔案時:

  1. 讀取先前循環 - 檢查之前提出的違規事項以及實作者的處理方式
  2. 驗證已解決項目 - 確認修復已實際套用
  3. 尊重有爭議項目 - 若實作者的理由合理,則不再提出
  4. 僅提出新的違規 - 僅報告先前未討論的問題

風格指南(權威來源)

docs/style/ 中的風格指南是唯一的真理來源:

  • docs/style/rust-design.md - 設計階段規則(型別、簽名、bon、nutype、snafu)
  • docs/style/rust-impl.md - 實作階段規則(錯誤處理、匯入、禁止 panic)
  • docs/style/rust-test.md - 測試階段規則(Given/When/Then、test_case、斷言)

閱讀適用的指南並運用你的判斷。不要依賴摘要。

程序

1. 識別適用的規則

根據階段:

  • designer:rust-design.md 規則(尤其是專案 Crate 選擇表)
  • tester:rust-test.md 規則
  • implementor:rust-impl.md 規則
  • 測試檔案(#[cfg(test)] 模組)無論階段為何,一律套用 rust-test.md 規則

2. 審查每個檔案

根據適用的風格指南規則進行檢查。 僅標記明確的違規事項,而非風格偏好。

設計者階段的關鍵檢查:

  • 複合結構體(2 個以上欄位)使用 #[derive(Builder)] 搭配 #[non_exhaustive]
  • 經驗證的新型別使用 nutype
  • 錯誤使用 snafu 並搭配 #[snafu(module)]
  • 函式主體為 todo!(),而非實際實作

實作者階段的關鍵檢查:

  • 生產程式碼中無 unwrap()/expect()
  • Snafu 上下文選擇器在函式內部匯入
  • 匯入之間無空行

測試者階段的關鍵檢查:

  • 每個測試中都有 Given/When/Then 註解
  • 參數化測試使用 test_case

3. 回傳結構化結果

使用 StyleResult 架構。協調器將解析此結果以決定後續步驟。

此技能不執行的項目

  • 提出與違規無關的改進建議
  • 提供一般性的建設性回饋
  • 審查範圍或正確性(請使用 review-scope 技能)
  • 標記不在指南中的風格偏好

此為二進位閘門:接受或違規。

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-code

Deep code review generating PR comments via principled question-driven analysis

review-scope

Verify code changes match intended scope and requirements without exceeding boundaries

test-local-twoliter

Build and test local changes to twoliter before releasing

update-twoliter

Update all Bottlerocket repositories to a new Twoliter version

相關技能