@arvorco/relentless 0.3.0 → 0.4.2

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 (71) hide show
  1. package/.claude/commands/relentless.constitution.md +1 -1
  2. package/.claude/commands/relentless.convert.md +25 -0
  3. package/.claude/commands/relentless.specify.md +1 -1
  4. package/.claude/skills/analyze/SKILL.md +113 -40
  5. package/.claude/skills/analyze/templates/analysis-report.md +138 -0
  6. package/.claude/skills/checklist/SKILL.md +143 -51
  7. package/.claude/skills/checklist/templates/checklist.md +43 -11
  8. package/.claude/skills/clarify/SKILL.md +70 -11
  9. package/.claude/skills/constitution/SKILL.md +61 -3
  10. package/.claude/skills/constitution/templates/constitution.md +241 -160
  11. package/.claude/skills/constitution/templates/prompt.md +150 -20
  12. package/.claude/skills/convert/SKILL.md +248 -0
  13. package/.claude/skills/implement/SKILL.md +82 -34
  14. package/.claude/skills/plan/SKILL.md +136 -27
  15. package/.claude/skills/plan/templates/plan.md +92 -9
  16. package/.claude/skills/specify/SKILL.md +110 -19
  17. package/.claude/skills/specify/scripts/bash/create-new-feature.sh +2 -2
  18. package/.claude/skills/specify/scripts/bash/setup-plan.sh +1 -1
  19. package/.claude/skills/specify/templates/spec.md +40 -5
  20. package/.claude/skills/tasks/SKILL.md +75 -1
  21. package/.claude/skills/tasks/templates/tasks.md +5 -4
  22. package/CHANGELOG.md +63 -1
  23. package/MANUAL.md +40 -0
  24. package/README.md +263 -11
  25. package/bin/relentless.ts +292 -5
  26. package/package.json +2 -2
  27. package/relentless/config.json +46 -2
  28. package/relentless/constitution.md +2 -2
  29. package/relentless/prompt.md +97 -18
  30. package/src/agents/amp.ts +53 -13
  31. package/src/agents/claude.ts +70 -15
  32. package/src/agents/codex.ts +73 -14
  33. package/src/agents/droid.ts +68 -14
  34. package/src/agents/exec.ts +96 -0
  35. package/src/agents/gemini.ts +59 -16
  36. package/src/agents/opencode.ts +188 -9
  37. package/src/cli/fallback-order.ts +210 -0
  38. package/src/cli/index.ts +63 -0
  39. package/src/cli/mode-flag.ts +198 -0
  40. package/src/cli/review-flags.ts +192 -0
  41. package/src/config/loader.ts +16 -1
  42. package/src/config/schema.ts +157 -2
  43. package/src/execution/runner.ts +144 -21
  44. package/src/init/scaffolder.ts +285 -25
  45. package/src/prd/parser.ts +92 -1
  46. package/src/prd/types.ts +136 -0
  47. package/src/review/index.ts +92 -0
  48. package/src/review/prompt.ts +293 -0
  49. package/src/review/runner.ts +337 -0
  50. package/src/review/tasks/docs.ts +529 -0
  51. package/src/review/tasks/index.ts +80 -0
  52. package/src/review/tasks/lint.ts +436 -0
  53. package/src/review/tasks/quality.ts +760 -0
  54. package/src/review/tasks/security.ts +452 -0
  55. package/src/review/tasks/test.ts +456 -0
  56. package/src/review/tasks/typecheck.ts +323 -0
  57. package/src/review/types.ts +139 -0
  58. package/src/routing/cascade.ts +310 -0
  59. package/src/routing/classifier.ts +338 -0
  60. package/src/routing/estimate.ts +270 -0
  61. package/src/routing/fallback.ts +512 -0
  62. package/src/routing/index.ts +124 -0
  63. package/src/routing/registry.ts +501 -0
  64. package/src/routing/report.ts +570 -0
  65. package/src/routing/router.ts +287 -0
  66. package/src/tui/App.tsx +2 -0
  67. package/src/tui/TUIRunner.tsx +103 -8
  68. package/src/tui/components/CurrentStory.tsx +23 -1
  69. package/src/tui/hooks/useTUI.ts +1 -0
  70. package/src/tui/types.ts +9 -0
  71. package/.claude/skills/specify/scripts/bash/update-agent-context.sh +0 -799
