sequant 2.1.1 → 2.2.0

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 (45) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/dist/bin/cli.js +1 -0
  4. package/dist/src/commands/init.d.ts +1 -0
  5. package/dist/src/commands/init.js +122 -3
  6. package/dist/src/commands/run-compat.d.ts +14 -0
  7. package/dist/src/commands/run-compat.js +12 -0
  8. package/dist/src/commands/run-display.d.ts +17 -0
  9. package/dist/src/commands/run-display.js +116 -0
  10. package/dist/src/commands/run.d.ts +4 -26
  11. package/dist/src/commands/run.js +47 -772
  12. package/dist/src/commands/status.js +24 -1
  13. package/dist/src/index.d.ts +11 -0
  14. package/dist/src/index.js +9 -0
  15. package/dist/src/lib/errors.d.ts +93 -0
  16. package/dist/src/lib/errors.js +97 -0
  17. package/dist/src/lib/settings.d.ts +236 -0
  18. package/dist/src/lib/settings.js +482 -37
  19. package/dist/src/lib/skill-version.d.ts +19 -0
  20. package/dist/src/lib/skill-version.js +68 -0
  21. package/dist/src/lib/templates.d.ts +1 -0
  22. package/dist/src/lib/templates.js +1 -1
  23. package/dist/src/lib/workflow/batch-executor.js +13 -5
  24. package/dist/src/lib/workflow/config-resolver.d.ts +50 -0
  25. package/dist/src/lib/workflow/config-resolver.js +167 -0
  26. package/dist/src/lib/workflow/error-classifier.d.ts +17 -7
  27. package/dist/src/lib/workflow/error-classifier.js +113 -15
  28. package/dist/src/lib/workflow/phase-executor.d.ts +31 -0
  29. package/dist/src/lib/workflow/phase-executor.js +143 -48
  30. package/dist/src/lib/workflow/run-log-schema.d.ts +12 -0
  31. package/dist/src/lib/workflow/run-log-schema.js +7 -1
  32. package/dist/src/lib/workflow/run-orchestrator.d.ts +161 -0
  33. package/dist/src/lib/workflow/run-orchestrator.js +510 -0
  34. package/dist/src/lib/workflow/worktree-manager.d.ts +4 -3
  35. package/dist/src/lib/workflow/worktree-manager.js +61 -11
  36. package/package.json +1 -1
  37. package/templates/skills/assess/SKILL.md +239 -77
  38. package/templates/skills/exec/SKILL.md +7 -68
  39. package/templates/skills/fullsolve/SKILL.md +303 -137
  40. package/templates/skills/qa/SKILL.md +42 -46
  41. package/templates/skills/qa/scripts/quality-checks.sh +47 -1
  42. package/templates/skills/spec/SKILL.md +183 -982
  43. package/templates/skills/spec/references/quality-checklist.md +75 -0
  44. package/templates/skills/test/SKILL.md +0 -27
  45. package/templates/skills/testgen/SKILL.md +0 -27
@@ -4,7 +4,7 @@ description: "Plan review vs Acceptance Criteria for a single GitHub issue, plus
4
4
  license: MIT
5
5
  metadata:
6
6
  author: sequant
7
- version: "1.0"
7
+ version: "2.1"
8
8
  allowed-tools:
9
9
  - Bash(npm test:*)
10
10
  - Bash(gh issue view:*)
@@ -19,987 +19,160 @@ allowed-tools:
19
19
 
20
20
  # Planning Agent
21
21
 
22
- You are the Phase 1 "Planning Agent" for the current repository.
22
+ Phase 1 "Planning Agent." Understands the issue and AC, reviews or synthesizes a plan, identifies gaps and risks, and drafts a GitHub issue comment.
23
23
 
24
- ## Purpose
24
+ ## Platform Detection — Run First
25
25
 
26
- When invoked as `/spec`, your job is to:
26
+ ```bash
27
+ gh --version >/dev/null 2>&1 && GITHUB_AVAILABLE=true || GITHUB_AVAILABLE=false
28
+ SETTINGS_AVAILABLE=false; [ -f ".sequant/settings.json" ] && SETTINGS_AVAILABLE=true
29
+ ```
27
30
 
28
- 1. Understand the issue and Acceptance Criteria (AC).
29
- 2. Review or synthesize a clear plan to address the AC.
30
- 3. Identify ambiguities, gaps, or risks.
31
- 4. Draft a GitHub issue comment summarizing AC + the agreed plan.
31
+ - **GitHub unavailable:** Skip phase detection, label review, auto-comment. Prompt user for AC from description text.
32
+ - **Settings unavailable:** Use defaults silently (sequential agents, no custom scope config).
32
33
 
33
- ## Phase Detection (Smart Resumption)
34
+ ## Phase Detection
34
35
 
35
- **Before executing**, check if this phase has already been completed by reading phase markers from issue comments:
36
+ If GitHub is available, check for prior phase completion:
36
37
 
37
38
  ```bash
38
- # Check for existing phase markers
39
39
  phase_data=$(gh issue view <issue-number> --json comments --jq '[.comments[].body]' | \
40
40
  grep -o '{[^}]*}' | grep '"phase"' | tail -1 || true)
41
-
42
- if [[ -n "$phase_data" ]]; then
43
- phase=$(echo "$phase_data" | jq -r '.phase')
44
- status=$(echo "$phase_data" | jq -r '.status')
45
-
46
- # Skip if spec is already completed or a later phase is completed
47
- if [[ "$phase" == "spec" && "$status" == "completed" ]] || \
48
- [[ "$phase" == "exec" || "$phase" == "test" || "$phase" == "qa" ]]; then
49
- echo "⏭️ Spec phase already completed (detected: $phase:$status). Skipping."
50
- # Exit early — no work needed
51
- fi
52
- fi
53
41
  ```
54
42
 
55
- **Behavior:**
56
- - If `spec:completed` or a later phase is detected Skip with message
57
- - If `spec:failed`Re-run spec (retry)
58
- - If no markers found → Normal execution (fresh start)
59
- - If detection fails (API error) → Fall through to normal execution
60
-
61
- **Phase Marker Emission:**
62
-
63
- When posting the spec plan comment to GitHub, append a phase marker at the end:
43
+ - `spec:completed` or later phase detected → Skip with message
44
+ - `spec:failed` → Re-run
45
+ - No markers / API error Normal execution
64
46
 
65
- ```markdown
47
+ Append to every phase-completion comment:
48
+ ```
66
49
  <!-- SEQUANT_PHASE: {"phase":"spec","status":"completed","timestamp":"<ISO-8601>"} -->
