sequant 2.0.1 → 2.1.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 (58) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/dist/bin/cli.js +2 -1
  4. package/dist/marketplace/external_plugins/sequant/.claude-plugin/plugin.json +1 -1
  5. package/dist/marketplace/external_plugins/sequant/.mcp.json +6 -0
  6. package/dist/marketplace/external_plugins/sequant/README.md +58 -8
  7. package/dist/marketplace/external_plugins/sequant/hooks/post-tool.sh +19 -8
  8. package/dist/marketplace/external_plugins/sequant/hooks/pre-tool.sh +36 -49
  9. package/dist/marketplace/external_plugins/sequant/skills/_shared/references/subagent-types.md +158 -48
  10. package/dist/marketplace/external_plugins/sequant/skills/assess/SKILL.md +354 -352
  11. package/dist/marketplace/external_plugins/sequant/skills/exec/SKILL.md +1155 -33
  12. package/dist/marketplace/external_plugins/sequant/skills/fullsolve/SKILL.md +35 -4
  13. package/dist/marketplace/external_plugins/sequant/skills/qa/SKILL.md +2157 -104
  14. package/dist/marketplace/external_plugins/sequant/skills/qa/scripts/quality-checks.sh +1 -1
  15. package/dist/marketplace/external_plugins/sequant/skills/setup/SKILL.md +386 -0
  16. package/dist/marketplace/external_plugins/sequant/skills/solve/SKILL.md +38 -664
  17. package/dist/marketplace/external_plugins/sequant/skills/spec/SKILL.md +505 -120
  18. package/dist/marketplace/external_plugins/sequant/skills/test/SKILL.md +246 -1
  19. package/dist/marketplace/external_plugins/sequant/skills/testgen/SKILL.md +138 -1
  20. package/dist/src/commands/dashboard.js +1 -1
  21. package/dist/src/commands/doctor.js +1 -1
  22. package/dist/src/commands/init.js +10 -10
  23. package/dist/src/commands/logs.js +1 -1
  24. package/dist/src/commands/run.js +49 -39
  25. package/dist/src/commands/state.js +3 -3
  26. package/dist/src/commands/status.js +5 -5
  27. package/dist/src/commands/sync.js +8 -8
  28. package/dist/src/commands/update.js +16 -16
  29. package/dist/src/lib/cli-ui.js +20 -19
  30. package/dist/src/lib/merge-check/index.js +2 -2
  31. package/dist/src/lib/settings.d.ts +8 -0
  32. package/dist/src/lib/settings.js +1 -0
  33. package/dist/src/lib/shutdown.js +1 -1
  34. package/dist/src/lib/templates.js +2 -0
  35. package/dist/src/lib/wizard.js +6 -4
  36. package/dist/src/lib/workflow/batch-executor.js +1 -1
  37. package/dist/src/lib/workflow/log-writer.js +6 -6
  38. package/dist/src/lib/workflow/metrics-writer.js +5 -3
  39. package/dist/src/lib/workflow/phase-executor.js +5 -1
  40. package/dist/src/lib/workflow/platforms/github.js +5 -1
  41. package/dist/src/lib/workflow/state-cleanup.js +1 -1
  42. package/dist/src/lib/workflow/state-manager.js +15 -13
  43. package/dist/src/lib/workflow/state-rebuild.js +2 -2
  44. package/dist/src/lib/workflow/types.d.ts +11 -0
  45. package/dist/src/lib/workflow/worktree-manager.js +40 -41
  46. package/dist/src/lib/worktree-isolation.d.ts +130 -0
  47. package/dist/src/lib/worktree-isolation.js +310 -0
  48. package/package.json +8 -8
  49. package/templates/agents/sequant-explorer.md +23 -0
  50. package/templates/agents/sequant-implementer.md +18 -0
  51. package/templates/agents/sequant-qa-checker.md +24 -0
  52. package/templates/agents/sequant-testgen.md +25 -0
  53. package/templates/scripts/cleanup-worktree.sh +18 -0
  54. package/templates/skills/_shared/references/subagent-types.md +158 -48
  55. package/templates/skills/exec/SKILL.md +72 -6
  56. package/templates/skills/qa/SKILL.md +8 -217
  57. package/templates/skills/spec/SKILL.md +446 -120
  58. package/templates/skills/testgen/SKILL.md +138 -1
@@ -13,7 +13,7 @@ allowed-tools:
13
13
  - Bash(gh label:*)
14
14
  - Bash(git worktree:*)