@@ -0,0 +1,248 @@
1
+ ---
2
+ name: convert
3
+ description: "Convert tasks.md to prd.json with smart routing classification. Use after creating tasks. Triggers on: convert to prd, generate prd.json, convert tasks."
4
+ ---
5
+
6
+ # Tasks to PRD Converter (with Smart Routing)
7
+
8
+ Convert user stories from tasks.md into prd.json format WITH automatic routing classification.
9
+
10
+ > **Note:** This command is typically auto-run by the `/relentless.tasks` skill.
11
+ > Manual execution is only needed if you edit `tasks.md` by hand after generation.
12
+
13
+ ---
14
+
15
+ ## The Job
16
+
17
+ 1. Locate tasks.md in the current feature directory
18
+ 2. Validate story structure, dependencies, and TDD compliance
19
+ 3. Preview conversion (show story count, dependency chain)
20
+ 4. Run the conversion with routing: `relentless convert tasks.md --feature <name>`
21
+ 5. Validate the generated prd.json HAS routing metadata
22
+ 6. Display routing summary (cost estimates per story)
23
+ 7. Report next step
24
+
25
+ ---
26
+
27
+ ## Why Routing Matters
28
+
29
+ Routing is the **core value** of Relentless:
30
+
31
+ - **Simple tasks** use cheap models (haiku, flash) - saves money
32
+ - **Complex tasks** use SOTA models (opus, gpt-5) - ensures quality
33
+ - **Estimated costs** BEFORE execution - no surprises
34
+ - **Compare estimated vs actual** after execution - learn and improve
35
+
36
+ Without routing, you lose the intelligent cost optimization that makes Relentless valuable.
37
+
38
+ ---
39
+
40
+ ## Step 1: Find Feature Directory
41
+
42
+ Look in `relentless/features/` for the most recent feature:
43
+
44
+ ```bash
45
+ ls -la relentless/features/
46
+ ```
47
+
48
+ Verify:
49
+ - [ ] tasks.md exists in the feature directory
50
+ - [ ] spec.md exists (for context)
51
+ - [ ] Feature directory follows naming convention (NNN-feature-name)
52
+
53
+ If tasks.md doesn't exist, suggest running `/relentless.tasks` first.
54
+
55
+ ---
56
+
57
+ ## Step 2: Validate tasks.md Structure
58
+
59
+ Before conversion, validate the tasks.md file:
60
+
61
+ ### Required Elements
62
+
63
+ - [ ] Each story has unique ID (US-XXX format)
64
+ - [ ] Each story has acceptance criteria
65
+ - [ ] **TDD criteria included** (tests must be mentioned in acceptance criteria)
66
+ - [ ] Dependencies reference valid story IDs
67
+ - [ ] No circular dependencies
68
+ - [ ] Routing Preference line present (recommended)
69
+
70
+ ### Example Valid Story
71
+
72
+ ```markdown
73
+ ### US-001: Create User Registration
74
+
75
+ **Description:** As a new user, I want to register so I can access the app.
76
+
77
+ **Acceptance Criteria:**
78
+ - [ ] POST /api/register endpoint exists
79
+ - [ ] Email validation works
80
+ - [ ] Password is hashed
81
+ - [ ] Unit tests pass
82
+ - [ ] Integration test passes
83
+
84
+ **Dependencies:** None
85
+ **Phase:** Foundation
86
+ **Priority:** 1
87
+ ```
88
+
89
+ ---
90
+
91
+ ## Step 3: Run Conversion (with Routing)
92
+
93
+ Execute the convert command:
94
+
95
+ ```bash
96
+ relentless convert relentless/features/<feature>/tasks.md --feature <feature-name>
97
+ ```
98
+
99
+ ### Options
100
+
101
+ | Flag | Description |
102
+ |------|-------------|
103
+ | `--mode <mode>` | Routing mode: free, cheap, good (default), genius |
104
+ | `--skip-routing` | Skip routing (NOT recommended) |
105
+ | `--auto-number` | Auto-number feature directory |
106
+ | `--with-checklist` | Merge checklist criteria |
107
+
108
+ ### Expected Output
109
+
110
+ ```
111
+ Converting tasks.md...
112
+
113
+ Classifying 6 stories for routing (mode: good)...
114
+ US-001: simple -> claude/haiku-4.5 ($0.0012)
115
+ US-002: medium -> claude/sonnet-4.5 ($0.0034)
116
+ US-003: complex -> claude/opus-4.5 ($0.0156)
117
+ US-004: simple -> claude/haiku-4.5 ($0.0010)
118
+ US-005: medium -> claude/sonnet-4.5 ($0.0028)
119
+ US-006: expert -> claude/opus-4.5 ($0.0234)
120
+
121
+ Total estimated cost: $0.0474
122
+
123
+ Created relentless/features/NNN-feature/
124
+ prd.json - 6 stories
125
+ Routing metadata included
126
+ prd.md - from tasks.md
127
+ progress.txt - progress log
128
+ ```
129
+
130
+ ---
131
+
132
+ ## Step 4: Validate Routing Output
133
+
134
+ After conversion, verify the prd.json has routing metadata:
135
+
136
+ ```bash
137
+ cat relentless/features/<feature>/prd.json | jq '.userStories[0].routing'
138
+ ```
139
+
140
+ ### Expected Routing Structure
141
+
142
+ ```json
143
+ {
144
+ "complexity": "simple",
145
+ "harness": "claude",
146
+ "model": "haiku-4.5",
147
+ "mode": "good",
148
+ "estimatedCost": 0.0012,
149
+ "classificationReasoning": "Task classified as simple (confidence: 85%)..."
150
+ }
151
+ ```
152
+
153
+ **CRITICAL:** If routing is missing, the conversion was run with `--skip-routing`. Re-run without that flag.
154
+
155
+ ---
156
+
157
+ ## Step 5: Report Summary
158
+
159
+ After successful conversion, provide this summary:
160
+
161
+ ```markdown
162
+ ## Conversion Complete
163
+
164
+ **Feature:** NNN-feature-name
165
+ **Stories:** 6 total
166
+
167
+ ### Routing Summary
168
+
169
+ | Story | Complexity | Harness/Model | Est. Cost |
170
+ |--------|------------|----------------------|-----------|
171
+ | US-001 | simple | claude/haiku-4.5 | $0.0012 |
172
+ | US-002 | medium | claude/sonnet-4.5 | $0.0034 |
173
+ | US-003 | complex | claude/opus-4.5 | $0.0156 |
174
+ | US-004 | simple | claude/haiku-4.5 | $0.0010 |
175
+ | US-005 | medium | claude/sonnet-4.5 | $0.0028 |
176
+ | US-006 | expert | claude/opus-4.5 | $0.0234 |
177
+
178
+ **Total Estimated Cost:** $0.0474
179
+
180
+ ### Files Created
181
+
182
+ - `relentless/features/<feature>/prd.json` - PRD with routing
183
+ - `relentless/features/<feature>/prd.md` - Copy of tasks.md
184
+
185
+ ### Next Steps
186
+
187
+ 1. Review routing decisions (adjust mode if needed)
188
+ 2. Run `/relentless.analyze` to check consistency
189
+ 3. Run `relentless run --feature <name> --mode good`
190
+ ```
191
+
192
+ ---
193
+
194
+ ## Complexity Classification
195
+
196
+ The classifier determines complexity based on:
197
+
198
+ | Complexity | Indicators | Example |
199
+ |------------|------------|---------|
200
+ | **simple** | Basic CRUD, single file, straightforward | "Add logging to function" |
201
+ | **medium** | Multiple files, some logic | "Create REST endpoint with validation" |
202
+ | **complex** | Architecture changes, multiple systems | "Implement OAuth2 authentication" |
203
+ | **expert** | Novel solutions, deep expertise | "Design event sourcing system" |
204
+
205
+ ---
206
+
207
+ ## Mode-Model Matrix
208
+
209
+ | Mode | Simple | Medium | Complex | Expert |
210
+ |------|--------|--------|---------|--------|
211
+ | free | glm-4.7 | glm-4.7 | grok-code-fast-1 | grok-code-fast-1 |
212
+ | cheap | haiku-4.5 | gemini-flash | gpt-5.2-low | gpt-5.2-low |
213
+ | good | sonnet-4.5 | sonnet-4.5 | opus-4.5 | opus-4.5 |
214
+ | genius | opus-4.5 | opus-4.5 | opus-4.5 | opus-4.5 |
215
+
216
+ ---
217
+
218
+ ## Troubleshooting
219
+
220
+ ### "Tasks.md not found"
221
+
222
+ Run `/relentless.tasks` first to generate tasks.md from spec.md and plan.md.
223
+
224
+ ### "No routing metadata"
225
+
226
+ The conversion was run with `--skip-routing`. Re-run:
227
+ ```bash
228
+ relentless convert relentless/features/<feature>/tasks.md --feature <feature-name>
229
+ ```
230
+
231
+ ### "Invalid dependency"
232
+
233
+ A story references a non-existent story ID. Check the `Dependencies:` line.
234
+
235
+ ### "Circular dependency detected"
236
+
237
+ Stories reference each other in a cycle. Example: US-001 depends on US-002, and US-002 depends on US-001.
238
+
239
+ ---
240
+
241
+ ## Notes
242
+
243
+ - Always run conversion WITH routing (default behavior)
244
+ - Routing metadata enables intelligent cost optimization
245
+ - Review complexity classifications before running
246
+ - Use `--mode free` for testing/experimentation
247
+ - Use `--mode good` (default) for production work
248
+ - Use `--mode genius` for critical/complex features
@@ -14,6 +14,22 @@ Guide systematic implementation of features using TDD and quality-first approach
14
14
 