67
50
  ```
68
51
 
69
- Include this marker in every `gh issue comment` that represents phase completion.
70
-
71
52
  ## Behavior
72
53
 
73
- When called like `/spec 123`:
74
- 1. Treat `123` as a GitHub issue number.
75
- 2. **Read all GitHub issue comments** for complete context.
76
- 3. Extract: problem statement, AC (explicit or inferred), clarifications from comments.
77
-
78
- When called like `/spec <freeform description>`:
79
- 1. Treat the text as the problem/AC source.
80
- 2. Ask clarifying questions if AC are ambiguous or conflicting.
54
+ **`/spec 123`** GitHub issue number. Read all comments for full context. Extract AC.
55
+ **`/spec <text>`** Freeform problem/AC source. Ask clarifying questions if ambiguous.
81
56
 
82
- **Flag:** `--skip-ac-lint`
83
- - Usage: `/spec 123 --skip-ac-lint`
84
- - Effect: Skips the AC Quality Check step
85
- - Use when: AC are intentionally high-level or you want to defer linting
57
+ **Flags:** `--skip-ac-lint` (skip AC quality check), `--skip-scope-check` (skip scope assessment).
86
58
 
87
- **Flag:** `--skip-scope-check`
88
- - Usage: `/spec 123 --skip-scope-check`
89
- - Effect: Skips the Scope Assessment step
90
- - Use when: Issue scope is intentionally complex or you want to defer assessment
59
+ ## Complexity Tier Determination
91
60
 
92
- ### AC Extraction and Storage REQUIRED
61
+ Determine the output tier **before** generating any output. Announce it as the first line.
93
62
 
94
- **After fetching the issue body**, extract and store acceptance criteria in workflow state:
63
+ | Tier | Criteria | Output Scope | Target |
64
+ |------|----------|--------------|--------|
65
+ | **Simple** | `simple-fix`/`typo`/`docs-only` label, or `bug` with ≤2 AC | AC list + plan + Design Review Q1/Q3 only | <4,000 chars |
66
+ | **Standard** | 3–8 AC, no complexity labels | Full output minus Polish, minus trivially-passing quality checks | <8,000 chars |
67
+ | **Complex** | `complex`/`refactor`/`breaking` label, or 9+ AC | Full output including all quality dimensions | <15,000 chars |
95
68
 
96
- ```bash
97
- # Extract AC from issue body and store in state
98
- npx tsx -e "
99
- import { extractAcceptanceCriteria } from './src/lib/ac-parser.ts';
100
- import { StateManager } from './src/lib/workflow/state-manager.ts';
101
-
102
- const issueBody = \`<ISSUE_BODY_HERE>\`;
103
- const issueNumber = <ISSUE_NUMBER>;
104
- const issueTitle = '<ISSUE_TITLE>';
105
-
106
- const ac = extractAcceptanceCriteria(issueBody);
107
- console.log('Extracted AC:', JSON.stringify(ac, null, 2));
108
-
109
- if (ac.items.length > 0) {
110
- const manager = new StateManager();
111
- (async () => {
112
- const existing = await manager.getIssueState(issueNumber);
113
- if (!existing) {
114
- await manager.initializeIssue(issueNumber, issueTitle);
115
- }
116
- await manager.updateAcceptanceCriteria(issueNumber, ac);
117
- console.log('AC stored in state for issue #' + issueNumber);
118
- })();
119
- }
120
- "
121
- ```
69
+ First line of output: `**Complexity: [Tier]** ([N] ACs, [N] directories)`
122
70
 
123
- **Why this matters:** Storing AC in state enables:
124
- - Dashboard visibility of AC progress per issue
125
- - `/qa` skill to update AC status during review
126
- - Cross-skill AC tracking throughout the workflow
71
+ Mark tier in HTML comment for downstream parsing: `<!-- SEQUANT_SPEC_TIER: [tier] -->`
127
72
 
128
- **AC Format Detection:**
129
- The parser supports multiple formats:
130
- - `- [ ] **AC-1:** Description` (bold with hyphen)
131
- - `- [ ] **B2:** Description` (letter + number)
132
- - `- [ ] AC-1: Description` (no bold)
73
+ ## Programmatic Checks (Conditional)
133
74
 
134
- **If no AC found:**
135
- - Log a warning but continue with planning
136
- - The plan output should note that AC will need to be defined
75
+ **Guard:** Only run `npx tsx` blocks if `./src/lib/ac-parser.ts` exists (sequant repo). Otherwise, perform all analysis inline by reading the issue text directly.
137
76
 
138
- ### AC Quality Check — REQUIRED (unless --skip-ac-lint)
77
+ ### If guard passes:
139
78
 
140
- **After extracting AC**, run the AC linter to flag vague, untestable, or incomplete requirements:
79
+ 1. **AC Extraction & Storage:** Use `extractAcceptanceCriteria` from `./src/lib/ac-parser.ts` and `StateManager` from `./src/lib/workflow/state-manager.ts` to parse and store AC in `.sequant/state.json`. Supports formats: `- [ ] **AC-1:** Desc`, `- [ ] AC-1: Desc`, `- [ ] **B2:** Desc`.
141
80
 
142
- ```bash
143
- # Lint AC for quality issues (skip if --skip-ac-lint flag is set)
144
- npx tsx -e "
145
- import { parseAcceptanceCriteria } from './src/lib/ac-parser.ts';
146
- import { lintAcceptanceCriteria, formatACLintResults } from './src/lib/ac-linter.ts';
81
+ 2. **AC Quality Check** (unless `--skip-ac-lint`): Use `lintAcceptanceCriteria` from `./src/lib/ac-linter.ts`. Warning-only — does not block planning. Flag these patterns:
147
82
 
148
- const issueBody = \`<ISSUE_BODY_HERE>\`;
149
-
150
- const criteria = parseAcceptanceCriteria(issueBody);
151
- const lintResults = lintAcceptanceCriteria(criteria);
152
- console.log(formatACLintResults(lintResults));
153
- "
154
- ```
83
+ | Pattern | Examples | Issue |
84
+ |---------|----------|-------|
85
+ | Vague | "should work", "properly" | No measurable outcome |
86
+ | Unmeasurable | "fast", "performant" | No threshold defined |
87
+ | Incomplete | "handle errors", "edge cases" | Scenarios not enumerated |
88
+ | Open-ended | "etc.", "and more" | Scope undefined |
155
89
 
156
- **Why this matters:** Vague AC lead to:
157
- - Ambiguous implementations that don't match expectations
158
- - Subjective /qa verdicts ("does it work properly?")
159
- - Wasted iteration cycles when requirements are clarified late
90
+ 3. **Scope Assessment** (unless `--skip-scope-check`): Use `performScopeAssessment` from `./src/lib/scope/index.ts` with settings from `getSettings()`. Verdicts: SCOPE_OK (green), SCOPE_WARNING (yellow, auto-enables quality loop), SCOPE_SPLIT_RECOMMENDED (red). Store results in state.
160
91
 
161
- **Pattern Detection:**
92
+ ### If guard fails (consumer projects):
162
93
 
163
- | Pattern Type | Examples | Issue |
164
- |--------------|----------|-------|
165
- | Vague | "should work", "properly", "correctly" | Subjective, no measurable outcome |
166
- | Unmeasurable | "fast", "performant", "responsive" | No threshold defined |
167
- | Incomplete | "handle errors", "edge cases" | Specific scenarios not enumerated |
168
- | Open-ended | "etc.", "and more", "such as" | Scope is undefined |
169
-
170
- **Example Output:**
171
-
172
- ```markdown
173
- ## AC Quality Check
94
+ Perform the same analysis inline:
95
+ - Extract AC by pattern-matching the issue body
96
+ - Flag vague/unmeasurable AC in the AC Quality Check section
97
+ - Assess scope using the same green/yellow/red heuristics on feature count, AC count, directory spread
174
98
 
175
- ⚠️ **AC-2:** "System should handle errors gracefully"
176
- → Incomplete: error types not specified
177
- → Suggest: List specific error types and expected responses (e.g., 400 for invalid input, 503 for service unavailable)
99
+ ## Context Gathering
178
100
 
179
- ⚠️ **AC-4:** "Page loads quickly"
180
- → Unmeasurable: "quickly" has no threshold
181
- → Suggest: Specify time limit (e.g., completes in <5 seconds)
101
+ ### Discover Project Structure — REQUIRED
182
102
 
183
- AC-1, AC-3, AC-5: Clear and testable
184
-
185
- **Summary:** 2/5 AC items flagged for review
186
- ```
187
-
188
- **Behavior:**
189
- - **Warning-only**: AC Quality Check does NOT block planning
190
- - Issues are surfaced in the output but plan generation continues
191
- - Include flagged AC in the issue comment draft with suggestions
192
- - Recommend refining vague AC before implementation
193
-
194
- **If `--skip-ac-lint` flag is set:**
195
- - Output: `AC Quality Check: Skipped (--skip-ac-lint flag set)`
196
- - Continue directly to plan generation
197
-
198
- ### Scope Assessment — REQUIRED (unless --skip-scope-check)
199
-
200
- **After AC Quality Check**, run scope assessment to detect overscoped issues:
103
+ **Do NOT use hardcoded paths.** Discover what actually exists:
201
104
 
