Community编程与开发github.com

review-style

验证代码是否符合项目风格指南,仅作为通过/未通过的检查,不提供改进建议。

review-style 是什么?

此技能用于严格检查代码是否遵循项目预定义的风格指南,适用于 TDD 验证阶段、PR 审查以及任何需要风格合规性验证的场景。它作为一个二进制门控机制,只返回“通过”或“违规”两种状态,并列出具体违规项,但不会给出改进意见。该技能支持多周期审查(通过分类账文件追踪历史违规),并能根据不同的阶段(如设计、实现、测试)应用相应的风格指南规则。它特别强调使用权威风格指南(如 `docs/style/` 目录下的文件)作为唯一判断依据,并避免对已被有效争议的违规项重复报告。

兼容平台~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 验证阶段
  • PR 审查中的风格合规性检查
  • 任何需要风格验证的代码审查

所需输入

context_files

  • 所审查阶段的风格指南(例如:docs/style/rust-design.md)
  • 需要审查的已更改文件
  • 分类账文件(可选,用于多周期审查)

context_data

  • phase:哪个阶段(designer/tester/implementor)——决定适用哪些风格指南规则
  • changed_files:需要审查的文件列表

响应格式

返回一个符合以下模式的结构化响应:

class StyleResult(BaseModel):
    status: Literal["accept", "violations"]
    violations: list[str] = []  # 每条:“文件:行号 - 描述”
    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 规则(特别是项目板条选择表)
  • tester:rust-test.md 规则
  • implementor:rust-impl.md 规则
  • 测试文件(#[cfg(test)] 模块)无论阶段如何始终应用 rust-test.md 规则

2. 审查每个文件

对照适用的风格指南规则进行检查。 仅标记明确的违规项,而非风格偏好。

设计阶段的关键检查项:

  • 复合结构体(2个及以上字段)使用 #[derive(Builder)] 并带上 #[non_exhaustive]
  • 已验证的 newtype 使用 nutype
  • 错误使用 snafu 并带上 #[snafu(module)]
  • 函数体为 todo!() 而非具体实现

实现阶段的关键检查项:

  • 生产代码中不能有 unwrap()/expect()
  • Snafu 上下文选择器在函数内部导入
  • 导入之间不能有空行

测试阶段的关键检查项:

  • 每个测试中都有 Given/When/When 注释
  • 参数化测试使用 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

相关技能