15
15
  ---
16
16
 
17
+ ## SpecKit Workflow
18
+
19
+ This skill is **Step 6 of 6** in the Relentless workflow:
20
+
21
+ specify → plan → tasks → convert → analyze → **implement**
22
+
23
+ Prerequisites:
24
+ - `spec.md` - Feature specification
25
+ - `plan.md` - Technical implementation plan
26
+ - `tasks.md` - User stories with acceptance criteria
27
+ - `prd.json` - Converted PRD with routing metadata
28
+ - `checklist.md` - Quality validation checklist
29
+ - Analysis must PASS (run `/relentless.analyze` first)
30
+
31
+ ---
32
+
17
33
  ## The Job
18
34
 
19
35
  Implement user stories one at a time, following strict TDD and updating all tracking files.
@@ -25,8 +41,10 @@ Implement user stories one at a time, following strict TDD and updating all trac
25
41
  1. **Read the Constitution** - Review your project's constitution (if exists) for governance principles
26
42
  2. **Read prompt.md** - Review workflow guidelines (if exists)
27
43
  3. **Read progress.txt** - Check learnings from previous iterations
28
- 4. **Review artifacts** - Ensure spec.md, plan.md, tasks.md, checklist.md exist
29
- 5. **Identify Quality Commands** - Find your project's typecheck, lint, and test commands
44
+ 4. **Review artifacts** - Ensure spec.md, plan.md, tasks.md, prd.json, checklist.md exist
45
+ 5. **Verify Analysis Passed** - Run `/relentless.analyze` if not already done
46
+ 6. **Identify Quality Commands** - Find your project's typecheck, lint, and test commands
47
+ 7. **Check Branch** - Verify you're on the correct branch from PRD `branchName`
30
48
 