202
105
  ```bash
203
- # Run scope assessment (skip if --skip-scope-check flag is set)
204
- npx tsx -e "
205
- import { parseAcceptanceCriteria } from './src/lib/ac-parser.ts';
206
- import { performScopeAssessment, formatScopeAssessment, convertSettingsToConfig } from './src/lib/scope/index.ts';
207
- import { getSettings } from './src/lib/settings.ts';
208
-
209
- const issueBody = \`<ISSUE_BODY_HERE>\`;
210
- const issueTitle = '<ISSUE_TITLE>';
211
-
212
- (async () => {
213
- const settings = await getSettings();
214
- const config = convertSettingsToConfig(settings.scopeAssessment);
215
-
216
- const criteria = parseAcceptanceCriteria(issueBody);
217
- const assessment = performScopeAssessment(criteria, issueBody, issueTitle, config);
218
- console.log(formatScopeAssessment(assessment));
219
- })();
220
- "
106
+ ls -d src/ app/ lib/ components/ pages/ routes/ docs/ 2>/dev/null || true
221
107
  ```
222
108
 
223
- **Why this matters:**
224
- - Bundled features (3+ distinct features) should be separate issues
225
- - Missing non-goals lead to scope creep during implementation
226
- - High AC counts increase complexity and error rates
227
-
228
- **Scope Metrics:**
109
+ Use discovered paths in all agent prompts and search commands.
229
110
 
230
- | Metric | Green | Yellow | Red |
231
- |--------|-------|--------|-----|
232
- | Feature count | 1 | 2 | 3+ |
233
- | AC items | 1-5 | 6-8 | 9+ |
234
- | Directory spread | 1-2 | 3-4 | 5+ |
111
+ ### Agent Spawn Rules
235
112
 
236
- **Non-Goals Section:**
113
+ Determine agent count from issue content — do NOT always spawn 3:
237
114
 
238
- Every `/spec` output MUST include a Non-Goals section. If the issue lacks one, output a warning:
115
+ | Issue Content | Agents | What to Spawn |
116
+ |---------------|--------|---------------|
117
+ | Database/SQL/migration keywords in AC or labels | 3 | Similar features + Codebase area + Database schema |
118
+ | UI/frontend (`.tsx`/`.jsx`/`components/` references) | 2 | Similar features + Codebase area |
119
+ | CLI/script changes | 2 | Similar features + Codebase area |
120
+ | Docs/config/`simple-fix` label | 1 | General context only |
239
121
 
240
- ```markdown
241
- ## Non-Goals
122
+ **Execution mode:** Read `.sequant/settings.json` → `agents.parallel` (default: false).
123
+ - **Parallel:** Spawn all agents in a SINGLE message
124
+ - **Sequential:** Spawn one at a time, waiting for each to complete
242
125
 
243
- ⚠️ **Non-Goals section not found.** Consider adding scope boundaries.
126
+ Agent prompts MUST reference discovered paths from the step above, not hardcoded ones like `components/admin/` or `lib/queries/`.
244
127
 
245
- Example format:
246
- - [ ] [Adjacent feature we're deferring]
247
- - [ ] [Scope boundary we're respecting]
248
- - [ ] [Future work that's out of scope]
249
- ```
128
+ ### In-Flight Work Analysis
250
129
 
251
- **Scope Verdicts:**
252
-
253
- | Verdict | Meaning | Action |
254
- |---------|---------|--------|
255
- | ✅ SCOPE_OK | Single focused feature | Proceed normally |
256
- | ⚠️ SCOPE_WARNING | Moderate complexity | Consider narrowing; quality loop auto-enabled |
257
- | ❌ SCOPE_SPLIT_RECOMMENDED | Multiple features bundled | Strongly recommend splitting |
258
-
259
- **Quality Loop Auto-Enable:**
260
-
261
- If scope verdict is SCOPE_WARNING or SCOPE_SPLIT_RECOMMENDED:
262
- - Quality loop is automatically enabled
263
- - Include note in Recommended Workflow section:
264
- ```markdown
265
- **Quality Loop:** enabled (auto-enabled due to scope concerns)
266
- ```
267
-
268
- **If `--skip-scope-check` flag is set:**
269
- - Output: `Scope Assessment: Skipped (--skip-scope-check flag set)`
270
- - Continue to plan generation
271
-
272
- **Store in State:**
273
-
274
- After assessment, store results in workflow state for analytics:
130
+ Scan for potential conflicts before planning:
275
131
 