15
15
  - Bash(git -C:*)
16
- - Task(Explore)
16
+ - Agent(sequant-explorer)
17
17
  - AgentOutputTool
18
18
  ---
19
19
 
@@ -84,6 +84,11 @@ When called like `/spec <freeform description>`:
84
84
  - Effect: Skips the AC Quality Check step
85
85
  - Use when: AC are intentionally high-level or you want to defer linting
86
86
 
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
91
+
87
92
  ### AC Extraction and Storage — REQUIRED
88
93
 
89
94
  **After fetching the issue body**, extract and store acceptance criteria in workflow state:
@@ -190,6 +195,103 @@ console.log(formatACLintResults(lintResults));
190
195
  - Output: `AC Quality Check: Skipped (--skip-ac-lint flag set)`
191
196
  - Continue directly to plan generation
192
197
 
198
+ ### Scope Assessment — REQUIRED (unless --skip-scope-check)
199
+
200
+ **After AC Quality Check**, run scope assessment to detect overscoped issues:
201
+
202
+ ```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
+ "
221
+ ```
222
+
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:**
229
+
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+ |
235
+
236
+ **Non-Goals Section:**
237
+
238
+ Every `/spec` output MUST include a Non-Goals section. If the issue lacks one, output a warning:
239
+
240
+ ```markdown
241
+ ## Non-Goals
242
+
243
+ ⚠️ **Non-Goals section not found.** Consider adding scope boundaries.
244
+
245
+ Example format:
246
+ - [ ] [Adjacent feature we're deferring]
247
+ - [ ] [Scope boundary we're respecting]
248
+ - [ ] [Future work that's out of scope]
249
+ ```
250
+
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:
275
+
276
+ ```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
+
193
295
  ### Feature Worktree Workflow
194
296
 
195
297
  **Planning Phase:** No worktree needed. Planning happens in the main repository directory. The worktree will be created during the execution phase (`/exec`).
@@ -209,21 +311,21 @@ Read(file_path=".sequant/settings.json")
209
311
 
210
312
  **Spawn ALL THREE agents in a SINGLE message:**
211
313
 
212
- 1. `Task(subagent_type="Explore", model="haiku", prompt="Find similar features for [FEATURE]. Check components/admin/, lib/queries/, docs/patterns/. Report: file paths, patterns, recommendations.")`
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.")`
213
315
 
214
- 2. `Task(subagent_type="Explore", model="haiku", prompt="Explore [CODEBASE AREA] for [FEATURE]. Find: main components, data flow, key files. Report structure.")`
316
+ 2. `Agent(subagent_type="sequant-explorer", prompt="Explore [CODEBASE AREA] for [FEATURE]. Find: main components, data flow, key files. Report structure.")`
215
317
 
216
- 3. `Task(subagent_type="Explore", model="haiku", prompt="Inspect database for [FEATURE]. Check: table schema, RLS policies, existing queries. Report findings.")`
318
+ 3. `Agent(subagent_type="sequant-explorer", prompt="Inspect database for [FEATURE]. Check: table schema, RLS policies, existing queries. Report findings.")`
217
319
 
218
320
  #### If sequential mode (default):
219
321
 
220
322
  **Spawn each agent ONE AT A TIME, waiting for each to complete:**
221
323
 
222
- 1. **First:** `Task(subagent_type="Explore", model="haiku", prompt="Find similar features for [FEATURE]. Check components/admin/, lib/queries/, docs/patterns/. Report: file paths, patterns, recommendations.")`
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.")`
223
325
 
224
- 2. **After #1 completes:** `Task(subagent_type="Explore", model="haiku", prompt="Explore [CODEBASE AREA] for [FEATURE]. Find: main components, data flow, key files. Report structure.")`
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.")`
225
327
 
226
- 3. **After #2 completes:** `Task(subagent_type="Explore", model="haiku", prompt="Inspect database for [FEATURE]. Check: table schema, RLS policies, existing queries. Report findings.")`
328
+ 3. **After #2 completes:** `Agent(subagent_type="sequant-explorer", prompt="Inspect database for [FEATURE]. Check: table schema, RLS policies, existing queries. Report findings.")`
227
329
 
228
330
  ### Feature Branch Context Detection
229
331
 
@@ -348,9 +450,9 @@ Before creating the implementation plan, scan for potential conflicts with in-fl
348
450
 
349
451
  ## Output Structure
350
452
 
351
- ### 1. AC Checklist with Verification Criteria
453
+ ### 1. AC Checklist with Verification Criteria (REQUIRED)
352
454
 
