feat: TDD features use dedicated plans for full context quality
TDD requires 2-3 execution cycles (RED → GREEN → REFACTOR), each with file reads, test runs, and potential debugging. This consumes 40-50% of context for a single feature. Dedicated TDD plans ensure full quality throughout the cycle. - TDD plans use `type: tdd` frontmatter with `<feature>` element - One feature per TDD plan (batching defeats the purpose) - Target ~40% context usage for TDD plans - Standard plans handle non-TDD work with 2-3 tasks 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -815,55 +815,62 @@ Logged to .planning/ISSUES.md for future consideration:
|
||||
|
||||
</deviation_documentation>
|
||||
|
||||
<tdd_execution>
|
||||
## TDD Task Execution
|
||||
<tdd_plan_execution>
|
||||
## TDD Plan Execution
|
||||
|
||||
When executing a task with `tdd="true"` attribute:
|
||||
When executing a plan with `type: tdd` in frontmatter, follow the RED-GREEN-REFACTOR cycle for the single feature defined in the plan.
|
||||
|
||||
**1. Check test infrastructure:**
|
||||
**1. Check test infrastructure (if first TDD plan):**
|
||||
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
|
||||
- This is part of the RED phase, not a separate task
|
||||
|
||||
**2. RED - Write failing test:**
|
||||
- Read `<test-first>` element for test specification
|
||||
- Read `<behavior>` 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]"
|
||||
- Commit: `test({phase}-{plan}): add failing test for [feature]`
|
||||
|
||||
**3. GREEN - Implement to pass:**
|
||||
- Read `<action>` element for implementation guidance
|
||||
- Read `<implementation>` element for guidance
|
||||
- Write minimal code to make test pass
|
||||
- Run tests - MUST pass
|
||||
- Commit: "feat: implement [feature]"
|
||||
- Commit: `feat({phase}-{plan}): 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 only if changes made: `refactor({phase}-{plan}): 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)
|
||||
**Commit pattern for TDD plans:**
|
||||
Each TDD plan produces 2-3 atomic commits:
|
||||
1. `test({phase}-{plan}): add failing test for X`
|
||||
2. `feat({phase}-{plan}): implement X`
|
||||
3. `refactor({phase}-{plan}): 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 test doesn't pass in GREEN phase: Debug implementation, keep iterating until green.
|
||||
- If tests fail in REFACTOR phase: Undo refactor, commit was premature.
|
||||
|
||||
**Verification:**
|
||||
After TDD task completion, ensure:
|
||||
After TDD plan completion, ensure:
|
||||
- All tests pass
|
||||
- Test coverage for the new behavior exists
|
||||
- No unrelated tests broken
|
||||
|
||||
**Note:** TDD tasks produce 2-3 commits (test/feat/refactor). Non-TDD tasks produce 1 commit after task completion.
|
||||
</tdd_execution>
|
||||
**Why TDD uses dedicated plans:** TDD requires 2-3 execution cycles (RED → GREEN → REFACTOR), each with file reads, test runs, and potential debugging. This consumes 40-50% of context for a single feature. Dedicated plans ensure full quality throughout the cycle.
|
||||
|
||||
**Comparison:**
|
||||
- Standard plans: Multiple tasks, 1 commit per task, 2-4 commits total
|
||||
- TDD plans: Single feature, 2-3 commits for RED/GREEN/REFACTOR cycle
|
||||
|
||||
See `~/.claude/get-shit-done/references/tdd.md` for TDD plan structure.
|
||||
</tdd_plan_execution>
|
||||
|
||||
<task_commit>
|
||||
## Task Commit Protocol
|
||||
@@ -917,7 +924,7 @@ git commit -m "{type}({phase}-{plan}): {concise task description}
|
||||
**Examples:**
|
||||
|
||||
```bash
|
||||
# Non-TDD task
|
||||
# Standard plan task
|
||||
git commit -m "feat(08-02): create user registration endpoint
|
||||
|
||||
- POST /auth/register validates email and password
|
||||
@@ -925,31 +932,16 @@ git commit -m "feat(08-02): create user registration endpoint
|
||||
- Returns JWT token on success
|
||||
"
|
||||
|
||||
# TDD task - RED phase
|
||||
git commit -m "test(07-02): add failing test for JWT generation
|
||||
# Another standard task
|
||||
git commit -m "fix(08-02): correct email validation regex
|
||||
|
||||
- Tests token contains user ID claim
|
||||
- Tests token expires in 1 hour
|
||||
- Tests signature verification
|
||||
"
|
||||
|
||||
# TDD task - GREEN phase
|
||||
git commit -m "feat(07-02): implement JWT generation
|
||||
|
||||
- Uses jose library for signing
|
||||
- Includes user ID and expiry claims
|
||||
- Signs with HS256 algorithm
|
||||
"
|
||||
|
||||
# TDD task - REFACTOR phase
|
||||
git commit -m "refactor(07-02): extract JWT config to constants
|
||||
|
||||
- Moved expiry time to constant
|
||||
- Centralized algorithm selection
|
||||
- No behavior changes
|
||||
- Fixed regex to accept plus-addressing
|
||||
- Added tests for edge cases
|
||||
"
|
||||
```
|
||||
|
||||
**Note:** TDD plans have their own commit pattern (test/feat/refactor for RED/GREEN/REFACTOR phases). See `<tdd_plan_execution>` section above.
|
||||
|
||||
**5. Record commit hash:**
|
||||
|
||||
After committing, capture hash for SUMMARY.md:
|
||||
|
||||
Reference in New Issue
Block a user