276
132
  ```bash
277
- npx tsx -e "
278
- import { StateManager } from './src/lib/workflow/state-manager.ts';
279
- import { performScopeAssessment, convertSettingsToConfig } from './src/lib/scope/index.ts';
280
- import { getSettings } from './src/lib/settings.ts';
281
-
282
- (async () => {
283
- const settings = await getSettings();
284
- const config = convertSettingsToConfig(settings.scopeAssessment);
285
-
286
- // ... perform assessment with config ...
287
- // const assessment = performScopeAssessment(criteria, issueBody, issueTitle, config);
288
-
289
- const manager = new StateManager();
290
- await manager.updateScopeAssessment(issueNumber, assessment);
291
- })();
292
- "
293
- ```
294
-
295
- ### Feature Worktree Workflow
296
-
297
- **Planning Phase:** No worktree needed. Planning happens in the main repository directory. The worktree will be created during the execution phase (`/exec`).
298
-
299
- ### Parallel Context Gathering — REQUIRED
300
-
301
- **You MUST spawn sub-agents for context gathering.** Do NOT explore the codebase inline with Glob/Grep commands. Sub-agents provide parallel execution, better context isolation, and consistent reporting.
302
-
303
- **Check agent execution mode first:**
304
- Use the Read tool to check project settings:
305
- ```
306
- Read(file_path=".sequant/settings.json")
307
- # Parse JSON and extract agents.parallel (default: false)
308
- ```
309
-
310
- #### If parallel mode enabled:
311
-
312
- **Spawn ALL THREE agents in a SINGLE message:**
313
-
314
- 1. `Agent(subagent_type="sequant-explorer", prompt="Find similar features for [FEATURE]. Check components/admin/, lib/queries/, docs/patterns/. Report: file paths, patterns, recommendations.")`
315
-
316
- 2. `Agent(subagent_type="sequant-explorer", prompt="Explore [CODEBASE AREA] for [FEATURE]. Find: main components, data flow, key files. Report structure.")`
317
-
318
- 3. `Agent(subagent_type="sequant-explorer", prompt="Inspect database for [FEATURE]. Check: table schema, RLS policies, existing queries. Report findings.")`
319
-
320
- #### If sequential mode (default):
321
-
322
- **Spawn each agent ONE AT A TIME, waiting for each to complete:**
323
-
324
- 1. **First:** `Agent(subagent_type="sequant-explorer", prompt="Find similar features for [FEATURE]. Check components/admin/, lib/queries/, docs/patterns/. Report: file paths, patterns, recommendations.")`
325
-
326
- 2. **After #1 completes:** `Agent(subagent_type="sequant-explorer", prompt="Explore [CODEBASE AREA] for [FEATURE]. Find: main components, data flow, key files. Report structure.")`
327
-
328
- 3. **After #2 completes:** `Agent(subagent_type="sequant-explorer", prompt="Inspect database for [FEATURE]. Check: table schema, RLS policies, existing queries. Report findings.")`
329
-
330
- ### Feature Branch Context Detection
331
-
332
- Before creating the implementation plan, check if a custom base branch should be recommended:
333
-
334
- 1. **Check for feature branch references in issue body**:
335
- ```bash
336
- gh issue view <issue> --json body --jq '.body' | grep -iE "(feature/|branch from|based on|part of.*feature)" || true
337
- ```
338
-
339
- 2. **Check issue labels for feature context**:
340
- ```bash
341
- gh issue view <issue> --json labels --jq '.labels[].name' | grep -iE "(dashboard|feature-|epic-)" || true
342
- ```
343
-
344
- 3. **Check if project has defaultBase configured**:
345
- Use the Read tool to check settings:
346
- ```
347
- Read(file_path=".sequant/settings.json")
348
- # Extract .run.defaultBase from JSON
349
- ```
350
-
351
- 4. **If feature branch context detected**, include in plan output:
352
- ```markdown
353
- ## Feature Branch Context
354
-
355
- **Detected base branch**: `feature/dashboard`
356
- **Source**: Issue body mentions "Part of dashboard feature" / Project config / Label
357
-
358
- **Recommended workflow**:
359
- \`\`\`bash
360
- npx sequant run <issue> --base feature/dashboard
361
- \`\`\`
362
- ```
363
-
364
- ### In-Flight Work Analysis (Conflict Detection)
365
-
366
- Before creating the implementation plan, scan for potential conflicts with in-flight work:
367
-
368
- 1. **List open worktrees**:
369
- ```bash
370
- git worktree list --porcelain
371
- ```
372
-
373
- 2. **For each worktree, get changed files** (use detected base branch or default to main):
374
- ```bash
375
- git -C <worktree-path> diff --name-only <base-branch>...HEAD
376
- ```
377
-
378
- 3. **Analyze this issue's likely file touches** based on:
379
- - Issue description and AC
380
- - Similar past issues
381
- - Codebase structure
382
-
383
- 4. **If overlap detected**, include in plan output:
384
- ```markdown
385
- ## Conflict Risk Analysis
386
-
387
- **In-flight work detected**: Issue #<N> (feature/<branch-name>)
388
- **Overlapping files**:
389
- - `<file-path>`
390
-
391
- **Recommended approach**:
392
- - [ ] Option A: Use alternative file/approach (no conflict)
393
- - [ ] Option B: Wait for #<N> to merge, then rebase
394
- - [ ] Option C: Coordinate unified implementation via /merger
395
-
396
- **Selected**: [To be decided during spec review]
397
- ```
398
-
399
- 5. **Check for explicit dependencies**:
400
- ```bash
401
- # Look for "Depends on" or "depends-on" labels
402
- gh issue view <issue> --json body,labels
403
- ```
404
-
405
- If dependencies found:
406
- ```markdown
407
- ## Dependencies
408
-
409
- **Depends on**: #<N>
410
- **Reason**: [Why this issue depends on the other]
411
- **Status**: [Open/Merged/Closed]
412
- ```
413
-
414
- ### Using MCP Tools (Optional)
415
-
416
- - **Sequential Thinking:** For complex analysis with multiple dependencies
417
- - **Context7:** For understanding existing patterns and architecture
418
-
419
- ## Context Gathering Strategy
420
-
421
- 1. **Check the Patterns Catalog first**
422
- - Read `docs/patterns/README.md` for quick lookup
423
- - Check HELPERS.md, COMPONENTS.md, TYPES.md
424
- - **Do NOT propose creating new utilities if similar ones exist**
425
-
426
- 2. **Look for similar features**
427
- - Use `ls components/admin/[area]/` for existing components
428
- - Read 1-2 examples to understand patterns
429
- - Propose solutions matching established architecture
430
-
431
- 3. **Check existing dependencies**
432
- - Review `package.json` for libraries
433
- - Prefer existing dependencies over new ones
434
- - For "solved problem" domains, recommend established packages in the plan:
435
- | Domain | Recommended Packages |
436
- |--------|---------------------|
437
- | Date/time | `date-fns`, `dayjs` |
438
- | Validation | `zod`, `yup`, `valibot` |
439
- | HTTP with retry | `ky`, `got`, `axios` |
440
- | Form state | `react-hook-form` |
441
- | State management | `zustand`, `jotai` |
442
-
443
- 4. **For database-heavy features**
444
- - Verify table schemas against TypeScript types
445
- - Check proposed types match database columns
446
-
447
- 5. **For complex features (>5 AC items)**
448
- - Use Sequential Thinking to break down systematically
449
- - Document key decision points and trade-offs
450
-
451
- ## Output Structure
452
-
453
- ### 1. AC Checklist with Verification Criteria (REQUIRED)
454
-
455
- **Every AC MUST have an explicit Verification Method.** Restate AC as a checklist with verification for each:
456
-
457
- ```markdown
458
- ### AC-1: [Description]
459
-
460
- **Verification Method:** Unit Test | Integration Test | Manual Test | Browser Test
461
-
462
- **Test Scenario:**
463
- - Given: [Initial state]
464
- - When: [Action taken]
465
- - Then: [Expected outcome]
466
-
467
- **Integration Points:**
468
- - [External system or component]
469
-
470
- **Assumptions to Validate:**
471
- - [ ] [Assumption that must be true]
472
- ```
473
-
474
- #### Verification Method Decision Framework
475
-
476
- **REQUIRED:** Choose the most appropriate verification method for each AC:
477
-
478
- | AC Type | Verification Method | When to Use |
479
- |---------|---------------------|-------------|
480
- | Pure logic/calculation | **Unit Test** | Functions with clear input/output, no side effects |
481
- | API endpoint | **Integration Test** | HTTP handlers, database queries, external service calls |
482
- | User workflow | **Browser Test** | Multi-step UI interactions, form submissions |
483
- | Visual appearance | **Manual Test** | Styling, layout, animations (hard to automate) |
484
- | CLI command | **Integration Test** | Script execution, file operations, stdout verification |
485
- | Error handling | **Unit Test** + **Integration Test** | Both isolated behavior and realistic scenarios |
486
- | Performance | **Manual Test** + **Integration Test** | Timing thresholds, load testing |
487
-
488
- #### Verification Method Examples
489
-
490
- **Good (specific and testable):**
491
- ```markdown
492
- **AC-1:** User can submit the registration form
493
- **Verification Method:** Browser Test
494
- **Test Scenario:**
495
- - Given: User on /register page
496
- - When: Fill form fields, click Submit
497
- - Then: Redirect to /dashboard, success toast appears
498
- ```
499
-
500
- **Bad (vague, no clear verification):**
501
- ```markdown
502
- **AC-1:** Registration should work properly
503
- **Verification Method:** ??? (cannot determine)
504
- ```
505
-
506
- #### Flags for Missing Verification Methods
507
-
508
- If you cannot determine a verification method for an AC:
509
-
510
- 1. **Flag the AC as unclear:**
511
- ```markdown
512
- **AC-3:** System handles errors gracefully
513
- **Verification Method:** ⚠️ UNCLEAR - needs specific error scenarios
514
- **Suggested Refinement:** List specific error types and expected responses
515
- ```
516
-
517
- 2. **Include in Open Questions:**
518
- ```markdown
519
- ## Open Questions
520
-
521
- 1. **AC-3 verification method unclear**
522
- - Question: What specific error scenarios should be tested?
523
- - Recommendation: Define 3-5 error types with expected behavior
524
- - Impact: Without this, QA cannot objectively validate
525
- ```
526
-
527
- **Why this matters:** AC without verification methods:
528
- - Cannot be objectively validated in `/qa`
529
- - Lead to subjective "does it work?" assessments
530
- - Cause rework when expectations don't match implementation
531
-
532
- See [verification-criteria.md](references/verification-criteria.md) for detailed examples including the #452 hooks failure case.
533
-
534
- ### 2. Implementation Plan
535
-
536
- Propose a concrete plan in 3–7 steps that:
537
- - References specific codebase areas
538
- - Respects existing architecture
539
- - Groups related work into phases
540
- - Identifies dependencies between steps
541
-
542
- For each major decision:
543
- - Present 2-3 options when relevant
544
- - Recommend a default with rationale
545
- - Note if decision should be deferred
546
-
547
- **Open Questions Format:**
548
- - Question: [Clear question]
549
- - Recommendation: [Your suggested default]
550
- - Impact: [What happens if we get this wrong]
551
-
552
- See [parallel-groups.md](references/parallel-groups.md) for parallelization format.
553
-
554
- ### 2.5. Design Review (REQUIRED)
555
-
556
- **Purpose:** Make design decisions explicit before implementation starts. This forces evaluation of *how* to build, not just *what* to build — catching wrong-layer, over-engineered, or pattern-mismatched approaches before code is written.
557
-
558
- **Why this matters:** Repeated pattern across issues: implementation passes QA functionally but uses the wrong design — wrong layer, hacky shortcut, over-engineered approach. The fix cycle is expensive. Making design explicit here prevents it.
559
-
560
- **Complexity Scaling:**
561
- - **Simple issues** (`simple-fix`, `typo`, `docs-only` labels): Abbreviated — answer Q1 and Q3 only
562
- - **Standard issues**: Answer all 4 questions
563
- - **Complex issues** (`complex`, `refactor`, `breaking` labels): Answer all 4 questions with detailed rationale
564
-
565
- **Answer these questions:**
566
-
567
- 1. **Where does this logic belong?** — Which module/layer owns this change? Name the specific directory, file, or abstraction layer. If it spans layers, explain why.
568
-
569
- 2. **What's the simplest correct approach?** — Actively reject over-engineering. What's the minimum implementation that satisfies all AC? What alternatives did you consider and reject?
570
-
571
- 3. **What existing pattern does this follow?** — Name the specific pattern in the codebase. Confirm it fits this use case. If no existing pattern fits, explain why a new approach is needed.
572
-
573
- 4. **What would a senior reviewer challenge?** — Anticipate design pushback. What's the most likely "why didn't you just...?" or "this should be in X instead" feedback?
574
-
575
- **Example (standard issue):**
576
-
577
- ```markdown
578
- ## Design Review
579
-
580
- 1. **Where does this logic belong?** Spec skill's SKILL.md prompt files — purely prompt engineering, not TypeScript. Same layer as Feature Quality Planning and AC Checklist sections.
581
-
582
- 2. **What's the simplest correct approach?** Add markdown prompt text to SKILL.md. Reuse the existing complexity scaling pattern from Feature Quality Planning. No code, no new files, no abstractions.
583
-
584
- 3. **What existing pattern does this follow?** Mirrors Feature Quality Planning exactly: required section, purpose statement, complexity scaling table, question format.
585
-
586
- 4. **What would a senior reviewer challenge?** (1) "Why after Implementation Plan, not before?" — Design review needs the plan as input to evaluate. (2) "Won't this bloat output?" — Adds ~15 lines for standard, ~5 for simple-fix.
133
+ git worktree list --porcelain
134
+ # For each worktree: git -C <path> diff --name-only origin/main...HEAD
587
135
  ```
