diff --git a/.claude/commands/workflow/tdd-plan.md b/.claude/commands/workflow/tdd-plan.md index 182b2881..e3fe232a 100644 --- a/.claude/commands/workflow/tdd-plan.md +++ b/.claude/commands/workflow/tdd-plan.md @@ -417,110 +417,6 @@ Convert user input to TDD-structured format: - **Command failure**: Keep phase in_progress, report error - **TDD validation failure**: Report incomplete chains or wrong dependencies -## TDD Workflow Enhancements - -### Overview -The TDD workflow has been significantly enhanced by integrating best practices from both traditional `plan --agent` and `test-gen` workflows, creating a hybrid approach that bridges the gap between idealized TDD and real-world development complexity. - -### Key Improvements - -#### 1. Test Coverage Analysis (Phase 3) -**Adopted from test-gen workflow** - -Before planning TDD tasks, the workflow now analyzes the existing codebase: -- Detects existing test patterns and conventions -- Identifies current test coverage -- Discovers related components and integration points -- Detects test framework automatically - -**Benefits**: -- Context-aware TDD planning -- Avoids duplicate test creation -- Enables integration with existing tests -- No longer assumes greenfield scenarios - -#### 2. Iterative Green Phase with Test-Fix Cycle -**Adopted from test-gen workflow** - -IMPL (Green phase) tasks now include automatic test-fix cycle for resilient implementation: - -**Enhanced IMPL Task Flow**: -``` -1. Write minimal implementation code -2. Execute test suite -3. IF tests pass → Complete task -4. IF tests fail → Enter fix cycle: - a. Gemini diagnoses with bug-fix template - b. Apply fix (manual or Codex) - c. Retest - d. Repeat (max 3 iterations) -5. IF max iterations → Auto-revert changes 🔄 -``` - -**Benefits**: -- Faster feedback within Green phase -- Autonomous recovery from implementation errors -- Systematic debugging with Gemini -- Safe rollback prevents broken state - -#### 3. Agent-Driven Planning -**From plan --agent workflow** - -Supports action-planning-agent for more autonomous TDD planning with: -- MCP tool integration (code-index, exa) -- Memory-first principles -- Brainstorming artifact integration -- Task merging over decomposition - -### Workflow Comparison - -| Aspect | Previous | Current (Optimized) | -|--------|----------|---------------------| -| **Phases** | 6 (with test coverage) | 7 (added concept verification) | -| **Context** | Greenfield assumption | Existing codebase aware | -| **Task Structure** | 1 feature = 3 tasks (TEST/IMPL/REFACTOR) | 1 feature = 1 task (internal TDD cycle) | -| **Task Count** | 5 features = 15 tasks | 5 features = 5 tasks (70% reduction) | -| **Green Phase** | Single implementation | Iterative with fix cycle | -| **Failure Handling** | Manual intervention | Auto-diagnose + fix + revert | -| **Test Analysis** | None | Deep coverage analysis | -| **Feedback Loop** | Post-execution | During Green phase | -| **Task Management** | High overhead (15 tasks) | Low overhead (5 tasks) | -| **Execution Efficiency** | Frequent context switching | Continuous context per feature | - -### Migration Notes - -**Backward Compatibility**: Fully compatible -- Existing TDD workflows continue to work -- New features are additive, not breaking -- Phase 3 can be skipped if test-context-gather not available - -**Session Structure**: -``` -.workflow/active/WFS-xxx/ -├── IMPL_PLAN.md (unified plan with TDD Implementation Tasks section) -├── TODO_LIST.md (with internal TDD phase indicators) -├── .process/ -│ ├── context-package.json -│ ├── test-context-package.json -│ ├── ANALYSIS_RESULTS.md (enhanced with TDD breakdown) -│ └── green-fix-iteration-*.md (fix logs from Green phase cycles) -└── .task/ - ├── IMPL-1.json (Complete TDD task: Red-Green-Refactor internally) - ├── IMPL-2.json (Complete TDD task) - ├── IMPL-3.json (Complex feature container, if needed) - ├── IMPL-3.1.json (Complex feature subtask, if needed) - └── IMPL-3.2.json (Complex feature subtask, if needed) -``` - -**File Count Comparison**: -- **Old structure**: 5 features = 15 task files (TEST/IMPL/REFACTOR × 5) -- **New structure**: 5 features = 5 task files (IMPL-N × 5) -- **Complex features**: Add container + subtasks only when necessary - -**Configuration Options** (in IMPL tasks): -- `meta.max_iterations`: Fix attempts (default: 3) -- `meta.use_codex`: Auto-fix mode (default: false) - ## Related Commands **Prerequisite Commands**: