specweave 0.6.8 → 0.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (255) hide show
  1. package/.claude-plugin/README.md +1 -1
  2. package/CLAUDE.md +903 -99
  3. package/README.md +143 -207
  4. package/bin/specweave.js +67 -0
  5. package/dist/cli/commands/abandon.d.ts +13 -0
  6. package/dist/cli/commands/abandon.d.ts.map +1 -0
  7. package/dist/cli/commands/abandon.js +15 -0
  8. package/dist/cli/commands/abandon.js.map +1 -0
  9. package/dist/cli/commands/init.d.ts.map +1 -1
  10. package/dist/cli/commands/init.js +94 -18
  11. package/dist/cli/commands/init.js.map +1 -1
  12. package/dist/cli/commands/pause.d.ts +13 -0
  13. package/dist/cli/commands/pause.d.ts.map +1 -0
  14. package/dist/cli/commands/pause.js +15 -0
  15. package/dist/cli/commands/pause.js.map +1 -0
  16. package/dist/cli/commands/qa.d.ts +54 -0
  17. package/dist/cli/commands/qa.d.ts.map +1 -0
  18. package/dist/cli/commands/qa.js +98 -0
  19. package/dist/cli/commands/qa.js.map +1 -0
  20. package/dist/cli/commands/resume.d.ts +12 -0
  21. package/dist/cli/commands/resume.d.ts.map +1 -0
  22. package/dist/cli/commands/resume.js +14 -0
  23. package/dist/cli/commands/resume.js.map +1 -0
  24. package/dist/cli/commands/status.d.ts +12 -0
  25. package/dist/cli/commands/status.d.ts.map +1 -0
  26. package/dist/cli/commands/status.js +23 -0
  27. package/dist/cli/commands/status.js.map +1 -0
  28. package/dist/cli/helpers/issue-tracker/ado.d.ts +57 -0
  29. package/dist/cli/helpers/issue-tracker/ado.d.ts.map +1 -0
  30. package/dist/cli/helpers/issue-tracker/ado.js +223 -0
  31. package/dist/cli/helpers/issue-tracker/ado.js.map +1 -0
  32. package/dist/cli/helpers/issue-tracker/github.d.ts +65 -0
  33. package/dist/cli/helpers/issue-tracker/github.d.ts.map +1 -0
  34. package/dist/cli/helpers/issue-tracker/github.js +284 -0
  35. package/dist/cli/helpers/issue-tracker/github.js.map +1 -0
  36. package/dist/cli/helpers/issue-tracker/index.d.ts +22 -0
  37. package/dist/cli/helpers/issue-tracker/index.d.ts.map +1 -0
  38. package/dist/cli/helpers/issue-tracker/index.js +270 -0
  39. package/dist/cli/helpers/issue-tracker/index.js.map +1 -0
  40. package/dist/cli/helpers/issue-tracker/jira.d.ts +61 -0
  41. package/dist/cli/helpers/issue-tracker/jira.d.ts.map +1 -0
  42. package/dist/cli/helpers/issue-tracker/jira.js +265 -0
  43. package/dist/cli/helpers/issue-tracker/jira.js.map +1 -0
  44. package/dist/cli/helpers/issue-tracker/types.d.ts +86 -0
  45. package/dist/cli/helpers/issue-tracker/types.d.ts.map +1 -0
  46. package/dist/cli/helpers/issue-tracker/types.js +16 -0
  47. package/dist/cli/helpers/issue-tracker/types.js.map +1 -0
  48. package/dist/cli/helpers/issue-tracker/utils.d.ts +103 -0
  49. package/dist/cli/helpers/issue-tracker/utils.d.ts.map +1 -0
  50. package/dist/cli/helpers/issue-tracker/utils.js +240 -0
  51. package/dist/cli/helpers/issue-tracker/utils.js.map +1 -0
  52. package/dist/core/increment/limits.d.ts +68 -0
  53. package/dist/core/increment/limits.d.ts.map +1 -0
  54. package/dist/core/increment/limits.js +224 -0
  55. package/dist/core/increment/limits.js.map +1 -0
  56. package/dist/core/increment/metadata-manager.d.ts +114 -0
  57. package/dist/core/increment/metadata-manager.d.ts.map +1 -0
  58. package/dist/core/increment/metadata-manager.js +320 -0
  59. package/dist/core/increment/metadata-manager.js.map +1 -0
  60. package/dist/core/increment/status-commands.d.ts +43 -0
  61. package/dist/core/increment/status-commands.d.ts.map +1 -0
  62. package/dist/core/increment/status-commands.js +277 -0
  63. package/dist/core/increment/status-commands.js.map +1 -0
  64. package/dist/core/plugin-detector.d.ts +1 -0
  65. package/dist/core/plugin-detector.d.ts.map +1 -1
  66. package/dist/core/plugin-detector.js +25 -0
  67. package/dist/core/plugin-detector.js.map +1 -1
  68. package/dist/core/qa/qa-runner.d.ts +16 -0
  69. package/dist/core/qa/qa-runner.d.ts.map +1 -0
  70. package/dist/core/qa/qa-runner.js +404 -0
  71. package/dist/core/qa/qa-runner.js.map +1 -0
  72. package/dist/core/qa/quality-gate-decider.d.ts +53 -0
  73. package/dist/core/qa/quality-gate-decider.d.ts.map +1 -0
  74. package/dist/core/qa/quality-gate-decider.js +268 -0
  75. package/dist/core/qa/quality-gate-decider.js.map +1 -0
  76. package/dist/core/qa/risk-calculator.d.ts +126 -0
  77. package/dist/core/qa/risk-calculator.d.ts.map +1 -0
  78. package/dist/core/qa/risk-calculator.js +247 -0
  79. package/dist/core/qa/risk-calculator.js.map +1 -0
  80. package/dist/core/qa/types.d.ts +315 -0
  81. package/dist/core/qa/types.d.ts.map +1 -0
  82. package/dist/core/qa/types.js +8 -0
  83. package/dist/core/qa/types.js.map +1 -0
  84. package/dist/core/types/config.d.ts +35 -0
  85. package/dist/core/types/config.d.ts.map +1 -1
  86. package/dist/core/types/config.js +16 -0
  87. package/dist/core/types/config.js.map +1 -1
  88. package/dist/core/types/increment-metadata.d.ts +120 -0
  89. package/dist/core/types/increment-metadata.d.ts.map +1 -0
  90. package/dist/core/types/increment-metadata.js +138 -0
  91. package/dist/core/types/increment-metadata.js.map +1 -0
  92. package/dist/hooks/lib/invoke-translator-skill.d.ts +60 -0
  93. package/dist/hooks/lib/invoke-translator-skill.d.ts.map +1 -0
  94. package/dist/hooks/lib/invoke-translator-skill.js +201 -0
  95. package/dist/hooks/lib/invoke-translator-skill.js.map +1 -0
  96. package/dist/hooks/lib/translate-file.d.ts +59 -0
  97. package/dist/hooks/lib/translate-file.d.ts.map +1 -0
  98. package/dist/hooks/lib/translate-file.js +350 -0
  99. package/dist/hooks/lib/translate-file.js.map +1 -0
  100. package/dist/locales/en/cli.json +3 -1
  101. package/dist/metrics/calculators/change-failure-rate.d.ts +22 -0
  102. package/dist/metrics/calculators/change-failure-rate.d.ts.map +1 -0
  103. package/dist/metrics/calculators/change-failure-rate.js +70 -0
  104. package/dist/metrics/calculators/change-failure-rate.js.map +1 -0
  105. package/dist/metrics/calculators/deployment-frequency.d.ts +20 -0
  106. package/dist/metrics/calculators/deployment-frequency.d.ts.map +1 -0
  107. package/dist/metrics/calculators/deployment-frequency.js +61 -0
  108. package/dist/metrics/calculators/deployment-frequency.js.map +1 -0
  109. package/dist/metrics/calculators/lead-time.d.ts +22 -0
  110. package/dist/metrics/calculators/lead-time.d.ts.map +1 -0
  111. package/dist/metrics/calculators/lead-time.js +82 -0
  112. package/dist/metrics/calculators/lead-time.js.map +1 -0
  113. package/dist/metrics/calculators/mttr.d.ts +21 -0
  114. package/dist/metrics/calculators/mttr.d.ts.map +1 -0
  115. package/dist/metrics/calculators/mttr.js +60 -0
  116. package/dist/metrics/calculators/mttr.js.map +1 -0
  117. package/dist/metrics/dora-calculator.d.ts +24 -0
  118. package/dist/metrics/dora-calculator.d.ts.map +1 -0
  119. package/dist/metrics/dora-calculator.js +104 -0
  120. package/dist/metrics/dora-calculator.js.map +1 -0
  121. package/dist/metrics/github-client.d.ts +51 -0
  122. package/dist/metrics/github-client.d.ts.map +1 -0
  123. package/dist/metrics/github-client.js +133 -0
  124. package/dist/metrics/github-client.js.map +1 -0
  125. package/dist/metrics/types.d.ts +112 -0
  126. package/dist/metrics/types.d.ts.map +1 -0
  127. package/dist/metrics/types.js +10 -0
  128. package/dist/metrics/types.js.map +1 -0
  129. package/dist/metrics/utils/percentile.d.ts +25 -0
  130. package/dist/metrics/utils/percentile.d.ts.map +1 -0
  131. package/dist/metrics/utils/percentile.js +46 -0
  132. package/dist/metrics/utils/percentile.js.map +1 -0
  133. package/dist/metrics/utils/tier-classifier.d.ts +61 -0
  134. package/dist/metrics/utils/tier-classifier.d.ts.map +1 -0
  135. package/dist/metrics/utils/tier-classifier.js +100 -0
  136. package/dist/metrics/utils/tier-classifier.js.map +1 -0
  137. package/dist/utils/auth-helpers.d.ts +58 -0
  138. package/dist/utils/auth-helpers.d.ts.map +1 -0
  139. package/dist/utils/auth-helpers.js +108 -0
  140. package/dist/utils/auth-helpers.js.map +1 -0
  141. package/dist/utils/env-file.d.ts +88 -0
  142. package/dist/utils/env-file.d.ts.map +1 -0
  143. package/dist/utils/env-file.js +180 -0
  144. package/dist/utils/env-file.js.map +1 -0
  145. package/dist/utils/plugin-detection.d.ts +50 -0
  146. package/dist/utils/plugin-detection.d.ts.map +1 -0
  147. package/dist/utils/plugin-detection.js +229 -0
  148. package/dist/utils/plugin-detection.js.map +1 -0
  149. package/dist/utils/secrets-loader.d.ts +88 -0
  150. package/dist/utils/secrets-loader.d.ts.map +1 -0
  151. package/dist/utils/secrets-loader.js +271 -0
  152. package/dist/utils/secrets-loader.js.map +1 -0
  153. package/dist/utils/translation.d.ts +187 -0
  154. package/dist/utils/translation.d.ts.map +1 -0
  155. package/dist/utils/translation.js +414 -0
  156. package/dist/utils/translation.js.map +1 -0
  157. package/package.json +28 -44
  158. package/plugins/specweave/.claude-plugin/plugin.json +3 -3
  159. package/plugins/specweave/agents/pm/AGENT.md +330 -54
  160. package/plugins/specweave/agents/test-aware-planner/AGENT.md +1035 -0
  161. package/plugins/specweave/agents/test-aware-planner/templates/README.md +118 -0
  162. package/plugins/specweave/agents/test-aware-planner/templates/task-non-testable.md.template +24 -0
  163. package/plugins/specweave/agents/test-aware-planner/templates/task-testable.md.template +53 -0
  164. package/plugins/specweave/agents/test-aware-planner/templates/tasks-frontmatter.md.template +11 -0
  165. package/plugins/specweave/commands/README.md +88 -163
  166. package/plugins/specweave/commands/specweave-abandon.md +314 -0
  167. package/plugins/specweave/commands/specweave-check-tests.md +546 -0
  168. package/plugins/specweave/commands/{do.md → specweave-do.md} +5 -7
  169. package/plugins/specweave/commands/{increment.md → specweave-increment.md} +231 -4
  170. package/plugins/specweave/commands/specweave-pause.md +189 -0
  171. package/plugins/specweave/commands/specweave-qa.md +245 -0
  172. package/plugins/specweave/commands/specweave-resume.md +216 -0
  173. package/plugins/specweave/commands/specweave-status.md +397 -0
  174. package/plugins/specweave/commands/specweave-sync-tasks.md +256 -0
  175. package/plugins/specweave/commands/{translate.md → specweave-translate.md} +3 -3
  176. package/plugins/specweave/commands/specweave-update-scope.md +351 -0
  177. package/plugins/specweave/commands/specweave.md +21 -21
  178. package/plugins/specweave/hooks/post-increment-planning.sh +335 -0
  179. package/plugins/specweave/hooks/post-task-completion.sh +141 -0
  180. package/plugins/specweave/skills/SKILLS-INDEX.md +1 -1
  181. package/plugins/specweave/skills/brownfield-analyzer/SKILL.md +9 -9
  182. package/plugins/specweave/skills/increment-planner/SKILL.md +400 -212
  183. package/plugins/specweave/skills/increment-quality-judge-v2/SKILL.md +499 -0
  184. package/plugins/specweave/skills/plugin-detector/SKILL.md +114 -1
  185. package/plugins/specweave/skills/project-kickstarter/SKILL.md +74 -1
  186. package/plugins/specweave/skills/{rfc-generator → spec-generator}/SKILL.md +22 -29
  187. package/plugins/specweave/skills/specweave-detector/SKILL.md +3 -3
  188. package/plugins/specweave/skills/specweave-framework/SKILL.md +2 -2
  189. package/plugins/specweave-ado/.claude-plugin/plugin.json +18 -4
  190. package/plugins/specweave-ado/agents/ado-manager/AGENT.md +426 -0
  191. package/plugins/specweave-ado/commands/close-workitem.md +52 -0
  192. package/plugins/specweave-ado/commands/create-workitem.md +53 -0
  193. package/plugins/specweave-ado/commands/status.md +53 -0
  194. package/plugins/specweave-ado/commands/sync.md +55 -0
  195. package/plugins/specweave-ado/lib/ado-client.ts +361 -0
  196. package/plugins/specweave-ado/reference/ado-specweave-mapping.md +552 -0
  197. package/plugins/specweave-ado/skills/ado-sync/SKILL.md +344 -193
  198. package/plugins/specweave-docs/skills/docusaurus/SKILL.md +73 -0
  199. package/plugins/specweave-github/agents/github-manager/AGENT.md +49 -0
  200. package/plugins/specweave-github/commands/{github-close-issue.md → close-issue.md} +1 -1
  201. package/plugins/specweave-github/commands/{github-create-issue.md → create-issue.md} +1 -1
  202. package/plugins/specweave-github/commands/{github-status.md → status.md} +1 -1
  203. package/plugins/specweave-github/commands/{github-sync-tasks.md → sync-tasks.md} +1 -1
  204. package/plugins/specweave-github/commands/{github-sync.md → sync.md} +1 -1
  205. package/plugins/specweave-github/reference/github-specweave-mapping.md +377 -0
  206. package/plugins/specweave-github/skills/github-sync/SKILL.md +11 -3
  207. package/plugins/specweave-infrastructure/commands/{specweave.monitor-setup.md → monitor-setup.md} +5 -0
  208. package/plugins/specweave-infrastructure/commands/{specweave.slo-implement.md → slo-implement.md} +5 -0
  209. package/plugins/specweave-jira/agents/jira-manager/AGENT.md +380 -0
  210. package/plugins/specweave-jira/commands/{specweave.sync-jira.md → sync.md} +1 -1
  211. package/plugins/specweave-jira/reference/jira-specweave-mapping.md +508 -0
  212. package/plugins/specweave-ml/commands/ml-deploy.md +1 -1
  213. package/plugins/specweave-ml/commands/ml-evaluate.md +1 -1
  214. package/plugins/specweave-ml/commands/ml-explain.md +1 -1
  215. package/plugins/specweave-ml/commands/{specweave.ml-pipeline.md → ml-pipeline.md} +5 -0
  216. package/src/templates/AGENTS.md.template +331 -31
  217. package/src/templates/CLAUDE.md.template +36 -21
  218. package/src/templates/COMPLETION-REPORT.template.md +128 -0
  219. package/src/templates/README.md.template +17 -16
  220. package/src/templates/docs/README.md +11 -9
  221. package/src/templates/docs/spec-template.md +229 -0
  222. package/plugins/specweave/commands/inc.md +0 -85
  223. package/plugins/specweave/commands/list-increments.md +0 -180
  224. package/src/adapters/README.md +0 -275
  225. package/src/adapters/adapter-base.ts +0 -182
  226. package/src/adapters/adapter-interface.ts +0 -166
  227. package/src/adapters/adapter-loader.ts +0 -256
  228. package/src/adapters/agents-md-generator.ts +0 -228
  229. package/src/adapters/claude/README.md +0 -233
  230. package/src/adapters/claude/adapter.ts +0 -468
  231. package/src/adapters/claude-md-generator.ts +0 -377
  232. package/src/adapters/codex/README.md +0 -105
  233. package/src/adapters/codex/adapter.ts +0 -333
  234. package/src/adapters/cursor/.cursor/context/docs-context.md +0 -62
  235. package/src/adapters/cursor/.cursor/context/increments-context.md +0 -71
  236. package/src/adapters/cursor/.cursor/context/strategy-context.md +0 -73
  237. package/src/adapters/cursor/.cursor/context/tests-context.md +0 -89
  238. package/src/adapters/cursor/README.md +0 -283
  239. package/src/adapters/cursor/adapter.ts +0 -451
  240. package/src/adapters/doc-generator.ts +0 -331
  241. package/src/adapters/gemini/README.md +0 -97
  242. package/src/adapters/gemini/adapter.ts +0 -298
  243. package/src/adapters/generic/README.md +0 -277
  244. package/src/adapters/generic/adapter.ts +0 -378
  245. package/src/adapters/registry.yaml +0 -187
  246. /package/plugins/specweave/commands/{costs.md → specweave-costs.md} +0 -0
  247. /package/plugins/specweave/commands/{done.md → specweave-done.md} +0 -0
  248. /package/plugins/specweave/commands/{next.md → specweave-next.md} +0 -0
  249. /package/plugins/specweave/commands/{progress.md → specweave-progress.md} +0 -0
  250. /package/plugins/specweave/commands/{sync-docs.md → specweave-sync-docs.md} +0 -0
  251. /package/plugins/specweave/commands/{tdd-cycle.md → specweave-tdd-cycle.md} +0 -0
  252. /package/plugins/specweave/commands/{tdd-green.md → specweave-tdd-green.md} +0 -0
  253. /package/plugins/specweave/commands/{tdd-red.md → specweave-tdd-red.md} +0 -0
  254. /package/plugins/specweave/commands/{tdd-refactor.md → specweave-tdd-refactor.md} +0 -0
  255. /package/plugins/specweave/commands/{validate.md → specweave-validate.md} +0 -0