353
- Restate AC as a checklist with verification for each:
455
+ **Every AC MUST have an explicit Verification Method.** Restate AC as a checklist with verification for each:
354
456
 
355
457
  ```markdown
356
458
  ### AC-1: [Description]
@@ -369,6 +471,64 @@ Restate AC as a checklist with verification for each:
369
471
  - [ ] [Assumption that must be true]
370
472
  ```
371
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
+
372
532
  See [verification-criteria.md](references/verification-criteria.md) for detailed examples including the #452 hooks failure case.
373
533
 
374
534
  ### 2. Implementation Plan
@@ -436,105 +596,141 @@ See [parallel-groups.md](references/parallel-groups.md) for parallelization form
436
596
  3. **What existing pattern does this follow?** Same pattern as `formatDuration()` in the same file — pure function, no side effects, single responsibility.
437
597
  ```
438
598
 
439
- ### 3. Plan Review
599
+ ### 3. Feature Quality Planning (REQUIRED)
440
600
 
441
- Ask the user to confirm or adjust:
442
- - The AC checklist (with verification criteria)
443
- - The implementation plan
444
- - The assumptions to validate
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.
445
602
 
446
- **Do NOT start implementation** - this is planning-only.
447
-
448
- ### 4. Content Analysis (AC-1, AC-2, AC-3, AC-4)
449
-
450
- **Before** determining the recommended workflow, analyze the issue content for phase-relevant signals:
451
-
452
- #### Step 1: Check for Assess Comment (AC-4)
453
-
454
- First, check if an `/assess` comment already exists for this issue:
455
-
456
- ```bash
457
- # Check issue comments for assess workflow (includes legacy /solve format for backward compat)
458
- gh issue view <issue-number> --json comments --jq '.comments[].body' | grep -l "## Assess Analysis\|## Solve Workflow for Issues:" || true
459
- ```
460
-
461
- **If assess comment found:**
462
- - Extract phases from the assess workflow (e.g., `spec → exec → test → qa`)
463
- - Use assess recommendations as the primary source (after labels)
464
- - Skip content analysis for phases (assess already analyzed)
465
- - Include in output: `"Assess comment found - using /assess workflow recommendations"`
466
-
467
- #### Step 2: Analyze Title for Keywords (AC-1)
468
-
469
- If no assess comment, analyze the issue title for phase-relevant keywords:
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.
470
604
 
471
- | Pattern | Detection | Suggested Phase |
472
- |---------|-----------|-----------------|
473
- | `extract`, `component` | UI work | Add `/test` |
474
- | `refactor.*ui`, `ui refactor` | UI work | Add `/test` |
475
- | `frontend`, `dashboard` | UI work | Add `/test` |
476
- | `auth`, `permission`, `security` | Security-sensitive | Add `/security-review` |
477
- | `password`, `credential`, `token` | Security-sensitive | Add `/security-review` |
478
- | `refactor`, `migration`, `restructure` | Complex work | Enable quality loop |
479
- | `breaking change` | Complex work | Enable quality loop |
480
-
481
- #### Step 3: Analyze Body for Patterns (AC-2)
482
-
483
- Analyze the issue body for file references and keywords:
484
-
485
- | Pattern | Detection | Suggested Phase |
486
- |---------|-----------|-----------------|
487
- | References `.tsx` or `.jsx` files | UI work likely | Add `/test` |
488
- | References `components/` directory | UI work | Add `/test` |
489
- | References `scripts/` or `bin/` | CLI work | May need `/verify` |
490
- | References `auth/` directory | Security-sensitive | Add `/security-review` |
491
- | References `middleware.ts` | May be auth-related | Consider `/security-review` |
492
- | Contains "breaking change" | Complex work | Enable quality loop |
493
-
494
- #### Step 3a: Browser Testing Label Suggestion
495
-
496
- **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:
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
497
609
 
498
610
  ```markdown
