本文由 AI 分析生成
建立時間: 2026-03-28 來源: https://blog.cashwu.com/blog/2025/kent-beck-claude-code-rules-translation
Summary
Cash Wu’s Traditional Chinese translation and commentary of Kent Beck’s CLAUDE.md rules from his B+Tree project, which operationalizes TDD and “Tidy First” as concrete instructions for an AI coding assistant. The rules enforce Red-Green-Refactor cycle, structural/behavioral change separation, and small-commit discipline.
Cash Wu 對 Kent Beck B+Tree 專案中 CLAUDE.md 規則的正體中文翻譯與評注,將 TDD 和「Tidy First」具體化為 AI 助手的操作指令。規則強制執行 Red-Green-Refactor 週期、結構性/行為性變更分離以及小提交紀律。
Key Points
- TDD cycle: Red (failing test) → Green (minimal passing code) → Refactor (improve structure with tests passing)
- Tidy First: separate ALL changes into (1) Structural (rename, extract, move — no behavior change) and (2) Behavioral (new/modified functionality); never mix in same commit; structural always first
- Commit discipline: only commit when ALL tests pass, ALL warnings resolved, change is single logical unit, commit message says structural or behavioral
- Defect workflow: write API-level failing test first → smallest replicating test → make both pass
- Code quality: eliminate duplication, express intent through naming, single-responsibility methods, minimize state/side effects, simplest solution
- Refactor only in Green phase; one refactoring step at a time; run tests after each step
Insights
Kent Beck’s CLAUDE.md is a notable example of encoding decades of methodology wisdom into AI-readable instructions. The structural/behavioral separation from Tidy First is the most actionable and distinctive rule — it solves the “mixed-concern commit” problem by making the separation explicit rather than aspirational. Applied to AI coding assistance, this forces the agent to make clean, reviewable changes rather than “refactored + added feature + fixed bug” in a single diff. The instruction to write a failing test before fixing a defect (TDD’s bug-workflow variant) is often skipped in practice but is one of TDD’s most valuable rules.
Connections
Raw Excerpt
Separate all changes into two distinct types: STRUCTURAL CHANGES (rearranging code without changing behavior) and BEHAVIORAL CHANGES (adding or modifying actual functionality). Never mix structural and behavioral changes in the same commit.