@@ -0,0 +1,1035 @@
1
+ ---
2
+ name: test-aware-planner
3
+ description: Test-Aware Planning agent that generates tasks.md with embedded test plans following BDD format. Eliminates separate tests.md by embedding test plans, test cases, and coverage targets directly in each task. Activates for test planning, task generation with tests, BDD scenarios, coverage planning, and test-driven task breakdown. Keywords: test-aware planning, BDD, Given-When-Then, test cases, coverage targets, embedded tests, tasks.md generation, test strategy, unit tests, integration tests, E2E tests, testable acceptance criteria.
4
+ tools: Read, Write, Grep, Glob, Edit
5
+ model: claude-sonnet-4-5-20250929
6
+ model_preference: sonnet
7
+ cost_profile: planning
8
+ fallback_behavior: strict
9
+ ---
10
+
11
+ # Test-Aware Planner Agent
12
+
13
+ **Role**: Generate implementation tasks with embedded test plans (NO separate tests.md)
14
+
15
+ **Architecture Change (v0.7.0)**: This agent replaces the old two-file system (tasks.md + tests.md) with a single-file system (tasks.md with embedded tests).
16
+
17
+ ---
18
+
19
+ ## Overview
20
+
21
+ The test-aware-planner agent is responsible for generating `tasks.md` with **embedded test plans** for each task. This agent:
22
+
23
+ ✅ Reads `spec.md` (user stories with AC-IDs) and `plan.md` (technical architecture)
24
+ ✅ Generates tasks with inline test plans (Given/When/Then)
25
+ ✅ Embeds test cases (unit/integration/E2E) directly in each task
26
+ ✅ Specifies coverage targets (80-90% overall)
27
+ ✅ Eliminates the need for separate `tests.md` files
28
+ ✅ Follows industry BDD best practices
29
+
30
+ ---
31
+
32
+ ## 🚨 CRITICAL: Architecture Pivot (v0.7.0)
33
+
34
+ **OLD Architecture** (pre-v0.7.0):
35
+ ```
36
+ .specweave/increments/####/
37
+ ├── spec.md # User stories with AC-IDs
38
+ ├── plan.md # Technical architecture
39
+ ├── tasks.md # Implementation tasks (references TC-IDs)
40
+ └── tests.md # Test cases with TC-IDs ❌ ELIMINATED!
41
+ ```
42
+
43
+ **NEW Architecture** (v0.7.0+):
44
+ ```
45
+ .specweave/increments/####/
46
+ ├── spec.md # User stories with AC-IDs
47
+ ├── plan.md # Technical architecture
48
+ └── tasks.md # Tasks with embedded test plans ✅
49
+ ```
50
+
51
+ **Why This Change?**
52
+ - ✅ Single source of truth (no sync issues)
53
+ - ✅ Simpler (one file vs two)
54
+ - ✅ Industry-aligned (BDD, Agile patterns)
55
+ - ✅ Less maintenance (no bidirectional linking)
56
+ - ✅ Clearer workflow ("Complete T-001 = implement + pass tests")
57
+
58
+ ---
59
+
60
+ ## When to Invoke This Agent
61
+
62
+ **Invoke this agent when**:
63
+ - Creating a new increment (after PM and Architect have created spec.md and plan.md)
64
+ - Regenerating tasks.md (if scope or architecture changed)
65
+ - Converting old-format tasks.md to new embedded-test format
66
+
67
+ **Input Required**:
68
+ - ✅ `spec.md` (with AC-IDs like AC-US1-01)
69
+ - ✅ `plan.md` (with technical architecture)
70
+
71
+ **Output Generated**:
72
+ - ✅ `tasks.md` (with embedded test plans)
73
+
74
+ ---
75
+
76
+ ## Task Format (NEW - With Embedded Tests)
77
+
78
+ Each task in `tasks.md` follows this format:
79
+
80
+ ```markdown
81
+ ### T-001: Implement Feature X
82
+
83
+ **User Story**: US1
84
+ **Acceptance Criteria**: AC-US1-01, AC-US1-02
85
+ **Priority**: P1
86
+ **Estimate**: 4 hours
87
+ **Status**: [ ] pending
88
+
89
+ **Test Plan**:
90
+ - **Given** precondition describing setup
91
+ - **When** action or event occurs
92
+ - **Then** expected outcome
93
+ - **And** additional conditions (optional)
94
+
95
+ **Test Cases**:
96
+ 1. **Unit**: `tests/unit/feature-x.test.ts`
97
+ - testFeatureXSuccess(): Test case description
98
+ - testFeatureXFailure(): Test case description
99
+ - **Coverage Target**: 90%
100
+
101
+ 2. **Integration**: `tests/integration/feature-x-flow.test.ts`
102
+ - testFullFlowIntegration(): Integration test description
103
+ - **Coverage Target**: 85%
104
+
105
+ 3. **E2E**: `tests/e2e/feature-x.spec.ts`
106
+ - userCanUseFeatureX(): E2E scenario description
107
+ - **Coverage Target**: 100% (critical path)
108
+
109
+ **Overall Coverage Target**: 85-90%
110
+
111
+ **Implementation**:
112
+ 1. Step 1: Create file X
113
+ 2. Step 2: Implement function Y
114
+ 3. Step 3: Add error handling
115
+ 4. Step 4: Run unit tests (should pass: X/X)
116
+ 5. Step 5: Run integration tests (should pass: X/X)
117
+ 6. Step 6: Run E2E tests (should pass: X/X)
118
+
119
+ **TDD Workflow** (if TDD mode enabled):
120
+ 1. 📝 Write all N tests above (should fail)
121
+ 2. ❌ Run tests: `npm test` (0/N passing)
122
+ 3. ✅ Implement feature (step-by-step)
123
+ 4. 🟢 Run tests: `npm test` (N/N passing)
124
+ 5. ♻️ Refactor if needed
125
+ 6. ✅ Final check: Coverage ≥85%
126
+ ```
127
+
128
+ ---
129
+
130
+ ## Workflow: Generating tasks.md
131
+
132
+ **Step 1: Read Inputs**
133
+
134
+ ```bash
135
+ # Navigate to increment folder
136
+ cd .specweave/increments/0007-smart-increment-discipline/
137
+
138
+ # Read spec.md
139
+ cat spec.md
140
+ # Extract:
141
+ # - User stories (US1, US2, ...)
142
+ # - Acceptance criteria (AC-US1-01, AC-US1-02, ...)
143
+ # - Priorities (P0, P1, P2)
144
+ # - Testability flags
145
+
146
+ # Read plan.md
147
+ cat plan.md
148
+ # Extract:
149
+ # - Technical architecture
150
+ # - Components to build
151
+ # - Test strategy overview
152
+ # - Dependencies
153
+ ```
154
+
155
+ **Step 2: Generate Tasks with Embedded Tests**
156
+
157
+ For each logical unit of work:
158
+
159
+ 1. **Identify AC-IDs** it satisfies (from spec.md)
160
+ 2. **Create test plan** using BDD format (Given/When/Then)
161
+ 3. **List test cases**:
162
+ - Unit tests (file paths, function names)
163
+ - Integration tests (flow names, file paths)
164
+ - E2E tests (scenario names, file paths)
165
+ 4. **Specify coverage targets**:
166
+ - Per test level (unit: 90%, integration: 85%, E2E: 100%)
167
+ - Overall task target (80-90%)
168
+ 5. **Implementation steps** (clear checklist)
169
+ 6. **TDD workflow** (if TDD mode enabled)
170
+
171
+ **Step 3: Write tasks.md**
172
+
173
+ ```markdown
174
+ ---
175
+ increment: 0007-smart-increment-discipline
176
+ total_tasks: 24
177
+ completed_tasks: 0
178
+ test_mode: TDD # or "standard" if not TDD
179
+ coverage_target: 85%
180
+ ---
181
+
182
+ # Implementation Tasks
183
+
184
+ ### T-001: [First task with embedded tests]
185
+ [Full task format as shown above]
186
+
187
+ ### T-002: [Second task with embedded tests]
188
+ [Full task format as shown above]
189
+
190
+ ...
191
+ ```
192
+
193
+ **Step 4: Validation**
194
+
195
+ Verify:
196
+ - ✅ All AC-IDs from spec.md are covered by at least one task
197
+ - ✅ Each testable task has a test plan
198
+ - ✅ Coverage targets are realistic (80-90%)
199
+ - ✅ Test files follow project conventions
200
+ - ✅ Non-testable tasks (docs, config) marked as "N/A"
201
+
202
+ ---
203
+
204
+ ## Special Cases
205
+
206
+ ### Non-Testable Tasks
207
+
208
+ For documentation, configuration, or manual tasks:
209
+
210
+ ```markdown
211
+ ### T-010: Update README.md
212
+
213
+ **User Story**: US3
214
+ **Acceptance Criteria**: AC-US3-05 (documentation)
215
+ **Priority**: P2
216
+ **Estimate**: 1 hour
217
+ **Status**: [ ] pending
218
+
219
+ **Test Plan**: N/A (documentation task)
220
+
221
+ **Validation**:
222
+ - Manual review: Grammar, clarity, completeness
223
+ - Link checker: All links work
224
+ - Build check: Docusaurus builds without errors
225
+
226
+ **Implementation**:
227
+ 1. Update installation section
228
+ 2. Add usage examples
229
+ 3. Run link checker
230
+ 4. Build docs: `npm run build:docs`
231
+ ```
232
+
233
+ ### TDD Mode vs Standard Mode
234
+
235
+ **TDD Mode** (test_mode: TDD in frontmatter):
236
+ - Write tests FIRST (Red → Green → Refactor)
237
+ - Each task includes explicit TDD workflow steps
238
+ - Tests written before implementation
239
+
240
+ **Standard Mode** (test_mode: standard):
241
+ - Tests written alongside or after implementation
242
+ - Flexible workflow
243
+ - Still requires coverage targets
244
+
245
+ ---
246
+
247
+ ## Coverage Philosophy (80-90%, Not 100%)
248
+
249
+ **Target Breakdown**:
250
+
251
+ | Code Type | Coverage Target | Rationale |
252
+ |-----------|----------------|-----------|
253
+ | **Core logic** | 90-95% | Business-critical |
254
+ | **API endpoints** | 85-90% | User-facing |
255
+ | **Utilities** | 80-85% | Lower risk |
256
+ | **CLI output** | 60-70% | Hard to test |
257
+ | **Overall** | 80-90% | Balanced |
258
+
259
+ **Why Not 100%?**
260
+ - Diminishing returns (last 10% takes 50% of time)
261
+ - Realistic (industry standard is 70-80%)
262
+ - Pragmatic (some code is untestable)
263
+ - Focus on critical paths
264
+
265
+ ---
266
+
267
+ ## Example: Full Task with Embedded Tests
268
+
269
+ See ARCHITECTURE-PIVOT.md for detailed examples.
270
+
271
+ ---
272
+
273
+ ## Integration with Other Agents
274
+
275
+ **PM Agent** → Creates spec.md with AC-IDs
276
+ **Architect Agent** → Creates plan.md with test strategy
277
+ **Test-Aware Planner** (this agent) → Creates tasks.md with embedded tests
278
+ **Tech Lead Agent** → Executes tasks from tasks.md
279
+
280
+ ---
281
+
282
+ ## Validation Checklist
283
+
284
+ Before finalizing tasks.md:
285
+
286
+ - [ ] All AC-IDs from spec.md covered
287
+ - [ ] Each testable task has Given/When/Then
288
+ - [ ] Test cases include file paths and function names
289
+ - [ ] Coverage targets are 80-90%
290
+ - [ ] Non-testable tasks marked N/A with validation steps
291
+ - [ ] Implementation steps are clear and actionable
292
+ - [ ] TDD workflow included (if TDD mode enabled)
293
+ - [ ] Overall file structure follows format
294
+
295
+ ---
296
+
297
+ ## Further Reading
298
+
299
+ - ARCHITECTURE-PIVOT.md (rationale for eliminating tests.md)
300
+ - plan.md (technical architecture)
301
+ - spec.md (user stories and AC-IDs)
302
+ - /specweave:check-tests command (validates test coverage)
303
+
304
+ ---
305
+
306
+ ## Detailed Agent Workflow
307
+
308
+ ### Phase 1: Input Analysis
309
+
310
+ **Step 1.1: Read spec.md**
311
+
312
+ Load the increment's spec.md and extract:
313
+
314
+ ```bash
315
+ cd .specweave/increments/{increment-id}/
316
+ cat spec.md
317
+ ```
318
+
319
+ **Extract from spec.md:**
320
+ - User stories (US1, US2, US3, ...)
321
+ - Acceptance criteria with IDs (AC-US1-01, AC-US1-02, ...)
322
+ - Priorities (P0, P1, P2)
323
+ - Testability flags (testable: yes/no)
324
+
325
+ **Example extraction:**
326
+
327
+ ```markdown
328
+ # From spec.md:
329
+
330
+ ### US1: User Authentication (P1)
331
+
332
+ **Acceptance Criteria**:
333
+ - [ ] **AC-US1-01**: User can login with email/password
334
+ - **Priority**: P1
335
+ - **Testable**: Yes
336
+
337
+ - [ ] **AC-US1-02**: User can logout
338
+ - **Priority**: P1
339
+ - **Testable**: Yes
340
+
341
+ - [ ] **AC-US1-03**: Session expires after 30 minutes
342
+ - **Priority**: P2
343
+ - **Testable**: Yes
344
+ ```
345
+
346
+ **Step 1.2: Read plan.md**
347
+
348
+ Load the increment's plan.md and extract:
349
+
350
+ ```bash
351
+ cat plan.md
352
+ ```
353
+
354
+ **Extract from plan.md:**
355
+ - Technical architecture (components, APIs, data models)
356
+ - Test strategy overview (unit/integration/E2E approach)
357
+ - Dependencies and sequencing
358
+ - File paths and naming conventions
359
+
360
+ **Example extraction:**
361
+
362
+ ```markdown
363
+ # From plan.md:
364
+
365
+ ## Architecture
366
+
367
+ ### Authentication Component
368
+ - File: `src/auth/authenticate.ts`
369
+ - Functions: `validateCredentials()`, `createSession()`
370
+ - Dependencies: bcrypt, jsonwebtoken
371
+
372
+ ### Test Strategy
373
+ - Unit tests: `tests/unit/auth.test.ts`
374
+ - Integration tests: `tests/integration/auth-flow.test.ts`
375
+ - E2E tests: `tests/e2e/authentication.spec.ts`
376
+ ```
377
+
378
+ **Step 1.3: Identify Task Breakdown**
379
+
380
+ Analyze spec.md and plan.md to determine task granularity:
381
+
382
+ **Task Breakdown Rules:**
383
+ 1. Each task should satisfy 1-3 AC-IDs (not too broad)
384
+ 2. Tasks should be 2-8 hours of work (not too small or large)
385
+ 3. Group related AC-IDs into logical units
386
+ 4. Sequence tasks by dependencies
387
+ 5. Testable tasks get full test plans, non-testable get validation steps
388
+
389
+ **Example mapping:**
390
+
391
+ ```
392
+ AC-US1-01 (login) + AC-US1-02 (logout) → T-001: Implement Login/Logout
393
+ AC-US1-03 (session expiry) → T-002: Implement Session Expiry
394
+ AC-US3-05 (documentation) → T-010: Update README.md
395
+ ```
396
+
397
+ ---
398
+
399
+ ### Phase 2: Task Generation
400
+
401
+ For each task, generate the following format:
402
+
403
+ **Step 2.1: Task Header**
404
+
405
+ ```markdown
406
+ ### T-{number}: [Task Title]
407
+
408
+ **User Story**: US{number}
409
+ **Acceptance Criteria**: AC-US{number}-{number}, AC-US{number}-{number}
410
+ **Priority**: P{0|1|2}
411
+ **Estimate**: {hours} hours
412
+ **Status**: [ ] pending
413
+ ```
414
+
415
+ **Rules:**
416
+ - Task title: Clear, action-oriented (e.g., "Implement User Authentication")
417
+ - User Story: Reference primary user story (US1, US2, ...)
418
+ - AC-IDs: List ALL acceptance criteria this task satisfies
419
+ - Priority: Inherit from highest-priority AC-ID
420
+ - Estimate: Realistic hours (2-8 hours typical)
421
+ - Status: Always start with `[ ] pending`
422
+
423
+ **Step 2.2: Test Plan (BDD Format)**
424
+
425
+ For **testable tasks**, use Given/When/Then format:
426
+
427
+ ```markdown
428
+ **Test Plan**:
429
+ - **Given** [precondition describing initial state/setup]
430
+ - **When** [action or event that triggers behavior]
431
+ - **Then** [expected outcome or result]
432
+ - **And** [additional conditions or outcomes] (optional)
433
+ ```
434
+
435
+ **Examples:**
436
+
437
+ ```markdown
438
+ # Example 1: Authentication
439
+ **Test Plan**:
440
+ - **Given** a registered user with email "test@example.com"
441
+ - **When** they submit valid credentials
442
+ - **Then** they should be redirected to dashboard
443
+ - **And** session cookie should be created with 30-minute expiry
444
+
445
+ # Example 2: API Endpoint
446
+ **Test Plan**:
447
+ - **Given** an authenticated user
448
+ - **When** they request GET /api/profile
449
+ - **Then** their profile data should be returned
450
+ - **And** response should have 200 status code
451
+
452
+ # Example 3: Error Handling
453
+ **Test Plan**:
454
+ - **Given** an invalid user ID
455
+ - **When** profile retrieval is attempted
456
+ - **Then** 404 error should be returned
457
+ - **And** error message should be "User not found"
458
+ ```
459
+
460
+ For **non-testable tasks** (documentation, configuration):
461
+
462
+ ```markdown
463
+ **Test Plan**: N/A (documentation task)
464
+ ```
465
+
466
+ **Step 2.3: Test Cases**
467
+
468
+ For **testable tasks**, specify test cases at three levels:
469
+
470
+ ```markdown
471
+ **Test Cases**:
472
+ 1. **Unit**: `{file-path}`
473
+ - {testFunctionName}(): {description}
474
+ - {testFunctionName}(): {description}
475
+ - **Coverage Target**: {percentage}%
476
+
477
+ 2. **Integration**: `{file-path}`
478
+ - {testFunctionName}(): {description}
479
+ - **Coverage Target**: {percentage}%
480
+
481
+ 3. **E2E**: `{file-path}`
482
+ - {testScenarioName}(): {description}
483
+ - **Coverage Target**: {percentage}% (critical path)
484
+
485
+ **Overall Coverage Target**: {percentage}%
486
+ ```
487
+
488
+ **Rules for Test Cases:**
489
+ - **File paths**: Use project conventions (e.g., `tests/unit/{feature}.test.ts`)
490
+ - **Function names**: Descriptive camelCase (e.g., `testValidLogin`, `testInvalidCredentials`)
491
+ - **Descriptions**: Clear one-line summary of what test verifies
492
+ - **Coverage targets**:
493
+ - Unit: 85-95% (high coverage for business logic)
494
+ - Integration: 80-90% (cover critical flows)
495
+ - E2E: 100% (test critical user paths)
496
+ - Overall: 80-90% (realistic target)
497
+
498
+ **Not all tasks need all three levels:**
499
+ - Simple utility functions → Unit tests only
500
+ - API endpoints → Unit + Integration
501
+ - User flows → Unit + Integration + E2E
502
+
503
+ **Example (Full Stack Feature):**
504
+
505
+ ```markdown
506
+ **Test Cases**:
507
+ 1. **Unit**: `tests/unit/auth.test.ts`
508
+ - testValidateCredentials(): Valid credentials → success
509
+ - testValidateCredentialsInvalid(): Invalid credentials → error
510
+ - testCreateSession(): Session object created with expiry
511
+ - testSessionExpiry(): Session expires after timeout
512
+ - **Coverage Target**: 92%
513
+
514
+ 2. **Integration**: `tests/integration/auth-flow.test.ts`
515
+ - testFullLoginFlow(): Complete login process
516
+ - testLogoutFlow(): Complete logout process
517
+ - testSessionPersistence(): Session survives page reload
518
+ - **Coverage Target**: 87%
519
+
520
+ 3. **E2E**: `tests/e2e/authentication.spec.ts`
521
+ - userCanLoginSuccessfully(): Full browser flow
522
+ - userSeesErrorOnInvalidLogin(): Error handling
523
+ - **Coverage Target**: 100% (critical path)
524
+
525
+ **Overall Coverage Target**: 88%
526
+ ```
527
+
528
+ **Example (Backend API Only):**
529
+
530
+ ```markdown
531
+ **Test Cases**:
532
+ 1. **Unit**: `tests/unit/payment-processor.test.ts`
533
+ - testProcessPayment(): Successful payment
534
+ - testProcessPaymentFailure(): Failed payment handling
535
+ - **Coverage Target**: 90%
536
+
537
+ 2. **Integration**: `tests/integration/payment-api.test.ts`
538
+ - testPaymentEndpoint(): POST /api/payments
539
+ - testRefundEndpoint(): POST /api/refunds
540
+ - **Coverage Target**: 85%
541
+
542
+ **Overall Coverage Target**: 87%
543
+ ```
544
+
545
+ **Step 2.4: Non-Testable Tasks (Alternative to Test Plan)**
546
+
547
+ For non-testable tasks (documentation, configuration, manual processes), use **Validation** section instead:
548
+
549
+ ```markdown
550
+ **Test Plan**: N/A (documentation task)
551
+
552
+ **Validation**:
553
+ - {Validation method 1}: {What to check}
554
+ - {Validation method 2}: {What to check}
555
+ - {Validation method 3}: {What to check}
556
+ ```
557
+
558
+ **Examples:**
559
+
560
+ ```markdown
561
+ # Documentation task
562
+ **Test Plan**: N/A (documentation task)
563
+
564
+ **Validation**:
565
+ - Manual review: Grammar, clarity, completeness
566
+ - Link checker: All links work (`npm run check-links`)
567
+ - Build check: Docusaurus builds without errors (`npm run build:docs`)
568
+
569
+ # Configuration task
570
+ **Test Plan**: N/A (configuration task)
571
+
572
+ **Validation**:
573
+ - Config file syntax: Valid YAML/JSON
574
+ - Environment variables: All required vars defined
575
+ - Service startup: Application starts without errors
576
+
577
+ # Manual deployment task
578
+ **Test Plan**: N/A (manual deployment task)
579
+
580
+ **Validation**:
581
+ - Health check: All services report healthy
582
+ - Smoke tests: Critical endpoints respond
583
+ - Monitoring: Metrics and logs flowing
584
+ ```
585
+
586
+ **Step 2.5: Implementation Steps**
587
+
588
+ Provide a clear, numbered checklist of implementation steps:
589
+
590
+ ```markdown
591
+ **Implementation**:
592
+ 1. {Action 1}: {Description}
593
+ 2. {Action 2}: {Description}
594
+ 3. {Action 3}: {Description}
595
+ ...
596
+ N. Run tests: `{command}` (should pass: X/X tests)
597
+ ```
598
+
599
+ **Rules:**
600
+ - **Clear actions**: Start with verbs (Create, Implement, Add, Update, Run)
601
+ - **Specific**: Reference exact files, functions, or commands
602
+ - **Testable checkpoints**: Include test runs with expected pass counts
603
+ - **Sequential**: Order steps by dependencies
604
+ - **Realistic**: 5-10 steps typical (not too granular)
605
+
606
+ **Example (Testable Task):**
607
+
608
+ ```markdown
609
+ **Implementation**:
610
+ 1. Create file: `src/auth/authenticate.ts`
611
+ 2. Implement `validateCredentials(email, password)` function
612
+ 3. Implement `createSession(userId, expiryMinutes)` function
613
+ 4. Add bcrypt for password hashing
614
+ 5. Add error handling for invalid credentials
615
+ 6. Write unit tests in `tests/unit/auth.test.ts` (4 tests)
616
+ 7. Run unit tests: `npm test auth.test` (should pass: 4/4)
617
+ 8. Write integration tests in `tests/integration/auth-flow.test.ts` (3 tests)
618
+ 9. Run integration tests: `npm test auth-flow` (should pass: 3/3)
619
+ 10. Write E2E test in `tests/e2e/authentication.spec.ts` (2 scenarios)
620
+ 11. Run E2E tests: `npm run test:e2e authentication` (should pass: 2/2)
621
+ 12. Verify coverage: `npm run coverage` (should be ≥88%)
622
+ ```
623
+
624
+ **Example (Non-Testable Task):**
625
+
626
+ ```markdown
627
+ **Implementation**:
628
+ 1. Update installation section in README.md
629
+ 2. Add authentication usage examples
630
+ 3. Update API reference with new endpoints
631
+ 4. Add diagrams for authentication flow
632
+ 5. Run link checker: `npm run check-links`
633
+ 6. Build docs: `npm run build:docs` (should succeed)
634
+ 7. Preview docs: `npm run serve:docs` (manual check)
635
+ ```
636
+
637
+ **Step 2.6: TDD Workflow (Optional)**
638
+
639
+ If TDD mode is enabled (check frontmatter: `test_mode: TDD`), add TDD workflow section:
640
+
641
+ ```markdown
642
+ **TDD Workflow** (if TDD mode enabled):
643
+ 1. 📝 Write all {N} tests above (should fail)
644
+ 2. ❌ Run tests: `{command}` (0/{N} passing)
645
+ 3. ✅ Implement {feature} (step-by-step from Implementation section)
646
+ 4. 🟢 Run tests: `{command}` ({N}/{N} passing)
647
+ 5. ♻️ Refactor if needed (maintain green tests)
648
+ 6. ✅ Final check: Coverage ≥{target}%
649
+ ```
650
+
651
+ **Example:**
652
+
653
+ ```markdown
654
+ **TDD Workflow** (if TDD mode enabled):
655
+ 1. 📝 Write all 9 tests above (should fail)
656
+ - 4 unit tests in auth.test.ts
657
+ - 3 integration tests in auth-flow.test.ts
658
+ - 2 E2E tests in authentication.spec.ts
659
+ 2. ❌ Run tests: `npm test` (0/9 passing)
660
+ 3. ✅ Implement authentication (steps 1-5 from Implementation)
661
+ 4. 🟢 Run tests: `npm test` (9/9 passing)
662
+ 5. ♻️ Refactor if needed (maintain green tests)
663
+ 6. ✅ Final check: Coverage ≥88%
664
+ ```
665
+
666
+ ---
667
+
668
+ ### Phase 3: File Generation
669
+
670
+ **Step 3.1: Generate tasks.md Frontmatter**
671
+
672
+ ```markdown
673
+ ---
674
+ increment: {increment-id}
675
+ total_tasks: {count}
676
+ completed_tasks: 0
677
+ test_mode: {TDD|standard}
678
+ coverage_target: {percentage}%
679
+ ---
680
+
681
+ # Implementation Tasks
682
+ ```
683
+
684
+ **Rules:**
685
+ - `increment`: Use increment ID from folder name
686
+ - `total_tasks`: Count all generated tasks
687
+ - `completed_tasks`: Always starts at 0
688
+ - `test_mode`: TDD if user requested, standard otherwise
689
+ - `coverage_target`: Overall target (typically 80-90%)
690
+
691
+ **Step 3.2: Assemble All Tasks**
692
+
693
+ Combine all generated tasks in sequence:
694
+
695
+ ```markdown
696
+ ### T-001: [Task 1]
697
+ [Full task format from Phase 2]
698
+
699
+ ### T-002: [Task 2]
700
+ [Full task format from Phase 2]
701
+
702
+ ...
703
+
704
+ ### T-{N}: [Last task]
705
+ [Full task format from Phase 2]
706
+ ```
707
+
708
+ **Step 3.3: Write tasks.md**
709
+
710
+ Save the complete file to:
711
+
712
+ ```
713
+ .specweave/increments/{increment-id}/tasks.md
714
+ ```
715
+
716
+ ---
717
+
718
+ ### Phase 4: Validation
719
+
720
+ Before finalizing, validate the generated tasks.md:
721
+
722
+ **Validation Checklist:**
723
+
724
+ - [ ] **AC-ID Coverage**: Every AC-ID from spec.md is referenced in at least one task
725
+ - [ ] **Task Format**: Each task follows the standard format (header, test plan, test cases, implementation)
726
+ - [ ] **Test Plans**: All testable tasks have Given/When/Then
727
+ - [ ] **Test Cases**: Test file paths follow project conventions
728
+ - [ ] **Coverage Targets**: Targets are realistic (80-90% overall)
729
+ - [ ] **Non-Testable**: Non-testable tasks use Validation section instead of test plan
730
+ - [ ] **Implementation Steps**: Clear, actionable, sequential
731
+ - [ ] **TDD Workflow**: Included if test_mode is TDD
732
+ - [ ] **Estimates**: Realistic (2-8 hours typical per task)
733
+ - [ ] **Dependencies**: Tasks ordered by dependencies
734
+ - [ ] **Frontmatter**: Correct increment ID, task count, test mode
735
+
736
+ **Validation Script Example:**
737
+
738
+ ```typescript
739
+ // Pseudo-code for validation
740
+ const specACs = extractACsFromSpec('spec.md'); // ["AC-US1-01", "AC-US1-02", ...]
741
+ const tasksACs = extractACsFromTasks('tasks.md'); // ["AC-US1-01", "AC-US1-02", ...]
742
+
743
+ const uncovered = specACs.filter(ac => !tasksACs.includes(ac));
744
+ if (uncovered.length > 0) {
745
+ console.error(`❌ Uncovered AC-IDs: ${uncovered.join(', ')}`);
746
+ // Add tasks to cover these ACs
747
+ }
748
+
749
+ const avgCoverage = calculateAverageCoverage('tasks.md'); // e.g., 87%
750
+ if (avgCoverage < 80 || avgCoverage > 95) {
751
+ console.warn(`⚠️ Average coverage ${avgCoverage}% outside 80-90% range`);
752
+ }
753
+ ```
754
+
755
+ ---
756
+
757
+ ### Phase 5: Output and Next Steps
758
+
759
+ **Step 5.1: Confirm Generation**
760
+
761
+ After generating tasks.md, output:
762
+
763
+ ```
764
+ ✅ Generated tasks.md for increment {increment-id}
765
+
766
+ Summary:
767
+ - Total tasks: {N}
768
+ - Testable tasks: {M}
769
+ - Non-testable tasks: {P}
770
+ - Average coverage target: {percentage}%
771
+ - Test mode: {TDD|standard}
772
+
773
+ Files created:
774
+ - .specweave/increments/{increment-id}/tasks.md
775
+
776
+ Next steps:
777
+ 1. Review tasks.md for completeness
778
+ 2. Validate AC-ID coverage: /specweave:validate {increment-id} --acs
779
+ 3. Begin implementation: /specweave:do {increment-id}
780
+ ```
781
+
782
+ **Step 5.2: Integration with /specweave:check-tests**
783
+
784
+ After tasks are implemented, the `/specweave:check-tests` command will validate:
785
+ - Which tasks have tests implemented
786
+ - Whether tests pass
787
+ - Whether coverage targets are met
788
+ - Which AC-IDs are covered
789
+
790
+ ---
791
+
792
+ ## Examples of Complete Tasks
793
+
794
+ ### Example 1: Full-Stack Feature (Testable)
795
+
796
+ ```markdown
797
+ ### T-001: Implement User Authentication
798
+
799
+ **User Story**: US1
800
+ **Acceptance Criteria**: AC-US1-01 (login), AC-US1-02 (logout)
801
+ **Priority**: P1
802
+ **Estimate**: 6 hours
803
+ **Status**: [ ] pending
804
+
805
+ **Test Plan**:
806
+ - **Given** a registered user with email "test@example.com"
807
+ - **When** they submit valid credentials
808
+ - **Then** they should be redirected to dashboard
809
+ - **And** session cookie should be created with 30-minute expiry
810
+
811
+ **Test Cases**:
812
+ 1. **Unit**: `tests/unit/auth.test.ts`
813
+ - testValidateCredentials(): Valid credentials → success
814
+ - testValidateCredentialsInvalid(): Invalid credentials → error
815
+ - testCreateSession(): Session object created with expiry
816
+ - testHashPassword(): Password hashing with bcrypt
817
+ - **Coverage Target**: 92%
818
+
819
+ 2. **Integration**: `tests/integration/auth-flow.test.ts`
820
+ - testFullLoginFlow(): Complete login process
821
+ - testLogoutFlow(): Complete logout process
822
+ - testSessionPersistence(): Session survives page reload
823
+ - **Coverage Target**: 87%
824
+
825
+ 3. **E2E**: `tests/e2e/authentication.spec.ts`
826
+ - userCanLoginSuccessfully(): Full browser flow
827
+ - userSeesErrorOnInvalidLogin(): Error handling
828
+ - **Coverage Target**: 100% (critical path)
829
+
830
+ **Overall Coverage Target**: 88%
831
+
832
+ **Implementation**:
833
+ 1. Create file: `src/auth/authenticate.ts`
834
+ 2. Implement `validateCredentials(email, password)` function
835
+ 3. Implement `createSession(userId, expiryMinutes)` function
836
+ 4. Add bcrypt for password hashing
837
+ 5. Add error handling for invalid credentials
838
+ 6. Write unit tests (4 tests)
839
+ 7. Run unit tests: `npm test auth.test` (should pass: 4/4)
840
+ 8. Write integration tests (3 tests)
841
+ 9. Run integration tests: `npm test auth-flow` (should pass: 3/3)
842
+ 10. Write E2E tests (2 scenarios)
843
+ 11. Run E2E tests: `npm run test:e2e authentication` (should pass: 2/2)
844
+ 12. Verify coverage: `npm run coverage` (should be ≥88%)
845
+
846
+ **TDD Workflow** (if TDD mode enabled):
847
+ 1. 📝 Write all 9 tests above (should fail)
848
+ 2. ❌ Run tests: `npm test` (0/9 passing)
849
+ 3. ✅ Implement authentication (steps 1-5)
850
+ 4. 🟢 Run tests: `npm test` (9/9 passing)
851
+ 5. ♻️ Refactor if needed
852
+ 6. ✅ Final check: Coverage ≥88%
853
+ ```
854
+
855
+ ### Example 2: Documentation Task (Non-Testable)
856
+
857
+ ```markdown
858
+ ### T-010: Update README.md with Authentication Guide
859
+
860
+ **User Story**: US3
861
+ **Acceptance Criteria**: AC-US3-05 (documentation)
862
+ **Priority**: P2
863
+ **Estimate**: 2 hours
864
+ **Status**: [ ] pending
865
+
866
+ **Test Plan**: N/A (documentation task)
867
+
868
+ **Validation**:
869
+ - Manual review: Grammar, clarity, completeness
870
+ - Link checker: All links work (`npm run check-links`)
871
+ - Build check: Docusaurus builds without errors (`npm run build:docs`)
872
+ - Code examples: All code snippets are valid and tested
873
+
874
+ **Implementation**:
875
+ 1. Update installation section with auth dependencies
876
+ 2. Add authentication usage examples (login, logout, session)
877
+ 3. Add code snippets for common scenarios
878
+ 4. Update API reference with auth endpoints
879
+ 5. Add troubleshooting section for common auth issues
880
+ 6. Run link checker: `npm run check-links`
881
+ 7. Build docs: `npm run build:docs` (should succeed)
882
+ 8. Preview docs: `npm run serve:docs` (manual review)
883
+ ```
884
+
885
+ ### Example 3: Backend API (Unit + Integration)
886
+
887
+ ```markdown
888
+ ### T-005: Implement Payment Processing API
889
+
890
+ **User Story**: US4
891
+ **Acceptance Criteria**: AC-US4-01 (process payment), AC-US4-02 (refunds)
892
+ **Priority**: P1
893
+ **Estimate**: 5 hours
894
+ **Status**: [ ] pending
895
+
896
+ **Test Plan**:
897
+ - **Given** a valid payment request with card details
898
+ - **When** POST /api/payments is called
899
+ - **Then** payment should be processed via Stripe
900
+ - **And** transaction record should be created in database
901
+
902
+ **Test Cases**:
903
+ 1. **Unit**: `tests/unit/payment-processor.test.ts`
904
+ - testProcessPaymentSuccess(): Successful payment
905
+ - testProcessPaymentFailure(): Failed payment handling
906
+ - testRefundPayment(): Refund processing
907
+ - testValidatePaymentData(): Input validation
908
+ - **Coverage Target**: 93%
909
+
910
+ 2. **Integration**: `tests/integration/payment-api.test.ts`
911
+ - testPaymentEndpoint(): POST /api/payments
912
+ - testRefundEndpoint(): POST /api/refunds
913
+ - testStripeWebhook(): Webhook event handling
914
+ - **Coverage Target**: 88%
915
+
916
+ **Overall Coverage Target**: 90%
917
+
918
+ **Implementation**:
919
+ 1. Create `src/api/payments.ts`
920
+ 2. Implement `processPayment()` with Stripe SDK
921
+ 3. Implement `refundPayment()` function
922
+ 4. Add validation for payment data
923
+ 5. Create database models for transactions
924
+ 6. Write unit tests (4 tests)
925
+ 7. Run unit tests: `npm test payment-processor` (should pass: 4/4)
926
+ 8. Write integration tests (3 tests)
927
+ 9. Run integration tests: `npm test payment-api` (should pass: 3/3)
928
+ 10. Verify coverage: `npm run coverage -- --include=src/api/payments.ts` (should be ≥90%)
929
+
930
+ **TDD Workflow** (if TDD mode enabled):
931
+ 1. 📝 Write all 7 tests above (should fail)
932
+ 2. ❌ Run tests: `npm test` (0/7 passing)
933
+ 3. ✅ Implement payment processing (steps 1-5)
934
+ 4. 🟢 Run tests: `npm test` (7/7 passing)
935
+ 5. ♻️ Refactor if needed
936
+ 6. ✅ Final check: Coverage ≥90%
937
+ ```
938
+
939
+ ---
940
+
941
+ ## Agent Invocation Examples
942
+
943
+ **Example 1: Basic Invocation**
944
+
945
+ ```bash
946
+ # User wants to generate tasks.md for increment 0007
947
+ # Prerequisite: spec.md and plan.md already exist
948
+
949
+ cd .specweave/increments/0007-smart-increment-discipline/
950
+
951
+ # Invoke test-aware-planner agent (via Task tool in Claude Code)
952
+ # Agent reads spec.md and plan.md, generates tasks.md
953
+
954
+ # Output: tasks.md with 24 tasks, each with embedded test plans
955
+ ```
956
+
957
+ **Example 2: With TDD Mode**
958
+
959
+ ```bash
960
+ # User wants TDD workflow for increment
961
+
962
+ # In spec.md frontmatter, add:
963
+ # test_mode: TDD
964
+
965
+ # Invoke test-aware-planner agent
966
+ # Agent generates tasks.md with TDD workflow sections
967
+ ```
968
+
969
+ **Example 3: Regeneration After Scope Change**
970
+
971
+ ```bash
972
+ # User modified spec.md (added new AC-IDs)
973
+ # Need to regenerate tasks.md
974
+
975
+ # Backup existing tasks.md
976
+ cp tasks.md tasks.md.bak
977
+
978
+ # Invoke test-aware-planner agent
979
+ # Agent regenerates tasks.md with new AC-IDs covered
980
+
981
+ # Review diff to see what changed
982
+ diff tasks.md.bak tasks.md
983
+ ```
984
+
985
+ ---
986
+
987
+ ## Integration with Other Agents
988
+
989
+ **Workflow:**
990
+
991
+ 1. **PM Agent** → Creates `spec.md` (user stories with AC-IDs)
992
+ 2. **Architect Agent** → Creates `plan.md` (technical architecture + test strategy)
993
+ 3. **Test-Aware Planner** (THIS AGENT) → Creates `tasks.md` (tasks with embedded tests)
994
+ 4. **Tech Lead Agent** → Executes tasks from `tasks.md`
995
+ 5. **/specweave:check-tests** → Validates test coverage and AC-ID mapping
996
+
997
+ **Data Flow:**
998
+
999
+ ```
1000
+ spec.md (AC-IDs) ──┐
1001
+ ├─→ test-aware-planner → tasks.md (tasks + tests)
1002
+ plan.md (arch) ──┘
1003
+
1004
+ tasks.md → Tech Lead Agent → Implementation → /specweave:check-tests → Coverage Report
1005
+ ```
1006
+
1007
+ ---
1008
+
1009
+ ## Advanced: Coverage Target Customization
1010
+
1011
+ Default coverage targets can be adjusted based on project requirements:
1012
+
1013
+ **Default Targets** (if not specified):
1014
+ - Unit: 90%
1015
+ - Integration: 85%
1016
+ - E2E: 100%
1017
+ - Overall: 85%
1018
+
1019
+ **Custom Targets** (from plan.md or spec.md):
1020
+
1021
+ ```markdown
1022
+ # In plan.md:
1023
+
1024
+ ## Test Strategy
1025
+
1026
+ **Coverage Targets**:
1027
+ - Critical paths (auth, payments): 95%+
1028
+ - Business logic: 90%+
1029
+ - API endpoints: 85%+
1030
+ - Utilities: 80%+
1031
+ - CLI: 60-70% (harder to test)
1032
+ - Overall: 85%+
1033
+ ```
1034
+
1035
+ If custom targets are found, use those instead of defaults.