31
49
  ---
32
50
 
@@ -50,6 +68,11 @@ go build ./... && golangci-lint run && go test ./...
50
68
  cargo check && cargo clippy && cargo test
51
69
  ```
52
70
 
71
+ **Requirements:**
72
+ - Typecheck: 0 errors
73
+ - Lint: 0 errors AND 0 warnings
74
+ - Tests: All pass
75
+
53
76
  **If ANY check fails, DO NOT mark the story as complete. Fix the issues first.**
54
77
 
55
78
  ---
@@ -81,6 +104,22 @@ For EVERY story, follow strict Test-Driven Development:
81
104
 
82
105
  ---
83
106
 
107
+ ## Research Phase (if story has `research: true`)
108
+
109
+ If the current story has `research: true` in prd.json and no research file exists yet:
110
+
111
+ 1. **Explore the codebase** - Find relevant files, patterns, and dependencies
112
+ 2. **Document findings** in `relentless/features/<feature>/research/<story-id>.md`:
113
+ - Existing patterns that should be followed
114
+ - Files that will likely need modification
115
+ - Dependencies and integration points
116
+ - Potential gotchas or edge cases
117
+ - Recommended implementation approach
118
+ 3. **Do NOT implement** - only research and document
119
+ 4. Save your findings to the research file and end your turn
120
+
121
+ ---
122
+
84
123
  ## Per-Story Implementation Flow
85
124
 
86
125
  For each story (in dependency order):
@@ -89,11 +128,13 @@ For each story (in dependency order):
89
128
  - Read `prd.json` to find the next story where `passes: false`
90
129
  - Check dependencies are met (dependent stories have `passes: true`)
91
130
  - Read the story's acceptance criteria
131
+ - Check routing metadata (complexity, model assigned)
92
132
 
93
133
  ### 2. Find Relevant Checklist Items
94
134
  - Open `checklist.md`
95
135
  - Find items tagged with `[US-XXX]` for this story
96
136
  - Note any governance/compliance items
137
+ - **Ensure Quality Gates and TDD items are included**
97
138
 
98
139
  ### 3. Implement with TDD
99
140
  Follow the TDD workflow above for each acceptance criterion.
@@ -160,39 +201,22 @@ Append progress entry:
160
201
  - Patterns discovered
161
202
  - Gotchas encountered
162
203
 
204
+ **Constitution Compliance:**
205
+ - [list principles followed]
206
+
163
207
  ---
164
208
  ```
