Community编程与开发github.com

实施提交技能

根据实施计划通过TDD流水线自动执行提交。

实施提交技能 是什么?

该技能(Implement Commit)是一个AI代理技能,旨在根据 `implementation-plan.toml` 文件中的实施计划,通过机械化的TDD流水线自动执行提交。它将开发工作流程解耦为设计、测试、实现三个独立阶段,每个阶段都有严格的门控(gate)和风格审查(style review),并由驱动状态机 `ic-driver.py` 管理。技能支持Claude Code、Cursor等AI驱动开发环境,通过调用驱动命令和生成(spawn)操作来协调LLM代理(如设计者、测试者、实现者),无需手动读取大量文件,从而高效、可靠地生成代码。当驱动遇到错误或门控失败时,它会向协调者发送升级请求,由协调者智能修复问题(如修正门控配置、调整代码范围)后继续执行。

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

Installed? Explore more 编程与开发 skills: steipete/bluebubbles, steipete/eightctl, steipete/blucli · View all 6 →

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

实施提交技能 是做什么的?

根据 implementation-plan.toml 中的实施计划,通过机械化的TDD流水线执行提交。

何时使用

  • 实施计划已存在于 docs/features/NNNN-name/implementation-plan.toml 中
  • 准备编写代码

协调者角色

你是一个机械化的协调者。驱动(ic-driver.py)负责状态转换。

你只负责:

  1. 调用驱动命令
  2. 执行生成(spawn)操作
  3. 将结果报告回去

除非出现失败,否则你不得读取相关文件 —— 保留你的令牌,信任 ic-driver。

设置

import json
from pydantic import BaseModel
from typing import Literal

# 路径
feature_dir = "docs/features/NNNN-feature"
plan_path = f"{feature_dir}/implementation-plan.toml"
state_dir = ".ic"
driver = "skills/implement-commit/ic-driver.py"
workspace = "."  # 来自计划元数据

# 响应模型
class PhaseResult(BaseModel):
    status: Literal["ok", "problems"]
    files_created: list[str] = []
    files_modified: list[str] = []
    notes: str | None = None

class GateDiscovery(BaseModel):
    designer_gate: str
    test_gate: str

class FormatterDiscovery(BaseModel):
    fmt_cmd: str
    lint_cmd: str

class StyleResult(BaseModel):
    status: Literal["accept", "violations"]
    violations: list[str] = []

class ArbiterResult(BaseModel):
    proceed: bool
    reasoning: str

# 用于生成的代理文件
agents = {
    "designer": "skills/implement-commit/agents/designer.md",
    "tester": "skills/implement-commit/agents/tester.md",
    "implementor": "skills/implement-commit/agents/implementor.md",
    "arbiter": "skills/implement-commit/agents/arbiter.md",
}
style_guides = {
    "designer": "docs/style/rust-design.md",
    "tester": "docs/style/rust-test.md",
    "implementor": "docs/style/rust-impl.md",
}

主循环

对于每个提交(按依赖顺序):

commit_id = 1  # 来自依赖分析
state_path = f"{state_dir}/commit-{commit_id}.json"

# 初始化
bash(f"python {driver} init --plan {plan_path} --commit {commit_id} --state {state_path}", on_error="raise")

# 驱动循环
while True:
    try:
        output = bash(f"python {driver} next --state {state_path}", on_error="raise")
    except BashError as e:
        # 驱动需要LLM帮助 - 参见下面的处理升级部分
        handle_escalation(e, state_path)
        continue
    
    action = json.loads(output)
    
    if action["action"] == "done":
        break
    
    if action["action"] == "spawn":
        result = execute_spawn(action)
        bash(
            f"python {driver} report --state {state_path} --result '{json.dumps(result)}'",
            on_error="raise"
        )

执行生成

def execute_spawn(action: dict) -> dict:
    phase = action.get("phase")
    
    # 确定上下文文件
    context_files = [f"{feature_dir}/design.md"]
    if phase and phase in agents:
        context_files.append(agents[phase])
        if phase in style_guides:
            context_files.append(style_guides[phase])
    
    # 确定响应模型
    if action.get("response_schema") == "GateDiscovery":
        model = GateDiscovery
    elif action.get("response_schema") == "FormatterDiscovery":
        model = FormatterDiscovery
    elif action.get("style_review"):
        model = StyleResult
    elif action.get("arbiter"):
        model = ArbiterResult
    else:
        model = PhaseResult
    
    # 执行生成
    result = spawn(
        prompt=action["prompt"],
        context_files=context_files,
        response_model=model,
        read_only=action.get("style_review") or action.get("scope_review"),
        isolate_to=Cwd(workspace) if not action.get("style_review") else None,
    )
    
    result_dict = result.parsed.model_dump()
    # 保留用于驱动状态机的动作标志
    if action.get("arbiter"):
        result_dict["arbiter"] = True
    return result_dict

处理升级

当驱动以退出码1退出时,它需要LLM帮助:

def handle_escalation(e: BashError, state_path: str):
    # 从标准错误解析升级信息
    escalation = json.loads(e.stderr)
    error = escalation["error"]
    
    # LLM干预 - 理解并修复问题
    # 这是你需要思考的部分 - 驱动已将控制权交给你
    
    if "gate failed" in error.lower():
        # 可能是代码错误或门控配置错误
        # 生成一个修复者或调整门控
        spawn(
            prompt=f"修复此门控失败: {error}",
            context_files=[...],
            isolate_to=Cwd(workspace),
        )
    elif "arbiter rejected" in error.lower():
        # 风格问题过于严重
        agent_feedback(f"风格审查失败: {error}")
    elif "scope violations" in error.lower():
        # 超出范围的修改
        agent_feedback(f"作用域违规: {error}")
    else:
        agent_feedback(f"未知升级: {error}")
    
    # 修复后继续
    bash(f"python {driver} resume --state {state_path}", on_error="raise")

驱动命令

命令用途
init为某个提交创建状态文件
next获取下一个动作(生成)或直接执行门控/bash
report报告生成结果,推进状态
resume在LLM干预后继续执行
status显示当前状态(用于调试)

状态机

EXPLORE_GATES -> EXPLORE_FORMATTERS ->
DESIGNER_PHASE -> DESIGNER_GATE -> DESIGNER_STYLE ->
TESTER_PHASE -> TESTER_GATE -> TESTER_STYLE ->
IMPLEMENTOR_PHASE -> IMPLEMENTOR_GATE -> IMPLEMENTOR_STYLE ->
SCOPE_REVIEW -> FORMAT -> COMMIT -> DONE
  • 门控失败会重试阶段(最多2次),然后升级
  • 风格违规会循环(最多3次),然后调用裁决者
  • 驱动直接运行门控/格式化/提交(无LLM开销)
  • 只有生成操作需要协调者的操作

文件

skills/implement-commit/
├── SKILL.md           # 本文件
├── ic-driver.py       # 状态机驱动
└── agents/
    ├── designer.md    # 创建类型和签名
    ├── tester.md      # 编写测试
    ├── implementor.md # 实现逻辑
    └── arbiter.md     # 决定风格审查是否通过/失败

审查者使用独立的技能:review-scope、review-style。

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

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

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

相关技能