diff --git a/dot_claude/rules/development-principles.md b/dot_claude/rules/development-principles.md index 1529c8c..082f704 100644 --- a/dot_claude/rules/development-principles.md +++ b/dot_claude/rules/development-principles.md @@ -6,8 +6,7 @@ alwaysApply: true ## Test-Driven Development -- Write tests first, then implementation -- Red → Green → Refactor cycle +- See `tdd.md` for detailed TDD rules ## Simplicity diff --git a/dot_claude/rules/tdd.md b/dot_claude/rules/tdd.md new file mode 100644 index 0000000..7afde17 --- /dev/null +++ b/dot_claude/rules/tdd.md @@ -0,0 +1,34 @@ +--- +alwaysApply: true +--- + +# Test-Driven Development + +## Red-Green-Refactor Cycle + +1. **Red**: Write a failing test that describes the desired behavior +2. Confirm the test fails for the expected reason +3. **Green**: Write the minimal implementation to make the test pass +4. Confirm all tests pass +5. **Refactor**: Improve code quality while keeping tests green + +## Rules + +- Never write production code without a corresponding failing test +- One test = one behavior. Keep incremental steps small +- Run tests after each step; show Red before Green +- Do not skip the Red step — a test that has never failed proves nothing + +## When Uncertain + +- Ask the user about test location, framework, or naming conventions rather than guessing +- If multiple test patterns exist in the project, ask which to follow + +## Exceptions + +TDD does not apply to contexts without test frameworks: + +- Dotfiles configuration and templates +- CI/CD pipeline definitions +- Shell scripts without a test harness +- Declarative config files (JSON, YAML, TOML)