Community程式設計與開發github.com

實作提交

從實作計劃中以 TDD 流程執行提交。

實作提交 是什麼?

這是一個 AI 代理技能,用於根據 `implementation-plan.toml` 檔案,以機械化的 TDD 管線逐個執行提交。它透過一個有限狀態機驅動程式 (`ic-driver.py`) 來協調設計、測試、實作、程式碼審查和格式化等階段,從而自動化開發工作流程。此技能專為在設有 `doc/features/NNNN-name/implementation-plan.toml` 目錄結構的專案中使用而設計。AI 代理僅需呼叫驅動命令、執行分支動作(例如,向專門的代理子技能發送提示)並回報結果;驅動程式會處理狀態轉換,並在閘道檢查、格式化和提交等階段無需 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. 執行分支動作
  3. 回報結果

除非發生錯誤,否則你不應讀取相關檔案 - 保留你的 token,信任 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 = "."  # 來自計劃 meta

# 回應模型
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):
    # 從 stderr 解析升級資訊
    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回報分支結果,推進狀態
resumeLLM 介入後繼續
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

相關技能