165
209
 
166
210
  ---
167
211
 
168
- ## Example Per-Story Workflow
212
+ ## Check for Queued Prompts
169
213
 
170
- ```markdown
171
- **Current:** US-001: Test Infrastructure Setup
172
-
173
- **Acceptance Criteria:**
174
- - [ ] Test command runs successfully
175
- - [ ] Test files are auto-discovered
176
- - [ ] Coverage report available
177
- - [ ] Type checking passes
178
- - [ ] Linting passes
179
-
180
- **Relevant Checklist Items:**
181
- - [ ] CHK-001 [US-001] Test command executes successfully
182
- - [ ] CHK-002 [US-001] Test files are auto-discovered
183
- - [ ] CHK-007 Tests written BEFORE implementation
184
-
185
- **Implementation Steps:**
186
- 1. Write a simple failing test first
187
- 2. Configure test runner for your project
188
- 3. Verify test discovery works
189
- 4. Run type checking - must pass
190
- 5. Run linting - must pass with 0 warnings
191
- 6. Update tasks.md - check off completed criteria
192
- 7. Update checklist.md - mark verified items
193
- 8. Commit: "feat: US-001 - Test Infrastructure Setup"
194
- 9. Update prd.json: set passes: true
195
- 10. Update progress.txt with learnings
214
+ Between iterations, check `.queue.txt` for user input:
215
+
216
+ ```bash
217
+ # If .queue.txt exists, read and process it
218
+ # Acknowledge in progress.txt
219
+ # Process in FIFO order
196
220
  ```
197
221
 
198
222
  ---
@@ -232,6 +256,32 @@ After completing each story, these files MUST be updated:
232
256
 
233
257
  ---
234
258
 
259
+ ## Stop Condition
260
+
261
+ After completing a user story, check if ALL stories have `passes: true`.
262
+
263
+ **If ALL stories are complete and passing, output:**
264
+ ```
265
+ <promise>COMPLETE</promise>
266
+ ```
267
+
268
+ **If there are still stories with `passes: false`, end your response normally** (another iteration will pick up the next story).
269
+
270
+ ---
271
+
272
+ ## Common Pitfalls to Avoid
273
+
274
+ 1. **Skipping TDD** - Never implement without tests first
275
+ 2. **Suppressing lints** - Fix issues properly, don't disable rules
276
+ 3. **Large commits** - Keep commits focused and atomic
277
+ 4. **Missing typecheck** - Always run typecheck before commit
278
+ 5. **Ignoring progress.txt** - Read learnings from previous iterations
279
+ 6. **Not checking queue** - Always check `.queue.txt` for user input
280
+ 7. **Skipping analysis** - Run `/relentless.analyze` before implementing
281
+ 8. **Ignoring routing metadata** - Check story complexity and model assignment
282
+
283
+ ---
284
+
235
285
  ## Notes
236
286
 
237
287
  - Work on ONE story at a time
@@ -240,8 +290,6 @@ After completing each story, these files MUST be updated:
240
290
  - Never skip quality checks
241
291
  - Commit after each story
242
292
  - Update ALL tracking files
243
- - This is a guided workflow for manual implementation
244
-
245
- ---
246
-
247
- *Adapt all commands and paths to your project's specific setup*
293
+ - Check `.queue.txt` for mid-run input
294
+ - This is a guided workflow for systematic implementation
295
+ - **Adapt all commands and paths to your project's specific setup**
@@ -9,12 +9,46 @@ Create detailed technical plans that translate feature specifications into imple
9
9
 
10
10
  ---
11
11
 
12
+ ## SpecKit Workflow
13
+
14
+ This skill is **Step 2 of 6** in the Relentless workflow:
15
+
16
+ specify → **plan** → tasks → convert → analyze → implement
17
+
18
+ What flows from spec:
19
+ - User requirements → technical approach
20
+ - Routing preference → carried forward
21
+ - Acceptance criteria → test specifications
22
+
23
+ What flows to tasks:
24
+ - Technical approach → implementation breakdown
25
+ - Test specifications → TDD acceptance criteria
26
+
27
+ ---
28
+
29
+ ## TDD is MANDATORY
30
+
31
+ The technical plan MUST include concrete test specifications:
32
+ - **Test file locations** (where tests will live)
33
+ - **Test class/function names** (what to create)
34
+ - **Mock/fixture requirements** (what test data needed)
35
+ - **Coverage targets** per component
36
+
37
+ **The agent MUST write tests BEFORE implementation code.**
38
+
39
+ This is non-negotiable. Plans without test specifications are incomplete.
40
+
41
+ ---
42
+
12
43
  ## The Job
13
44
 
14
45
  1. Read the feature specification (`spec.md`)
15
- 2. Read project constitution for technical constraints
16
- 3. Generate technical architecture and implementation plan
17
- 4. Save to `plan.md` in the feature directory
46
+ 2. **Extract and validate routing preference (Step 2)**
47
+ 3. Read project constitution for technical constraints
48
+ 4. Generate technical architecture and implementation plan
49
+ 5. **Include complete test specifications**
50
+ 6. **Validate against quality gates**
51
+ 7. Save to `plan.md` in the feature directory
18
52
 
19
53
  ---
20
54
 
@@ -27,16 +61,34 @@ Find the current feature directory:
27
61
 
28
62
  ---
29
63
 
30
- ## Step 2: Load Context
64
+ ## Step 2: Extract Routing Preference
65
+
66
+ 1. Read `spec.md` and extract routing preference
67
+ 2. If missing, DEFAULT to: `auto: good | allow free: yes`
68
+ 3. Validate format is correct
69
+ 4. Carry forward to plan.md metadata
70
+ 5. Update progress.txt with routing decision
71
+
72
+ Example:
73
+ ```
74
+ Spec says: **Routing Preference**: auto: genius | allow free: no
75
+ Plan carries: **Routing Preference**: auto: genius | allow free: no
76
+ ```
77
+
78
+ ---
79
+
80
+ ## Step 3: Load Context
31
81
 
32
82
  Read these files:
33
83
  1. **relentless/constitution.md** - Project governance and technical standards
34
84
  2. **relentless/features/NNN-feature/spec.md** - Feature requirements
35
85
  3. Project README or docs for tech stack information
36
86
 
87
+ Note all MUST and SHOULD rules from constitution - these are quality gates.
88
+
37
89
  ---
38
90
 
39
- ## Step 3: Generate Technical Plan
91
+ ## Step 4: Generate Technical Plan
40
92
 
41
93
  Using the template at `templates/plan.md`, create a plan with:
42
94
 
@@ -46,6 +98,7 @@ Using the template at `templates/plan.md`, create a plan with:
46
98
  - Architecture approach
47
99
  - Key technologies to use (from constitution/existing stack)
48
100
  - Integration points
101
+ - Routing preference carried from spec (auto mode or harness/model)
49
102
 
50
103
  **2. Data Models**
51
104
  - Database schemas
@@ -64,11 +117,12 @@ Using the template at `templates/plan.md`, create a plan with:
64
117
  - Dependencies between components
65
118
  - Integration approach
66
119
 
67
- **5. Testing Strategy**
68
- - Unit test approach
69
- - Integration test scenarios
70
- - E2E test cases
71
- - Test data requirements
120
+ **5. Test Specifications (MANDATORY)**
121
+ - Test file structure
122
+ - Unit test table (component → test file → functions)
123
+ - Integration test table (flow → test file → scenarios)
124
+ - Mock requirements
125
+ - Coverage targets (minimum 80%)
72
126
 
73
127
  **6. Security Considerations**
74
128
  - Authentication/authorization
@@ -84,24 +138,37 @@ Using the template at `templates/plan.md`, create a plan with:
84
138
 
85
139
  ---
86
140
 
87
- ## Step 4: Ensure Constitution Compliance
141
+ ## Step 5: Ensure Constitution Compliance
88
142
 
89
143
  Validate the plan against constitution:
90
- - **MUST** rules: Required, plan must follow these
91
- - **SHOULD** rules: Best practices, document any deviations
144
+
145
+ ### Quality Gates Check
146
+
147
+ Before completing the plan, validate:
148
+ - [ ] **TDD approach defined** - test specs with file locations
149
+ - [ ] **Quality commands identified** - typecheck, lint, test
150
+ - [ ] **Routing preference carried** from spec
151
+ - [ ] **All MUST rules** from constitution addressed
152
+ - [ ] **No `any` types** planned in TypeScript
153
+ - [ ] **Error handling strategy** defined
154
+
155
+ **MUST** rules: Required, plan must follow these
156
+ **SHOULD** rules: Best practices, document any deviations
92
157
 
93
158
  If plan violates MUST rules, revise until compliant.
94
159
 
95
160
  ---
96
161
 
97
- ## Step 5: Save & Report
162
+ ## Step 6: Save & Report
98
163
 
99
164
  1. Save plan to `relentless/features/NNN-feature/plan.md`
100
- 2. Update progress.txt with plan creation timestamp
165
+ 2. Update progress.txt with plan creation timestamp and routing info
101
166
  3. Report:
102
167
  - Plan location
103
168
  - Key technical decisions
169
+ - Test specifications summary
104
170
  - Constitution compliance: PASS/FAIL
171
+ - Routing preference: [carried value]
105
172
  - Next step: `/relentless.tasks`
106
173
 
107
174
  ---
@@ -111,6 +178,8 @@ If plan violates MUST rules, revise until compliant.
111
178
  ```markdown