499
- > **Component files detected** — Issue body references `.tsx`/`.jsx` files or `components/` directory, but no `ui`/`frontend`/`admin` label is present.
500
- > - To enable browser testing: add the `ui` label → `gh issue edit <N> --add-label ui`
501
- > - To explicitly skip browser testing: add `no-browser-test` label → `gh issue edit <N> --add-label no-browser-test`
502
- > - Without either label, QA will note the missing browser test coverage.
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.
503
666
  ```
504
667
 
505
- **When NOT to show this warning:**
506
- - Issue already has `ui`, `frontend`, or `admin` label (browser testing already enabled)
507
- - Issue has `no-browser-test` label (explicit opt-out)
508
- - No `.tsx`/`.jsx`/`components/` references detected
509
-
510
- #### Step 4: Merge Signals (AC-3)
668
+ **Section Applicability:**
511
669
 
512
- Content analysis **supplements** label detection - it can only ADD phases, never remove them.
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 |
513
679
 
514
- **Priority order (highest first):**
515
- 1. **Labels** (explicit, highest priority)
516
- 2. **Assess comment** (if exists)
517
- 3. **Title keywords**
518
- 4. **Body patterns** (lowest priority)
519
-
520
- **Output format:**
680
+ **Example (API endpoint feature):**
521
681
 
522
682
  ```markdown
523
- ## Content Analysis
524
-
525
- ### Signal Sources
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
+ ```
526
725
 
527
- | Phase | Source | Confidence | Reason |
528
- |-------|--------|------------|--------|
529
- | /test | title | high | "Extract component" detected |
530
- | /security-review | body | medium | References auth/ directory |
726
+ ### 4. Plan Review
531
727
 
532
- ### Merged Recommendations
728
+ Ask the user to confirm or adjust:
729
+ - The AC checklist (with verification criteria)
730
+ - The implementation plan
731
+ - The assumptions to validate
533
732
 
534
- **From labels:** /test (ui label)
535
- **From content:** /security-review (added)
536
- **Final phases:** spec → exec → test → security-review → qa
537
- ```
733
+ **Do NOT start implementation** - this is planning-only.
538
734
 
539
735
  ### 4.5. Assess Comment Detection (AC-4, AC-5)
540
736
 
@@ -581,20 +777,90 @@ Analyze the issue and recommend the optimal workflow phases:
581
777
 
582
778
  **Phases:** spec → exec → qa
583
779
  **Quality Loop:** disabled
584
- **Signal Sources:** [labels | solve | content]
585
780
  **Reasoning:** [Brief explanation of why these phases were chosen]
586
781
  ```
587
782
 
588
783
  **Phase Selection Logic:**
589
784
  - **UI/Frontend changes** → Add `test` phase (browser testing)
785
+ - **`no-browser-test` label** → Skip `test` phase (explicit opt-out, overrides UI labels)
590
786
  - **Bug fixes** → Skip `spec` if already well-defined
591
787
  - **Complex refactors** → Enable quality loop
592
788
  - **Security-sensitive** → Add `security-review` phase
593
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 |
594
823
 
595
- **Content Analysis Integration:**
596
- - Include content-detected phases in the workflow
597
- - Note signal source in reasoning (e.g., "Added /test based on title keyword 'extract component'")
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
+ ```
598
864
 
599
865
  ### 6. Label Review
600
866
 
@@ -694,17 +960,26 @@ npx tsx scripts/state/update.ts fail <issue-number> spec "Error description"
694
960
  **Before responding, verify your output includes ALL of these:**
695
961
 
696
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
697
965
  - [ ] **AC Checklist** - Numbered AC items (AC-1, AC-2, etc.) with descriptions
698
- - [ ] **Verification Criteria** - Each AC has Verification Method and Test Scenario
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
699
970
  - [ ] **Conflict Risk Analysis** - Check for in-flight work, include if conflicts found
700
971
  - [ ] **Implementation Plan** - 3-7 concrete steps with codebase references
701
972
  - [ ] **Design Review** - All 4 questions answered (abbreviated to Q1+Q3 for simple-fix/typo/docs-only labels)
702
- - [ ] **Content Analysis** - Title/body analysis results (or "Assess comment found" if using /assess)
703
- - [ ] **Recommended Workflow** - Phases, Quality Loop setting, Signal Sources, and Reasoning
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)
704
975
  - [ ] **Label Review** - Current vs recommended labels based on plan analysis
705
- - [ ] **Open Questions** - Any ambiguities with recommended defaults
976
+ - [ ] **Open Questions** - Any ambiguities with recommended defaults (including unclear verification methods)
706
977
  - [ ] **Issue Comment Draft** - Formatted for GitHub posting
707
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
+
708
983
  **DO NOT respond until all items are verified.**
709
984
 
710
985
  ## Output Template
@@ -718,6 +993,26 @@ You MUST include these sections in order:
718
993
 
719
994
  ---
720
995
 