588
136
 
589
- **Example (simple-fix issue, abbreviated):**
137
+ If overlap detected → include **Conflict Risk Analysis** section with options (alternative approach / wait for merge / coordinate via /merger).
590
138
 
591
- ```markdown
592
- ## Design Review
139
+ Check for explicit dependencies: `gh issue view <issue> --json body,labels`. If "Depends on" found → include **Dependencies** section with status.
593
140
 
594
- 1. **Where does this logic belong?** `src/lib/utils.ts` — utility function, same layer as existing helpers.
141
+ ### Feature Branch Context
595
142
 
596
- 3. **What existing pattern does this follow?** Same pattern as `formatDuration()` in the same file pure function, no side effects, single responsibility.
597
- ```
143
+ Check issue body/labels for feature branch references (`feature/`, `based on`, epic labels). If found, recommend `--base feature/<branch>` in the plan.
598
144
 
599
- ### 3. Feature Quality Planning (REQUIRED)
145
+ ## Verification Method Decision Framework
600
146
 
601
- **Purpose:** Systematically consider professional implementation requirements beyond the minimum AC. This prevents gaps that slip through exec and QA because they were never planned.
147
+ Use this table when assigning verification methods to each AC:
602
148
 
603
- **Why this matters:** Spec currently plans the "minimum to satisfy AC" rather than "complete professional implementation." Gaps found in manual review are omissions from incomplete planning, not failures.
149
+ | AC Type | Method | When to Use |
150
+ |---------|--------|-------------|
151
+ | Pure logic/calculation | Unit Test | Clear input/output, no side effects |
152
+ | API endpoint | Integration Test | HTTP handlers, DB queries, external calls |
153
+ | User workflow | Browser Test | Multi-step UI interactions, forms |
154
+ | Visual appearance | Manual Test | Styling, layout, animations |
155
+ | CLI command | Integration Test | Script execution, stdout verification |
156
+ | Error handling | Unit + Integration | Both isolated and realistic scenarios |
604
157
 
