feat(05-tdd): TDD integration with detection, annotation, and execution flow

- Add references/tdd.md with detection heuristics, red-green-refactor cycle
- Add tdd_annotation section to plan-format.md with task structure
- Expand plan-phase.md with TDD detection and annotation guidance
- Add tdd_execution section to execute-phase.md with commit patterns
- TDD-aware task routing in execute step

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Lex Christopherson
2025-12-31 11:40:56 -06:00
parent 51f395080c
commit 5390b33bd2
4 changed files with 322 additions and 3 deletions

View File

@@ -439,6 +439,10 @@ Execute each task in the prompt. **Deviations are normal** - handle them automat
**If `type="auto"`:**
**Before executing:** Check if task has `tdd="true"` attribute:
- If yes: Follow TDD execution flow (see `<tdd_execution>`) - RED → GREEN → REFACTOR cycle with multiple atomic commits
- If no: Standard implementation with single commit
- Work toward task completion
- **If CLI/API returns authentication error:** Handle as authentication gate (see below)
- **When you discover additional work not in plan:** Apply deviation rules (see below) automatically
@@ -810,6 +814,54 @@ Logged to .planning/ISSUES.md for future consideration:
</deviation_documentation>
<tdd_execution>
## TDD Task Execution
When executing a task with `tdd="true"` attribute:
**1. Check test infrastructure:**
If no test framework configured:
- Detect project type from package.json/requirements.txt/etc.
- Install minimal test framework (Jest, pytest, Go testing, etc.)
- Create test config file
- Verify: run empty test suite
**2. RED - Write failing test:**
- Read `<test-first>` element for test specification
- Create test file if doesn't exist (follow project conventions)
- Write test(s) that describe expected behavior
- Run tests - MUST fail (if passes, test is wrong or feature exists)
- Commit: "test: add failing test for [feature]"
**3. GREEN - Implement to pass:**
- Read `<action>` element for implementation guidance
- Write minimal code to make test pass
- Run tests - MUST pass
- Commit: "feat: implement [feature]"
**4. REFACTOR (if needed):**
- Clean up code if obvious improvements
- Run tests - MUST still pass
- Commit only if changes made: "refactor: clean up [feature]"
**Commit pattern for TDD tasks:**
Each TDD task produces 2-3 atomic commits:
1. `test: add failing test for X`
2. `feat: implement X`
3. `refactor: clean up X` (optional)
**Error handling:**
- If test doesn't fail in RED phase: Test is wrong or feature already exists. Investigate before proceeding.
- If test doesn't pass in GREEN phase: Debug implementation, don't skip to next task.
- If tests fail in REFACTOR phase: Undo refactor, commit was premature.
**Verification:**
After TDD task completion, ensure:
- All tests pass
- Test coverage for the new behavior exists
- No unrelated tests broken
</tdd_execution>
<step name="checkpoint_protocol">
When encountering `type="checkpoint:*"`:

View File

@@ -19,8 +19,9 @@ Decimal phases enable urgent work insertion without renumbering:
2. ~/.claude/get-shit-done/references/plan-format.md
3. ~/.claude/get-shit-done/references/scope-estimation.md
4. ~/.claude/get-shit-done/references/checkpoints.md
5. .planning/ROADMAP.md
6. .planning/PROJECT.md
5. ~/.claude/get-shit-done/references/tdd.md
6. .planning/ROADMAP.md
7. .planning/PROJECT.md
**Load domain expertise from ROADMAP:**
- Parse ROADMAP.md's `## Domain Expertise` section for paths
@@ -187,7 +188,33 @@ Decompose phase into tasks. Each task needs:
- **Verify**: How to prove it worked
- **Done**: Acceptance criteria
**TDD fit:** Can you write `expect(fn(input)).toBe(output)` before writing `fn`? Yes (business logic, APIs, validation) → test-first. No (UI layout, config, glue code) → standard implementation.
**TDD detection:** For each task, evaluate TDD fit:
TDD candidates (add `tdd="true"` to task, include `<test-first>` element):
- Business logic with defined inputs/outputs
- API endpoints with request/response contracts
- Data transformations, parsing, formatting
- Validation rules and constraints
- Algorithms with testable behavior
- State machines and workflows
Skip TDD (standard `type="auto"` task):
- UI layout, styling, visual components
- Configuration changes
- Glue code connecting existing components
- One-off scripts and migrations
- Simple CRUD with no business logic
**Heuristic:** Can you write `expect(fn(input)).toBe(output)` before writing `fn`?
→ Yes: Add `tdd="true"`, include `<test-first>` describing the failing test
→ No: Standard task, no TDD annotation
**Test framework:** If project has no test setup and TDD tasks exist, add a setup task first:
- Detect project type (package.json → Jest, requirements.txt → pytest, etc.)
- Add minimal test configuration
- Create example test file to verify setup
See `~/.claude/get-shit-done/references/tdd.md` for complete TDD guidance.
**Checkpoints:** Visual/functional verification → checkpoint:human-verify. Implementation choices → checkpoint:decision. Manual action (email, 2FA) → checkpoint:human-action (rare).
@@ -292,6 +319,21 @@ Phase plan created: .planning/phases/XX-name/{phase}-01-PLAN.md
- "Set up authentication" / "Make it secure" / "Handle edge cases"
If you can't specify Files + Action + Verify + Done, the task is too vague.
**Good TDD task:**
```xml
<task type="auto" tdd="true">
<name>Create price calculator with discount rules</name>
<files>src/lib/pricing.ts, src/lib/pricing.test.ts</files>
<test-first>
Test: calculatePrice applies discounts correctly
Cases: base 100 + 10% off → 90, base 100 + 20% off + $5 coupon → 75
</test-first>
<action>Implement calculatePrice(base, discountPercent, couponAmount). Apply percentage first, then flat amount.</action>
<verify>npm test -- pricing.test.ts passes</verify>
<done>Price calculation handles all discount combinations correctly</done>
</task>
```
</task_quality>
<anti_patterns>