112
179
  # Technical Implementation Plan: User Authentication
113
180
 
181
+ **Routing Preference**: auto: good | allow free: yes
182
+
114
183
  ## Technical Overview
115
184
 
116
185
  **Architecture:** Three-tier (API, Service, Data)
@@ -153,20 +222,58 @@ CREATE INDEX idx_users_email ON users(email);
153
222
  }
154
223
  \`\`\`
155
224
 
156
- ## Testing Strategy
225
+ ## Test Specifications (MANDATORY)
157
226
 
158
- **Unit Tests:**
159
- - Password hashing utility
160
- - Email validation
161
- - Token generation/verification
162
-
163
- **Integration Tests:**
164
- - Full registration flow
165
- - Email sending
166
- - Database operations
227
+ ### Test File Structure
228
+ \`\`\`
229
+ tests/
230
+ ├── unit/
231
+ │ ├── auth/
232
+ │ │ ├── password.test.ts
233
+ │ │ └── email-validation.test.ts
234
+ │ └── token/
235
+ │ └── jwt.test.ts
236
+ ├── integration/
237
+ │ └── auth/
238
+ │ ├── register.test.ts
239
+ │ └── login.test.ts
240
+ └── e2e/
241
+ └── auth-flow.test.ts
242
+ \`\`\`
167
243
 
168
- **E2E Tests:**
169
- - Complete user journey from signup to login
244
+ ### Unit Tests
245
+ | Component | Test File | Functions to Test |
246
+ |-----------|-----------|-------------------|
247
+ | Password | `tests/unit/auth/password.test.ts` | hashPassword, verifyPassword |
248
+ | Email | `tests/unit/auth/email-validation.test.ts` | validateEmail |
249
+ | JWT | `tests/unit/token/jwt.test.ts` | generateToken, verifyToken |
250
+
251
+ ### Integration Tests
252
+ | Flow | Test File | Scenarios |
253
+ |------|-----------|-----------|
254
+ | Register | `tests/integration/auth/register.test.ts` | success, duplicate email, invalid input |
255
+ | Login | `tests/integration/auth/login.test.ts` | success, wrong password, unconfirmed |
256
+
257
+ ### Mock Requirements
258
+ - Database mock (in-memory or test container)
259
+ - Email service mock (no actual sends)
260
+ - Time mock for token expiration tests
261
+
262
+ ### Coverage Targets
263
+ - Unit: 90% minimum (critical auth code)
264
+ - Integration: All happy paths + error paths
265
+ - E2E: Complete registration and login flow
266
+
267
+ ## Constitution Compliance
268
+
269
+ **MUST Rules Checked:**
270
+ - [x] TDD is mandatory - test specs defined above
271
+ - [x] Quality gates defined - typecheck, lint, test commands
272
+ - [x] Routing preference carried from spec
273
+ - [x] No `any` types planned
274
+ - [x] Error handling strategy defined
275
+
276
+ **If any MUST rule cannot be satisfied, document the exception and remediation plan.**
170
277
  ```
171
278
 
172
279
  ---
@@ -177,3 +284,5 @@ CREATE INDEX idx_users_email ON users(email);
177
284
  - Include specific technologies and patterns
178
285
  - Must comply with constitution
179
286
  - Detailed enough for task generation
287
+ - **Test specifications are mandatory** - no tests = incomplete plan
288
+ - **Routing preference must be carried forward** from spec