996
+ ## Scope Assessment
997
+
998
+ ### Non-Goals (Required)
999
+
1000
+ [List non-goals from issue, or warning if missing]
1001
+
1002
+ ### Scope Metrics
1003
+
1004
+ | Metric | Value | Status |
1005
+ |--------|-------|--------|
1006
+ | Feature count | [N] | [✅/⚠️/❌] |
1007
+ | AC items | [N] | [✅/⚠️/❌] |
1008
+ | Directory spread | [N] | [✅/⚠️/❌] |
1009
+
1010
+ ### Scope Verdict
1011
+
1012
+ [✅/⚠️/❌] **[SCOPE_OK/SCOPE_WARNING/SCOPE_SPLIT_RECOMMENDED]** - [Recommendation]
1013
+
1014
+ ---
1015
+
721
1016
  ## Acceptance Criteria
722
1017
 
723
1018
  ### AC-1: [Description]
@@ -730,6 +1025,20 @@ You MUST include these sections in order:
730
1025
  - Then: [Expected outcome]
731
1026
 
732
1027
  ### AC-2: [Description]
1028
+
1029
+ **Verification Method:** [Choose from decision framework]
1030
+
1031
+ **Test Scenario:**
1032
+ - Given: [Initial state]
1033
+ - When: [Action]
1034
+ - Then: [Expected outcome]
1035
+
1036
+ ### AC-N: [Unclear AC example]
1037
+
1038
+ **Verification Method:** ⚠️ UNCLEAR - [reason why verification is unclear]
1039
+
1040
+ **Suggested Refinement:** [How to make this AC testable]
1041
+
733
1042
  <!-- Continue for all AC items -->
734
1043
 
735
1044
  ---
@@ -759,31 +1068,49 @@ You MUST include these sections in order:
759
1068
 
760
1069
  ---
761
1070
 
762
- ## Open Questions
1071
+ ## Feature Quality Planning
763
1072
 
764
- 1. **[Question]**
765
- - Recommendation: [Default choice]
766
- - Impact: [What happens if wrong]
1073
+ ### Completeness Check
1074
+ - [ ] All AC items have corresponding implementation steps
1075
+ - [ ] Integration points identified
1076
+ - [ ] No partial implementations planned
767
1077
 
768
- ---
1078
+ ### Error Handling
1079
+ - [ ] Invalid input scenarios identified
1080
+ - [ ] External service failures handled
1081
+ - [ ] Edge cases documented
1082
+
1083
+ ### Code Quality
1084
+ - [ ] Types fully defined (no `any`)
1085
+ - [ ] Follows existing patterns
1086
+ - [ ] No magic strings/numbers
1087
+
1088
+ ### Test Coverage Plan
1089
+ - [ ] Unit tests for business logic
1090
+ - [ ] Edge case tests identified
1091
+ - [ ] Critical paths covered
769
1092
 
770
- ## Content Analysis
1093
+ ### Best Practices
1094
+ - [ ] Logging for observability
1095
+ - [ ] Security reviewed
1096
+ - [ ] Documentation updated
771
1097
 
772
- <!-- If assess comment found: -->
773
- **Source:** Assess comment found - using /assess workflow recommendations
1098
+ ### Polish (UI only)
1099
+ - [ ] Loading/error/empty states
1100
+ - [ ] Responsive design
774
1101
 
775
- <!-- If no assess comment, show analysis: -->
776
- ### Signal Sources
1102
+ ### Derived ACs
1103
+ | Source | Derived AC | Priority |
1104
+ |--------|-----------|----------|
1105
+ | [Section] | AC-N: [Description] | High/Medium/Low |
777
1106
 
778
- | Phase | Source | Confidence | Reason |
779
- |-------|--------|------------|--------|
780
- | /test | title | high | "[matched keyword]" detected |
781
- | /security-review | body | medium | References [pattern] |
1107
+ ---
782
1108
 
783
- ### Merged Recommendations
1109
+ ## Open Questions
784
1110
 
785
- **From labels:** [label-detected phases]
786
- **From content:** [content-detected phases]
1111
+ 1. **[Question]**
1112
+ - Recommendation: [Default choice]
1113
+ - Impact: [What happens if wrong]
787
1114
 
788
1115
  ---
789
1116
 
@@ -791,7 +1118,6 @@ You MUST include these sections in order:
791
1118
 
792
1119
  **Phases:** exec → qa
793
1120
  **Quality Loop:** disabled
794
- **Signal Sources:** [labels | solve | content]
795
1121
  **Reasoning:** [Why these phases based on issue analysis]
796
1122
 
797
1123
  ---