605
- **Complexity Scaling:**
606
- - **Simple issues** (`simple-fix`, `typo`, `docs-only` labels): Use abbreviated checklist (Completeness + one relevant section)
607
- - **Standard issues**: Complete all applicable sections
608
- - **Complex issues** (`complex`, `refactor`, `breaking` labels): Complete all sections with detailed items
609
-
610
- ```markdown
611
- ## Feature Quality Planning
612
-
613
- ### Completeness Check
614
- - [ ] All AC items have corresponding implementation steps
615
- - [ ] Integration points with existing features identified
616
- - [ ] No partial implementations or TODOs planned
617
- - [ ] State management considered (if applicable)
618
- - [ ] Data flow is complete end-to-end
619
-
620
- ### Error Handling
621
- - [ ] Invalid input scenarios identified
622
- - [ ] API/external service failures handled
623
- - [ ] Edge cases documented (empty, null, max values)
624
- - [ ] Error messages are user-friendly
625
- - [ ] Graceful degradation planned
626
-
627
- ### Code Quality
628
- - [ ] Types fully defined (no `any` planned)
629
- - [ ] Follows existing patterns in codebase
630
- - [ ] Error boundaries where needed
631
- - [ ] No magic strings/numbers
632
- - [ ] Consistent naming conventions
633
-
634
- ### Test Coverage Plan
635
- - [ ] Unit tests for business logic
636
- - [ ] Integration tests for data flow
637
- - [ ] Edge case tests identified
638
- - [ ] Mocking strategy appropriate
639
- - [ ] Critical paths have test coverage
640
-
641
- ### Best Practices
642
- - [ ] Logging for debugging/observability
643
- - [ ] Accessibility considerations (if UI)
644
- - [ ] Performance implications considered
645
- - [ ] Security reviewed (auth, validation, sanitization)
646
- - [ ] Documentation updated (if behavior changes)
647
-
648
- ### Polish (UI features only)
649
- - [ ] Loading states planned
650
- - [ ] Error states have UI
651
- - [ ] Empty states handled
652
- - [ ] Responsive design considered
653
- - [ ] Keyboard navigation works
654
-
655
- ### Derived ACs
656
-
657
- Based on quality planning, identify additional ACs needed:
658
-
659
- | Source | Derived AC | Priority |
660
- |--------|-----------|----------|
661
- | Error Handling | AC-N: Handle [specific error] with [specific response] | High/Medium/Low |
662
- | Test Coverage | AC-N+1: Add tests for [specific scenario] | High/Medium/Low |
663
- | Best Practices | AC-N+2: Add logging for [specific operation] | High/Medium/Low |
664
-
665
- **Note:** Derived ACs are numbered sequentially after original ACs and follow the same format.
666
- ```
667
-
668
- **Section Applicability:**
669
-
670
- | Issue Type | Sections Required |
671
- |------------|-------------------|
672
- | Bug fix | Completeness, Error Handling, Test Coverage |
673
- | New feature | All sections |
674
- | Refactor | Completeness, Code Quality, Test Coverage |
675
- | UI change | All sections including Polish |
676
- | Backend/API | Completeness, Error Handling, Code Quality, Test Coverage, Best Practices |
677
- | CLI/Script | Completeness, Error Handling, Test Coverage, Best Practices |
678
- | Docs only | Completeness only |
679
-
680
- **Example (API endpoint feature):**
681
-
682
- ```markdown
683
- ## Feature Quality Planning
684
-
685
- ### Completeness Check
686
- - [x] All AC items have corresponding implementation steps
687
- - [x] Integration points: Auth middleware, database queries, response serializer
688
- - [x] No partial implementations planned
689
- - [ ] State management: N/A (stateless API)
690
- - [x] Data flow: Request → Validate → Query → Transform → Response
691
-
692
- ### Error Handling
693
- - [x] Invalid input: Return 400 with validation errors
694
- - [x] Auth failure: Return 401 with "Unauthorized" message
695
- - [x] Not found: Return 404 with resource ID
696
- - [x] Server error: Return 500, log full error, return generic message
697
- - [x] Rate limit: Return 429 with retry-after header
698
-
699
- ### Code Quality
700
- - [x] Types: Define RequestDTO, ResponseDTO, ErrorResponse
701
- - [x] Patterns: Follow existing controller pattern in `src/api/`
702
- - [ ] Error boundaries: N/A (API, not UI)
703
- - [x] No magic strings: Use constants for error messages
704
-
705
- ### Test Coverage Plan
706
- - [x] Unit: Validation logic, data transformation
707
- - [x] Integration: Full request/response cycle
708
- - [x] Edge cases: Empty results, max pagination, invalid IDs
709
- - [x] Mocking: Mock database, not HTTP layer
710
-
711
- ### Best Practices
712
- - [x] Logging: Log request ID, duration, status code
713
- - [ ] Accessibility: N/A (API)
714
- - [x] Performance: Add database index for query field
715
- - [x] Security: Validate input, sanitize output, check auth
716
-
717
- ### Derived ACs
718
-
719
- | Source | Derived AC | Priority |
720
- |--------|-----------|----------|
721
- | Error Handling | AC-6: Return 429 with retry-after header on rate limit | Medium |
722
- | Best Practices | AC-7: Log request ID and duration for observability | High |
723
- | Test Coverage | AC-8: Add integration test for auth failure path | High |
724
- ```
725
-
726
- ### 4. Plan Review
727
-
728
- Ask the user to confirm or adjust:
729
- - The AC checklist (with verification criteria)
730
- - The implementation plan
731
- - The assumptions to validate
732
-
733
- **Do NOT start implementation** - this is planning-only.
734
-
735
- ### 4.5. Assess Comment Detection (AC-4, AC-5)
736
-
737
- **Before making your own phase recommendation**, check if `/assess` has already posted an analysis comment to this issue:
738
-
739
- ```bash
740
- # Check for assess analysis comment on the issue (includes legacy /solve format for backward compat)
741
- assess_comment=$(gh issue view <issue-number> --json comments \
742
- --jq '[.comments[].body | select(test("## Assess Analysis|## Solve Analysis|<!-- assess:phases=|<!-- solve:phases="))] | last // empty')
743
- ```
744
-
745
- **If an assess analysis comment exists:**
746
-
747
- 1. Parse the HTML comment markers to extract the recommended phases:
748
- ```
749
- <!-- assess:phases=exec,qa --> → phases: ["exec", "qa"] (spec not included = skip spec)
750
- <!-- assess:browser-test=false --> → no browser testing needed
751
- <!-- assess:quality-loop=true --> → enable quality loop
752
- ```
753
-
754
- 2. **Use the assess recommendation as your starting point** for the phase recommendation in step 5.
755
-
756
- 3. **You may override the assess recommendation**, but you MUST document why:
757
- ```markdown
758
- ## Recommended Workflow
759
-
760
- **Phases:** spec → exec → test → qa
761
- **Quality Loop:** enabled
762
- **Reasoning:** Assess recommended `exec → qa`, but codebase analysis reveals UI components
763
- are affected (found `.tsx` files in change scope), so browser testing is needed.
764
- Overriding assess recommendation with explanation.
765
- ```
766
-
767
- 4. If the assess comment recommends phases that don't include `spec` (e.g., `phases=exec,qa`), acknowledge this in your output but proceed with spec since `/spec` was explicitly invoked.
768
-
769
- **If no assess analysis comment exists:** Proceed with your own analysis as normal (step 5).
770
-
771
- ### 5. Recommended Workflow
772
-
773
- Analyze the issue and recommend the optimal workflow phases:
774
-
775
- ```markdown
776
- ## Recommended Workflow
777
-
778
- **Phases:** spec → exec → qa
779
- **Quality Loop:** disabled
780
- **Reasoning:** [Brief explanation of why these phases were chosen]
781
- ```
782
-
783
- **Phase Selection Logic:**
784
- - **UI/Frontend changes** → Add `test` phase (browser testing)
785
- - **`no-browser-test` label** → Skip `test` phase (explicit opt-out, overrides UI labels)
786
- - **Bug fixes** → Skip `spec` if already well-defined
787
- - **Complex refactors** → Enable quality loop
788
- - **Security-sensitive** → Add `security-review` phase
789
- - **Documentation only** → Skip `spec`, just `exec → qa`
790
- - **New features with testable ACs** → Add `testgen` phase after spec
791
- - **Refactors needing regression tests** → Add `testgen` phase
792
-
793
- #### Browser Testing Label Suggestion
794
-
795
- **When `.tsx` or `.jsx` file references are detected** in the issue body AND the issue does NOT have `ui`, `frontend`, or `admin` labels, include this warning in the spec output:
796
-
797
- ```markdown
798
- > **Component files detected** — Issue body references `.tsx`/`.jsx` files or `components/` directory, but no `ui`/`frontend`/`admin` label is present.
799
- > - To enable browser testing: add the `ui` label → `gh issue edit <N> --add-label ui`
800
- > - To explicitly skip browser testing: add `no-browser-test` label → `gh issue edit <N> --add-label no-browser-test`
801
- > - Without either label, QA will note the missing browser test coverage.
802
- ```
803
-
804
- **When NOT to show this warning:**
805
- - Issue already has `ui`, `frontend`, or `admin` label (browser testing already enabled)
806
- - Issue has `no-browser-test` label (explicit opt-out)
807
- - No `.tsx`/`.jsx`/`components/` references detected
808
-
809
- #### Testgen Phase Auto-Detection
810
-
811
- **When to recommend `testgen` phase:**
812
-
813
- | Condition | Recommend testgen? | Reasoning |
814
- |-----------|-------------------|-----------|
815
- | ACs have "Unit Test" verification method | ✅ Yes | Tests should be stubbed before implementation |
816
- | ACs have "Integration Test" verification method | ✅ Yes | Complex integration tests benefit from early structure |
817
- | Issue is a new feature (not bug fix) with >2 AC items | ✅ Yes | Features need test coverage |
818
- | Issue has `enhancement` or `feature` label | ✅ Yes | New functionality needs tests |
819
- | Project has test framework (Jest, Vitest, etc.) | ✅ Yes | Infrastructure exists to run tests |
820
- | Issue is a simple bug fix (`bug` label only) | ❌ No | Bug fixes typically have targeted tests |
821
- | Issue is docs-only (`docs` label) | ❌ No | Documentation doesn't need unit tests |
822
- | All ACs have "Manual Test" or "Browser Test" verification | ❌ No | These don't generate code stubs |
823
-
824
- **Detection Logic:**
825
-
826
- 1. **Check verification methods in AC items:**
827
- - Count ACs with "Unit Test" → If >0, recommend testgen
828
- - Count ACs with "Integration Test" → If >0, recommend testgen
829
-
830
- 2. **Check issue labels:**
831
- ```bash
832
- gh issue view <issue> --json labels --jq '.labels[].name'
833
- ```
834
- - If `bug` or `fix` is the ONLY label → Skip testgen
835
- - If `docs` is present → Skip testgen
836
- - If `enhancement`, `feature`, `refactor` → Consider testgen
837
-
838
- 3. **Check project test infrastructure:**
839
- ```bash
840
- # Check for test framework in package.json
841
- grep -E "jest|vitest|mocha" package.json || true
842
- ```
843
- - If no test framework detected → Skip testgen (no infrastructure)
844
-
845
- **Example output when testgen is recommended:**
846
-
847
- ```markdown
848
- ## Recommended Workflow
849
-
850
- **Phases:** spec → testgen → exec → qa
851
- **Quality Loop:** disabled
852
- **Reasoning:** ACs include Unit Test verification methods; testgen will create stubs before implementation
853
- ```
854
-
855
- **Example output when testgen is NOT recommended:**
856
-
857
- ```markdown
858
- ## Recommended Workflow
859
-
860
- **Phases:** spec → exec → qa
861
- **Quality Loop:** disabled
862
- **Reasoning:** Bug fix with targeted scope; existing tests sufficient
863
- ```
864
-
865
- ### 6. Label Review
866
-
867
- Analyze current labels vs implementation plan and suggest updates:
868
-
869
- ```markdown
870
- ## Label Review
871
-
872
- **Current:** enhancement
873
- **Recommended:** enhancement, refactor
874
- **Reason:** Implementation plan involves structural changes to 5+ files
875
- **Quality Loop:** Will auto-enable due to `refactor` label
876
-
877
- → `gh issue edit <N> --add-label refactor`
878
- ```
879
-
880
- **Plan-Based Detection Logic:**
881
- - If plan has 5+ file changes → suggest `refactor`
882
- - If plan touches UI components → suggest `ui` or `frontend`
883
- - If plan has breaking API changes → suggest `breaking`
884
- - If plan involves database migrations → suggest `backend`, `complex`
885
- - If plan involves CLI/scripts → suggest `cli`
886
- - If plan is documentation-only → suggest `docs`
887
- - If recommended workflow includes quality loop → ensure matching label exists (`complex`, `refactor`, or `breaking`)
888
-
889
- **Label Inference from Plan Analysis:**
890
- - Count files in implementation plan steps
891
- - Identify component types being modified
892
- - Check if API contracts are changing
893
- - Match against quality loop trigger labels
894
-
895
- ### 7. Issue Comment Draft
896
-
897
- Generate a Markdown snippet with:
898
- - AC checklist with verification criteria
899
- - Verification methods summary
900
- - Consolidated assumptions checklist
901
- - Implementation plan with phases
902
- - Key decisions and rationale
903
- - Open questions with recommendations
904
- - Effort breakdown
905
-
906
- Label clearly as:
907
- ```md
908
- --- DRAFT GITHUB ISSUE COMMENT (PLAN) ---
909
- ```
910
-
911
- ### 8. Update GitHub Issue
912
-
913
- Post the draft comment to GitHub:
914
- ```bash
915
- gh issue comment <issue-number> --body "..."
916
- gh issue edit <issue-number> --add-label "planned"
917
- ```
918
-
919
- ---
920
-
921
- ## State Tracking
922
-
923
- **IMPORTANT:** Update workflow state when running standalone (not orchestrated).
924
-
925
- ### Check Orchestration Mode
926
-
927
- At the start of the skill, check if running orchestrated:
928
- ```bash
929
- # Check if orchestrated - if so, skip state updates
930
- if [[ -n "$SEQUANT_ORCHESTRATOR" ]]; then
931
- echo "Running orchestrated - state managed by orchestrator"
932
- fi
933
- ```
934
-
935
- ### State Updates (Standalone Only)
936
-
937
- When NOT orchestrated (`SEQUANT_ORCHESTRATOR` is not set):
938
-
939
- **At skill start:**
940
- ```bash
941
- npx tsx scripts/state/update.ts start <issue-number> spec
942
- ```
943
-
944
- **On successful completion:**
945
- ```bash
946
- npx tsx scripts/state/update.ts complete <issue-number> spec
947
- ```
948
-
949
- **On failure:**
950
- ```bash
951
- npx tsx scripts/state/update.ts fail <issue-number> spec "Error description"
952
- ```
953
-
954
- **Why this matters:** State tracking enables dashboard visibility, resume capability, and workflow orchestration. Skills update state when standalone; orchestrators handle state when running workflows.
955
-
956
- ---
957
-
958
- ## Output Verification
959
-
960
- **Before responding, verify your output includes ALL of these:**
961
-
962
- - [ ] **AC Quality Check** - Lint results (or "Skipped" if --skip-ac-lint)
963
- - [ ] **Scope Assessment** - Verdict and metrics (or "Skipped" if --skip-scope-check)
964
- - [ ] **Non-Goals Section** - Listed or warning if missing
965
- - [ ] **AC Checklist** - Numbered AC items (AC-1, AC-2, etc.) with descriptions
966
- - [ ] **Verification Criteria (REQUIRED)** - Each AC MUST have:
967
- - Explicit Verification Method (Unit Test, Integration Test, Browser Test, or Manual Test)
968
- - Test Scenario with Given/When/Then format
969
- - If unclear, flag as "⚠️ UNCLEAR" and add to Open Questions
970
- - [ ] **Conflict Risk Analysis** - Check for in-flight work, include if conflicts found
971
- - [ ] **Implementation Plan** - 3-7 concrete steps with codebase references
972
- - [ ] **Design Review** - All 4 questions answered (abbreviated to Q1+Q3 for simple-fix/typo/docs-only labels)
973
- - [ ] **Feature Quality Planning** - Quality dimensions checklist completed (abbreviated for simple-fix/typo/docs-only labels)
974
- - [ ] **Recommended Workflow** - Phases, Quality Loop setting, and Reasoning (auto-enable quality loop if scope is yellow/red)
975
- - [ ] **Label Review** - Current vs recommended labels based on plan analysis
976
- - [ ] **Open Questions** - Any ambiguities with recommended defaults (including unclear verification methods)
977
- - [ ] **Issue Comment Draft** - Formatted for GitHub posting
978
-
979
- **CRITICAL:** Do NOT output AC items without verification methods. Either:
980
- 1. Assign a verification method from the decision framework, or
981
- 2. Flag as "⚠️ UNCLEAR" and include in Open Questions
982
-
983
- **DO NOT respond until all items are verified.**
158
+ See [verification-criteria.md](references/verification-criteria.md) for detailed examples.
984
159
 
