From 92660f0ca9d0429987e906cbcefb03aa56c2fe95 Mon Sep 17 00:00:00 2001 From: catlog22 Date: Thu, 2 Oct 2025 09:37:45 +0800 Subject: [PATCH] docs: Enhance TDD command documentation with examples and fix encoding MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit **Task JSON Examples Added (task-generate-tdd.md)**: - RED Phase: Complete TEST task JSON with pre_analysis steps - GREEN Phase: IMPL task JSON with test verification flow - REFACTOR Phase: Quality-focused refactoring task with safeguards - All examples include flow_control with pre/post completion steps **Encoding Fixes (tdd-coverage-analysis.md)**: - Replace Unicode symbols with ASCII markers - ✅ → [PASS] - ❌ → [FAIL] - ⚠️ → [WARN] - → → -> - Ensure cross-platform compatibility - Improve readability in all terminals **Documentation Improvements**: - Detailed flow_control examples for each TDD phase - Clear dependency chain examples - Practical acceptance criteria - Test framework integration patterns 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- .../workflow/tools/task-generate-tdd.md | 153 ++++++++++++++++++ .../workflow/tools/tdd-coverage-analysis.md | Bin 7698 -> 7770 bytes 2 files changed, 153 insertions(+) diff --git a/.claude/commands/workflow/tools/task-generate-tdd.md b/.claude/commands/workflow/tools/task-generate-tdd.md index 4e099cf7..0990dc82 100644 --- a/.claude/commands/workflow/tools/task-generate-tdd.md +++ b/.claude/commands/workflow/tools/task-generate-tdd.md @@ -95,6 +95,159 @@ For each feature, generate 3 tasks with ID format: - `meta.agent`: Agent for task execution - `meta.tdd_phase`: "red" | "green" | "refactor" +#### Task JSON Examples + +**RED Phase - Test Task (TEST-1.1.json)** +```json +{ + "id": "TEST-1.1", + "title": "Write failing test for user authentication", + "status": "pending", + "meta": { + "type": "test", + "agent": "@code-review-test-agent", + "tdd_phase": "red" + }, + "context": { + "requirements": [ + "Write test case for login with valid credentials", + "Test should fail with 'AuthService not implemented' error", + "Include tests for invalid credentials and edge cases" + ], + "focus_paths": ["tests/auth/login.test.ts"], + "acceptance": [ + "Test file created with at least 3 test cases", + "Test runs and fails with clear error message", + "Test assertions define expected behavior" + ], + "depends_on": [] + }, + "flow_control": { + "pre_analysis": [ + { + "step": "check_test_framework", + "action": "Verify test framework is configured", + "command": "bash(npm list jest || npm list vitest)", + "output_to": "test_framework_info", + "on_error": "warn" + } + ] + } +} +``` + +**GREEN Phase - Implementation Task (IMPL-1.1.json)** +```json +{ + "id": "IMPL-1.1", + "title": "Implement user authentication to pass tests", + "status": "pending", + "meta": { + "type": "feature", + "agent": "@code-developer", + "tdd_phase": "green" + }, + "context": { + "requirements": [ + "Implement minimal AuthService to pass TEST-1.1", + "Handle valid and invalid credentials", + "Return appropriate success/error responses" + ], + "focus_paths": ["src/auth/AuthService.ts", "tests/auth/login.test.ts"], + "acceptance": [ + "All tests in TEST-1.1 pass", + "Implementation is minimal and focused", + "No over-engineering or premature optimization" + ], + "depends_on": ["TEST-1.1"] + }, + "flow_control": { + "pre_analysis": [ + { + "step": "load_test_requirements", + "action": "Read test specifications from TEST phase", + "command": "bash(cat .workflow/WFS-xxx/.summaries/TEST-1.1-summary.md)", + "output_to": "test_requirements", + "on_error": "fail" + }, + { + "step": "verify_tests_failing", + "action": "Confirm tests are currently failing", + "command": "bash(npm test -- tests/auth/login.test.ts || echo 'Tests failing as expected')", + "output_to": "initial_test_status", + "on_error": "warn" + } + ], + "post_completion": [ + { + "step": "verify_tests_passing", + "action": "Confirm all tests now pass", + "command": "bash(npm test -- tests/auth/login.test.ts)", + "output_to": "final_test_status", + "on_error": "fail" + } + ] + } +} +``` + +**REFACTOR Phase - Refactoring Task (REFACTOR-1.1.json)** +```json +{ + "id": "REFACTOR-1.1", + "title": "Refactor authentication implementation", + "status": "pending", + "meta": { + "type": "refactor", + "agent": "@code-developer", + "tdd_phase": "refactor" + }, + "context": { + "requirements": [ + "Improve code quality while keeping tests green", + "Remove duplication in credential validation", + "Improve error handling and logging", + "Enhance code readability and maintainability" + ], + "focus_paths": ["src/auth/AuthService.ts", "tests/auth/login.test.ts"], + "acceptance": [ + "Code quality improved (complexity, readability)", + "All tests still pass after refactoring", + "No new functionality added", + "Duplication eliminated" + ], + "depends_on": ["IMPL-1.1"] + }, + "flow_control": { + "pre_analysis": [ + { + "step": "verify_tests_passing", + "action": "Run tests to confirm green state before refactoring", + "command": "bash(npm test -- tests/auth/login.test.ts)", + "output_to": "test_status", + "on_error": "fail" + }, + { + "step": "analyze_code_quality", + "action": "Run linter and complexity analysis", + "command": "bash(npm run lint src/auth/AuthService.ts)", + "output_to": "quality_metrics", + "on_error": "warn" + } + ], + "post_completion": [ + { + "step": "verify_tests_still_passing", + "action": "Confirm tests remain green after refactoring", + "command": "bash(npm test -- tests/auth/login.test.ts)", + "output_to": "final_test_status", + "on_error": "fail" + } + ] + } +} +``` + ### Phase 4: TDD_PLAN.md Generation Generate TDD-specific plan with: diff --git a/.claude/commands/workflow/tools/tdd-coverage-analysis.md b/.claude/commands/workflow/tools/tdd-coverage-analysis.md index 9511c275e9c414e8d53920bc72bcf0458729a19e..0202b143548aecdb3b736ec12e85b49d95f54ee4 100644 GIT binary patch delta 591 zcmbPabIWE!8WXp!oq~H&YHFT>uHEK*CMgy^pn#`ufRC=9o-a^r@>I52A|a{8CB+Km zsYR&@$wjG&C8;S~x|6-xr6y;xub3>#Auj+?ke6SsP>@($43zZY*sK?nnwFScl3$dW zm#$ErSgeqopIeZV3f8Ou(NJ8HnUe$6ve}X|kVzG0xuKpR&~k+!S2suJ5dR=uAfJm% zS0OsUF*rDO@@yVcHYoERw=s+Kt8$|;f_Imv6C7`pX|nO!-?Rv@|yv9P(7RX@vmcs8J8=} z%?M*xim1cblNX9QszW@WV5?wgV4w;%UqM$PC^bbv8yX={AO06rff=D9ro>hc)#nC` zhf-jK7+NVfLjzVp1Ed`(LV?CXqCk@iO_vdoy1)UX0JF>3O2Jbw4;GIw>oy;e@nZx4 D-iEu- delta 454 zcmca*Gs$K{8WZOv1^1%V)I5brn+utwSa>EWc=`tT==$mTDomO@lWmq#v_h;xNNRCO zu|j!jQK~|6QEFmIY6_RG0$gJ925wO%h1kgn>?@gpf|EHo6eQr13VHeE3I&P9#Sk5n zEjTuV6}{q+l|m>gF3HTvK~lC^k~5G=4(b*|Jwt^_3PG-Jj?N+eLApRL7tk=)$^G1> zjI5JSaT^0k8D7iDHatc!Ek>wXfLyp1<^}u;lh5&ZFtToz;T2^P6=7gd&?_j)Pfjf^ z*5^_H0vQH|$wB-!%piI?zZo-7#pY}L>zIK$x`eqIfz)gfbs#nQgs3Bs!6H&`QBMKer$!wIo$RBPcZm=nZIKD+HycB_@~T7in@Klp7JF S9OV3WGBS*lHuK2(F#-VdI)4!W