985
160
  ## Output Template
986
161
 
987
- You MUST include these sections in order:
162
+ **Single authoritative template.** Include ALL sections in this order. Scale detail by complexity tier.
988
163
 
989
164
  ```markdown
165
+ **Complexity: [Simple|Standard|Complex]** ([N] ACs, [N] directories)
166
+
990
167
  ## AC Quality Check
991
168
 
992
- [Output from AC linter, or "Skipped (--skip-ac-lint flag set)"]
169
+ [Inline analysis results, or "Skipped (--skip-ac-lint)"]
993
170
 
994
171
  ---
995
172
 
996
173
  ## Scope Assessment
997
174
 
998
- ### Non-Goals (Required)
999
-
1000
- [List non-goals from issue, or warning if missing]
1001
-
1002
- ### Scope Metrics
175
+ **Non-Goals:** [From issue body. If missing: "⚠️ Non-Goals section not found. Consider adding scope boundaries."]
1003
176
 
1004
177
  | Metric | Value | Status |
1005
178
  |--------|-------|--------|
@@ -1007,9 +180,9 @@ You MUST include these sections in order:
1007
180
  | AC items | [N] | [✅/⚠️/❌] |
1008
181
  | Directory spread | [N] | [✅/⚠️/❌] |
1009
182
 
1010
- ### Scope Verdict
183
+ **Verdict:** [✅ SCOPE_OK | ⚠️ SCOPE_WARNING | ❌ SCOPE_SPLIT_RECOMMENDED]
1011
184
 
1012
- [✅/⚠️/❌] **[SCOPE_OK/SCOPE_WARNING/SCOPE_SPLIT_RECOMMENDED]** - [Recommendation]
185
+ [Or "Skipped (--skip-scope-check)"]
1013
186
 
1014
187
  ---
1015
188
 
@@ -1017,116 +190,93 @@ You MUST include these sections in order:
1017
190
 
1018
191
  ### AC-1: [Description]
1019
192
 
1020
- **Verification Method:** [Unit Test | Integration Test | Browser Test | Manual Test]
1021
-
1022
- **Test Scenario:**
1023
- - Given: [Initial state]
1024
- - When: [Action]
1025
- - Then: [Expected outcome]
1026
-
1027
- ### AC-2: [Description]
1028
-
1029
- **Verification Method:** [Choose from decision framework]
193
+ **Verification:** [Unit Test | Integration Test | Browser Test | Manual Test]
194
+ **Scenario:** Given [state] → When [action] → Then [outcome]
195
+ **Assumptions:** [List any that need pre-coding validation]
1030
196
 
1031
- **Test Scenario:**
1032
- - Given: [Initial state]
1033
- - When: [Action]
1034
- - Then: [Expected outcome]
197
+ <!-- Repeat for all ACs. EVERY AC must have a Verification Method from the decision framework.
198
+ If unclear, flag as "⚠️ UNCLEAR" with suggested refinement. -->
1035
199
 
1036
- ### AC-N: [Unclear AC example]
200
+ <!-- Example of a completed AC entry:
1037
201
 
1038
- **Verification Method:** ⚠️ UNCLEAR - [reason why verification is unclear]
202
+ ### AC-3: User can submit the registration form
1039
203
 
1040
- **Suggested Refinement:** [How to make this AC testable]
1041
-
1042
- <!-- Continue for all AC items -->
204
+ **Verification:** Browser Test
205
+ **Scenario:** Given user on /register → When fill fields and click Submit → Then redirect to /dashboard with success toast
206
+ **Assumptions:** Auth API returns 201 on valid input; email uniqueness enforced by DB constraint
207
+ -->
1043
208
 
1044
209
  ---
1045
210
 
1046
211
  ## Implementation Plan
1047
212
 
1048
- ### Phase 1: [Phase Name]
1049
- 1. [Step with specific file/component references]
213
+ ### Phase 1: [Name]
214
+ 1. [Step referencing specific files/components from context gathering]
1050
215
  2. [Step]
1051
216
 
1052
- ### Phase 2: [Phase Name]
1053
- <!-- Continue for all phases -->
217
+ ### Phase 2: [Name]
218
+ <!-- 3-7 total steps. Group into phases. Note dependencies between steps.
219
+ For major decisions: present 2-3 options, recommend default with rationale.
220
+ See references/parallel-groups.md for parallel execution format (3+ independent tasks). -->
1054
221
 
1055
222
  ---
1056
223
 
1057
224
  ## Design Review
1058
225
 
1059
226
  1. **Where does this logic belong?** [Module/layer that owns this change]
1060
-
1061
227
  2. **What's the simplest correct approach?** [Minimum implementation, rejected alternatives]
228
+ 3. **What existing pattern does this follow?** [Named pattern, confirm it fits]
229
+ 4. **What would a senior reviewer challenge?** [Anticipated "why didn't you just...?" pushback]
1062
230
 
1063
- 3. **What existing pattern does this follow?** [Named pattern, confirmation it fits]
1064
-
1065
- 4. **What would a senior reviewer challenge?** [Anticipated pushback]
1066
-
1067
- <!-- For simple-fix/typo/docs-only: only Q1 and Q3 required -->
231
+ <!-- Simple tier: Q1 and Q3 only. Standard/Complex: all four. -->
1068
232
 
1069
233
  ---
1070
234
 
1071
235
  ## Feature Quality Planning
1072
236
 
1073
- ### Completeness Check
1074
- - [ ] All AC items have corresponding implementation steps
1075
- - [ ] Integration points identified
1076
- - [ ] No partial implementations planned
1077
-
1078
- ### Error Handling
1079
- - [ ] Invalid input scenarios identified
1080
- - [ ] External service failures handled
1081
- - [ ] Edge cases documented
237
+ <!-- Exception-based: report only gaps and concerns. Full checklist in references/quality-checklist.md -->
1082
238
 
1083
- ### Code Quality
1084
- - [ ] Types fully defined (no `any`)
1085
- - [ ] Follows existing patterns
1086
- - [ ] No magic strings/numbers
239
+ **All standard checks pass.** Notable items:
240
+ - [Gap or concern requiring attention]
241
+ - [Another gap if applicable]
1087
242
 
1088
- ### Test Coverage Plan
1089
- - [ ] Unit tests for business logic
1090
- - [ ] Edge case tests identified
1091
- - [ ] Critical paths covered
243
+ ### Derived ACs (if any)
1092
244
 
1093
- ### Best Practices
1094
- - [ ] Logging for observability
1095
- - [ ] Security reviewed
1096
- - [ ] Documentation updated
1097
-
1098
- ### Polish (UI only)
1099
- - [ ] Loading/error/empty states
1100
- - [ ] Responsive design
1101
-
1102
- ### Derived ACs
1103
245
  | Source | Derived AC | Priority |
1104
246
  |--------|-----------|----------|
1105
- | [Section] | AC-N: [Description] | High/Medium/Low |
247
+ | [Quality dimension] | AC-N: [Description] | High/Medium/Low |
248
+
249
+ <!-- Complex tier: walk through full checklist from references/quality-checklist.md -->
1106
250
 
1107
251
  ---
1108
252
 
1109
253
  ## Open Questions
1110
254
 
1111
- 1. **[Question]**
1112
- - Recommendation: [Default choice]
1113
- - Impact: [What happens if wrong]
255
+ 1. **[Question]** — Recommendation: [default]. Impact: [if wrong].
1114
256
 
1115
257
  ---
1116
258
 
1117
259
  ## Recommended Workflow
1118
260
 
1119
- **Phases:** exec → qa
1120
- **Quality Loop:** disabled
1121
- **Reasoning:** [Why these phases based on issue analysis]
261
+ **Phases:** [spec →] exec → qa
262
+ **Quality Loop:** [enabled/disabled]
263
+ **Reasoning:** [Brief explanation]
264
+
265
+ <!-- Decision logic:
266
+ - UI/frontend → add `test` phase
267
+ - `no-browser-test` label → skip `test` (overrides UI labels)
268
+ - Complex refactor → enable quality loop
269
+ - Security-sensitive → add `security-review` phase
270
+ - New features with Unit/Integration Test verification ACs → add `testgen` phase
271
+ - Docs-only → skip spec, just exec → qa -->
1122
272
 
1123
273
  ---
1124
274
 
1125
275
  ## Label Review
1126
276
 
1127
- **Current:** [current labels]
1128
- **Recommended:** [recommended labels]
1129
- **Reason:** [Why these labels based on plan analysis]
277
+ **Current:** [labels]
278
+ **Recommended:** [labels]
279
+ **Reason:** [Why, based on plan analysis]
1130
280
  **Quality Loop:** [Will/Won't auto-enable and why]
1131
281
 
1132
282
  → `gh issue edit <N> --add-label [label]`
@@ -1135,5 +285,56 @@ You MUST include these sections in order:
1135
285
 
1136
286
  --- DRAFT GITHUB ISSUE COMMENT (PLAN) ---
1137
287
 
1138
- [Complete formatted comment for GitHub]
288
+ [AC checklist with verification + implementation plan + key decisions + open questions]
289
+ ```
290
+
291
+ ### Testgen Phase Auto-Detection
292
+
293
+ #### When to recommend `testgen` phase:
294
+
295
+ | Condition | Recommend testgen? | Reasoning |
296
+ |-----------|-------------------|-----------|
297
+ | ACs have "Unit Test" verification method | Yes | Tests should be stubbed before implementation |
298
+ | ACs have "Integration Test" verification method | Yes | Complex integration tests benefit from early structure |
299
+ | New feature (`enhancement`/`feature` label) with >2 ACs | Yes | Features need test coverage |
300
+ | Simple bug fix (`bug` label only) | No | Skip testgen — targeted tests sufficient |
301
+ | Docs-only (`docs` label) | No | Skip testgen — no unit tests needed |
302
+ | All ACs have "Manual Test" or "Browser Test" | No | Skip testgen — no code stubs to generate |
303
+
304
+ **Detection logic:**
305
+ 1. Count ACs with "Unit Test" → If >0, recommend testgen
306
+ 2. Count ACs with "Integration Test" → If >0, recommend testgen
307
+ 3. Check labels: `bug`/`fix` only → Skip testgen. `docs` → Skip testgen.
308
+
309
+ **Example when testgen recommended:**
310
+ ```markdown
311
+ **Phases:** spec → testgen → exec → qa
312
+ **Reasoning:** ACs include Unit Test verification methods; testgen will create stubs before implementation
313
+ ```
314
+
315
+ ### Browser Testing Label Suggestion
316
+
317
+ When `.tsx`/`.jsx` references detected in issue body AND no `ui`/`frontend`/`admin` label present:
318
+ > **Component files detected** — add `ui` label for browser testing, or `no-browser-test` to explicitly skip.
319
+
320
+ ### Assess Comment Integration
321
+
322
+ Before making phase recommendations, check for prior `/assess` analysis:
323
+
324
+ ```bash
325
+ assess_comment=$(gh issue view <N> --json comments \
326
+ --jq '[.comments[].body | select(test("## Assess Analysis|<!-- assess:phases="))] | last // empty')
1139
327
  ```
328
+
329
+ If found, use assess recommendation as starting point. You may override, but MUST document why.
330
+
331
+ ## Update GitHub Issue
332
+
333
+ Post the draft comment and add label:
334
+
335
+ ```bash
336
+ gh issue comment <issue-number> --body "..."
337
+ gh issue edit <issue-number> --add-label "planned"
338
+ ```
339
+
340
+ **Do NOT start implementation** — this is planning-only.