Skip to content

feat: CLI wiring completeness — QA verification + exec prevention for new option fields #307

Closed

Description

@admarble

Problem

When a new CLI option is added to a TypeScript interface (e.g., RunOptions.force) and used in runtime code (mergedOptions.force), but NOT registered in the CLI argument parser (bin/cli.ts), the flag is silently unreachable from the command line. Commander.js will error on the unrecognized option.

This class of bug is invisible to:

  • TypeScript compilation (interface field is valid)
  • Build (compiles fine)
  • Unit tests (mock the option directly, never go through CLI parsing)
  • CI (all checks pass)

Incident: #305 --force flag (2026-02-20)

Issue #305 added a force?: boolean field to RunOptions, checked it at runtime with mergedOptions.force, and displayed "use --force to re-run" in user-facing warnings. But --force was never registered as a .option() on the run command in bin/cli.ts. The previous QA pass gave READY_FOR_MERGE. The bug was caught by manual cross-reference during a second QA run.

Root cause

The QA skill has no mechanical check for CLI wiring completeness. It reviews code quality, tests, security, and AC coverage — but not whether new interface fields have corresponding CLI registrations.

Proposed Solution

Add a CLI Registration Verification section to the QA skill that triggers when option interfaces or bin/cli.ts are modified.

Detection

# Check if option interfaces or CLI file were modified
cli_modified=$(git diff main...HEAD --name-only | grep -E "bin/cli\.ts|RunOptions" | wc -l | xargs)

Verification Logic

# Extract user-facing option fields from RunOptions (exclude internal-only fields)
interface_fields=$(git diff main...HEAD -- src/commands/run.ts | grep -E '^\+\s+\w+\??: ' | sed 's/.*+ *//' | sed 's/\?.*//') 

# Extract registered CLI options
registered=$(grep '\.option(' bin/cli.ts | grep -oE '\-\-[a-z-]+')

# Cross-reference: flag any new field with runtime usage but no CLI registration

Output Format

### CLI Registration Verification

| Interface Field | Runtime Usage | CLI Registered | Status |
|----------------|--------------|----------------|--------|
| `force` | `mergedOptions.force` (line 2447) | `--force` in bin/cli.ts | OK |
| `newField` | `mergedOptions.newField` (line 500) | NOT REGISTERED | FAIL |

Acceptance Criteria

  • AC-1: QA skill detects when RunOptions (or similar CLI option interfaces) are modified in the diff
  • AC-2: For each new field with runtime usage (mergedOptions.X), QA verifies a corresponding .option() exists in bin/cli.ts
  • AC-3: Missing CLI registrations are flagged as issues in the QA output
  • AC-4: Verdict cannot be READY_FOR_MERGE if CLI registration verification fails
  • AC-5: Internal-only fields (e.g., autoDetectPhases, worktreeIsolation) are excluded from the check (no runtime mergedOptions.X → --X expectation)

Files to Modify

File Changes
.claude/skills/qa/SKILL.md Add CLI Registration Verification section (Section 2f)

Context


Merged from #308: Exec-Side Prevention

In addition to QA-side detection, add a CLI wiring checklist to the exec skill that triggers when option interfaces are modified.

Exec Skill Addition

Add to the exec skill's pre-PR checklist:

CLI Wiring Check: If you added a new field to RunOptions or any CLI command's option interface:

  1. Register the flag in bin/cli.ts with .option("--flag-name", "description")
  2. Verify with npx sequant <command> --help that the flag appears
  3. Boolean flags: --flag / --no-flag
  4. Value flags: --flag <value> with optional parser (e.g., parseInt)

Key File Map (from #308)

Interface CLI Registration
RunOptions in src/commands/run.ts run command in bin/cli.ts
MergeOptions in src/commands/merge.ts merge command in bin/cli.ts

Combined Acceptance Criteria

Activity

  1. added
    enhancement
    on Feb 20, 2026
  2. changed the title [-]feat(qa): Add CLI registration verification for new option fields[/-] [+]feat: CLI wiring completeness — QA verification + exec prevention for new option fields[/+] on Feb 22, 2026
  3. admarble commented on Mar 12, 2026

    @admarble
    ContributorAuthor

    Solve Analysis

    Recommended Phases: spec → exec → qa
    Skip Spec: No (complex cross-skill verification logic needs design)
    Browser Testing: No (skill file changes, not UI)
    Quality Loop: Yes (part of 3-issue chain, includes merged #308 scope)

    Reasoning

    Flags

    Flag Value Reasoning
    -q (quality-loop) ✓ Enhancement with cross-skill modifications
    --chain ✓ Shares .claude/skills/qa/SKILL.md with #254, #304
    --qa-gate ✗ Additive sections, low stale risk
    --base ✗ Branching from main
    --testgen ✗ Skill config changes, no unit test ACs

    📝 Generated by /solve

  4. admarble commented on Mar 12, 2026

    @admarble
    ContributorAuthor

    Spec Review Complete

    Acceptance Criteria

    AC Description Verification Method Status
    AC-1 QA skill detects when RunOptions modified Integration Test ⬜ Planned
    AC-2 Verify .option() exists for runtime mergedOptions.X usage Integration Test ⬜ Planned
    AC-3 Missing registrations flagged in QA output Unit Test (output format) ⬜ Planned
    AC-4 Verdict blocked if verification fails Integration Test ⬜ Planned
    AC-5 Internal-only fields excluded Unit Test ⬜ Planned

    Key File Map

    Interface Location CLI Registration
    RunOptions src/lib/workflow/batch-executor.ts run command in bin/cli.ts
    MergeOptions src/commands/merge.ts merge command in bin/cli.ts

    Implementation Plan

    Phase 1: QA Skill Updates (.claude/skills/qa/SKILL.md)

    1. Add Section 2g: CLI Registration Verification
    2. Detection: git diff main...HEAD --name-only | grep -E "RunOptions|MergeOptions"
    3. Cross-reference: New interface fields ↔ .option() registrations
    4. Output: Status table with PASS/FAIL per field
    5. Verdict gate: Failed verification → AC_NOT_MET

    Phase 2: Exec Skill Updates (.claude/skills/exec/SKILL.md)

    1. Add Section 3f: CLI Wiring Checklist
    2. Triggered when interface files modified
    3. Checklist: Register flag, verify with --help, follow conventions

    Conflict Coordination

    Issue Files Risk Mitigation
    #254 .claude/skills/qa/SKILL.md Low Additive section
    #304 .claude/skills/qa/SKILL.md, .claude/skills/exec/SKILL.md Low Additive section
    #233 .claude/skills/exec/SKILL.md, bin/cli.ts Low Different sections

    Chain position: Last of #254, #304, #307 QA skill chain (per solve analysis)

    Open Questions

    1. Internal-only field detection: Explicit allowlist vs heuristic?

      • Recommendation: Explicit allowlist with documented reasons
    2. Cross-command coverage: Just run or all commands?

      • Recommendation: Start with run, expand later

    Recommended Workflow

    npx sequant run 307 -q  # Quality loop enabled (cross-skill changes)
    
  5. added
    planned
    on Mar 12, 2026
  6. added a commit that references this issue on Mar 12, 2026
  7. admarble commented on Mar 12, 2026

    @admarble
    ContributorAuthor

    /exec Phase Complete

    AC Coverage Summary

    AC Description Status Evidence
    AC-1 Add CLI Registration Verification section to QA skill (Section 2g) ✅ Implemented .claude/skills/qa/SKILL.md:931-1028
    AC-2 Add CLI Wiring Checklist section to exec skill (Section 3g) ✅ Implemented .claude/skills/exec/SKILL.md:575-640
    AC-3 Reference #305 as origin in both sections ✅ Implemented Both sections include "Origin: Issue #305"
    AC-4 Verification failure gates verdict to AC_NOT_MET ✅ Implemented QA skill "Verdict Gating" table
    AC-5 Internal-only field exclusion (no mergedOptions.X) ✅ Implemented Both skills explain exclusion logic

    Files Changed

    • .claude/skills/qa/SKILL.md - Added Section 2g: CLI Registration Verification + output template
    • .claude/skills/exec/SKILL.md - Added Section 3g: CLI Wiring Checklist + output verification checklist item

    Quality Plan Alignment

    N/A - No quality plan in issue

    Check Results

    Check Status Notes
    Build ✅ Passed npm run build succeeded
    Lint ⚠️ Pre-existing warnings 5 warnings in unrelated files (only .md files modified)
    Tests ⚠️ 1 flaky timeout Pre-existing flaky test in state-utils.test.ts (not related to changes)

    PR Status

    ✅ Created: #351

    Implementation Highlights

    1. QA Skill (Section 2g): Comprehensive detection of option interface fields with runtime usage but missing CLI registration. Includes:

      • Detection script using git diff and grep
      • Key file map linking RunOptions to bin/cli.ts
      • Internal-only field exclusion logic
      • Verdict gating table (Failed → AC_NOT_MET)
      • Output template section for reports
    2. Exec Skill (Section 3g): Proactive implementation-time checklist with:

      • Step-by-step wiring verification
      • Quick verification script
      • Self-check table template before commit
      • Output verification checklist item
  8. admarble commented on Mar 12, 2026

    @admarble
    ContributorAuthor

    QA Review — Issue #307

    PR: #351
    Branch: feature/307-feat-cli-wiring-completeness-qa-verification-exec-
    Commit: e6777ac — feat(#307): add CLI wiring completeness checks to /exec and /qa skills


    Phase 0: Pre-flight

    Check Status Notes
    Worktree found PASS /Users/tony/Projects/worktrees/feature/307-feat-cli-wiring-completeness-qa-verification-exec-
    PR exists PASS PR #351, OPEN, MERGEABLE
    Uncommitted changes PASS Clean working tree
    Stale worktree PASS 1 commit ahead of main

    Phase 1: CI Status

    Job Status Notes
    build (18.x) FAILURE Lint step — --max-warnings 0 with 5 pre-existing warnings
    build (20.x) CANCELLED Cancelled after 18.x failure
    build (22.x) CANCELLED Cancelled after 18.x failure
    validate-skills SUCCESS
    typecheck SUCCESS
    validate-plugin SUCCESS

    CI Verdict: FAIL — Lint failure on Node 18.x. The 5 warnings are in src/commands/run.ts and src/lib/workflow/batch-executor.ts (unused imports: PhaseResult, determinePhasesForIssue, parseQaVerdict, formatDuration, hasUILabels). These appear to be pre-existing issues not introduced by this PR (only .md files changed), but CI is red nonetheless.


    Phase 2: Code Review

    2a. Scope & Size

    Metric Value Status
    Files changed 2 PASS
    Lines added 195 PASS
    Lines deleted 0 PASS
    Scope .claude/skills/qa/SKILL.md, .claude/skills/exec/SKILL.md only PASS — Matches issue scope

    2b. Type Safety

    N/A — Only markdown files changed.

    2c. Security

    No security concerns — skill markdown documentation only.

    2d. Anti-Pattern Detection

    Issue found: grep commands without || true

    The exec skill's Quick Verification Script (Section 3g) contains grep commands without || true:

    grep -E '^\s+\w+\??: ' src/lib/workflow/batch-executor.ts | head -30
    grep -A 50 'command("run")' bin/cli.ts | grep '\.option(' | head -30

    Per project MEMORY.md: "grep returns exit code 1 on 0 matches, which kills parallel Bash tool calls." All grep commands in SKILL.md code blocks must have || true.

    Severity: Medium — These are instructional code blocks that agents copy-paste into bash calls. Without || true, zero-match scenarios will kill sibling tool calls.

    2e. Template Sync

    Issue found: templates/skills/ not updated

    Changes were made to:

    • .claude/skills/qa/SKILL.md (128 lines added)
    • .claude/skills/exec/SKILL.md (67 lines added)

    But the corresponding template files were NOT updated:

    • templates/skills/qa/SKILL.md — NOT SYNCED
    • templates/skills/exec/SKILL.md — NOT SYNCED

    Per project MEMORY.md: "Skill templates live in both .claude/skills/ and templates/skills/ — fix both or sequant init regenerates the bug."

    Severity: High — sequant init will overwrite the new sections with stale template versions.

    2f. CHANGELOG

    No CHANGELOG entry. Since this modifies skill files (internal tooling, not user-facing code), a CHANGELOG entry is not strictly required but would be nice for traceability.


    Phase 3: QA vs AC

    AC Description Status Evidence
    AC-1 QA skill detects when RunOptions modified in diff MET Section 2g detection script checks batch-executor.ts, run.ts, cli.ts
    AC-2 Verify .option() for runtime mergedOptions.X usage MET Verification logic steps 1-3 cross-reference fields against bin/cli.ts registrations
    AC-3 Missing registrations flagged in QA output MET Output template includes status table with FAIL status and remediation steps
    AC-4 Verdict blocked if verification fails MET Verdict Gating table: Failed → AC_NOT_MET, explicit "CRITICAL" callout
    AC-5 Internal-only fields excluded MET Detection: grep "mergedOptions.$field" returns no matches → internal-only. Examples: autoDetectPhases, worktreeIsolation
    AC-exec Exec skill includes CLI wiring checklist MET Section 3g with step-by-step checklist, key file map, self-check table
    AC-both Both skills reference key file map MET Both sections include identical Key File Map table

    AC Verdict: All acceptance criteria MET.


    Phase 4: Call-Site Review

    N/A — No TypeScript code changes, only skill markdown.

    CLI Registration Verification

    N/A — No option interface changes in this PR.

    Test Coverage

    N/A — No testable code changes. Skill markdown files are validated by validate-skills CI job (PASSED).


    Phase 5: Adversarial Self-Evaluation

    1. Could I have missed a file? No — only 2 files changed, both reviewed. However, the templates/skills/ sync issue was caught.
    2. Are the grep || true issues real? Yes — documented in MEMORY.md as a known pattern that causes agent failures.
    3. Is the CI failure blocking? The lint warnings are pre-existing (not introduced by this PR), but CI is red. This is a judgment call — the PR itself is clean.
    4. Is the spec comment's AC mapping accurate? The exec comment maps AC-1 through AC-5 with line references. Verified against actual diff content — mapping is accurate.

    Verdict

    REVISIONS_NEEDED

    Verdict Algorithm:

    • All ACs met: YES
    • CI green: NO (pre-existing lint warnings, not from this PR)
    • Issues found: YES (2 issues)

    Blocking Issues:

    1. Template sync missing (HIGH) — templates/skills/qa/SKILL.md and templates/skills/exec/SKILL.md must be updated with the same additions. Without this, sequant init will overwrite the changes.
    2. grep || true missing (MEDIUM) — Exec skill Section 3g Quick Verification Script has 2 grep commands without || true safety guards.

    Non-blocking:
    3. CI lint failure is pre-existing (5 unused import warnings in unrelated files). Should be fixed separately but does not block this PR conceptually.

    Remediation:

    1. Copy Section 2g additions from .claude/skills/qa/SKILL.md to templates/skills/qa/SKILL.md
    2. Copy Section 3g additions from .claude/skills/exec/SKILL.md to templates/skills/exec/SKILL.md
    3. Add || true to grep commands in exec skill Section 3g Quick Verification Script
    4. (Optional) Fix pre-existing lint warnings to get CI green
  9. added
    needs-work
    and removed
    planned
    on Mar 12, 2026
  10. admarble commented on Mar 12, 2026

    @admarble
    ContributorAuthor

    RE-QA Review — Issue #307

    PR: #351
    Branch: feature/307-feat-cli-wiring-completeness-qa-verification-exec-
    Commits: e6777ac (feat) + dff4dcf (fix)
    Previous QA: REVISIONS_NEEDED (2 blocking issues)


    Phase 0: Pre-flight

    Check Status Notes
    Worktree found PASS /Users/tony/Projects/worktrees/feature/307-feat-cli-wiring-completeness-qa-verification-exec-
    PR exists PASS PR #351, OPEN, MERGEABLE
    Uncommitted changes PASS Clean working tree
    Branch up to date PASS 2 commits ahead of main

    Phase 1: CI Status

    Job Status Notes
    build (18.x) FAILURE Pre-existing lint warnings (5 unused imports)
    build (20.x) CANCELLED Cascaded from 18.x
    build (22.x) CANCELLED Cascaded from 18.x
    validate-skills SUCCESS
    typecheck SUCCESS
    validate-plugin SUCCESS
    Plugin Installation Test FAILURE Pre-existing hook/marketplace issues

    CI Verdict: FAIL (pre-existing). The 5 lint warnings are in src/commands/run.ts and src/lib/workflow/batch-executor.ts (unused imports: PhaseResult, determinePhasesForIssue, parseQaVerdict, formatDuration, hasUILabels). These exist on main and are NOT introduced by this PR (only .md files changed). Plugin test failures are also pre-existing and unrelated.


    Phase 2: Code Review

    2a. Scope & Size

    Metric Value Status
    Files changed 6 PASS
    Commits 2 PASS
    Scope .claude/skills/{qa,exec}/SKILL.md, templates/skills/{qa,exec}/SKILL.md, skills/{qa,exec}/SKILL.md PASS — Matches issue scope

    2b. Type Safety

    N/A — Only markdown files changed.

    2c. Security

    No security concerns — skill markdown documentation only.

    2d. Anti-Pattern Detection — grep || true

    Previous issue: 2 grep commands without || true in exec skill Section 3g

    RE-QA verification:

    • Line 603: grep -E '^\s+\w+\??: ' src/lib/workflow/batch-executor.ts | head -30 || true — FIXED
    • Line 606: grep -A 50 'command("run")' bin/cli.ts | grep '\.option(' | head -30 || true — FIXED
    • Line 611: grep -q "\-\-$cli_flag" bin/cli.ts && echo "..." || echo "..." — Safe (|| echo handles non-zero)
    • All grep commands in QA skill Section 2g also properly guarded with || true

    Status: RESOLVED

    2e. Template Sync

    Previous issue: Changes only in .claude/skills/, not synced to templates/skills/ or skills/

    RE-QA verification:

    • .claude/skills/exec/SKILL.md == templates/skills/exec/SKILL.md — IDENTICAL (diff empty)
    • .claude/skills/exec/SKILL.md == skills/exec/SKILL.md — IDENTICAL (diff empty)
    • .claude/skills/qa/SKILL.md == templates/skills/qa/SKILL.md — IDENTICAL (diff empty)
    • .claude/skills/qa/SKILL.md == skills/qa/SKILL.md — IDENTICAL (diff empty)

    All 3 directories fully synced for both qa and exec skills.

    Status: RESOLVED

    2f. CHANGELOG

    No CHANGELOG entry. Acceptable for internal skill file changes (not user-facing code).


    Phase 3: AC Verification

    AC Description Status Evidence
    AC-1 QA skill detects when RunOptions modified in diff MET Section 2g detection script checks batch-executor.ts, run.ts, cli.ts (qa/SKILL.md:941-949)
    AC-2 Verify .option() for runtime mergedOptions.X usage MET Verification logic steps 1-3 cross-reference fields against bin/cli.ts registrations (qa/SKILL.md:957-990)
    AC-3 Missing registrations flagged in QA output MET Output template includes status table with FAIL status (qa/SKILL.md:1001-1015)
    AC-4 Verdict blocked if verification fails MET Verdict Gating table: Failed -> AC_NOT_MET, explicit "CRITICAL" callout (qa/SKILL.md:1017-1025)
    AC-5 Internal-only fields excluded MET Detection: grep "mergedOptions.$field" returns no matches -> internal-only (qa/SKILL.md:992-999)
    AC-exec Exec skill includes CLI wiring checklist MET Section 3g with step-by-step checklist, key file map, self-check table (exec/SKILL.md:576-640)
    AC-both Both skills reference key file map MET Both sections include identical Key File Map table

    AC Verdict: All acceptance criteria MET.


    Phase 4: Previous Blocking Issues Resolution

    Issue Severity Status Verification
    Template sync missing HIGH RESOLVED diff confirms all 3 directories identical for both skills
    grep true missing MEDIUM

    Both blocking issues from the previous QA are fully resolved in commit dff4dcf.


    Phase 5: Adversarial Self-Evaluation

    1. Could I have missed a sync issue? No — ran diff on all 6 file pairs (3 dirs x 2 skills). All pairs are identical.
    2. Are there other grep commands without || true? Audited all grep lines in both new sections. All are either guarded with || true, in a pipeline ending with || true, or use the && ... || ... pattern.
    3. Is CI failure blocking? No — lint warnings are pre-existing (5 unused imports in files not modified by this PR). Plugin test failures are also pre-existing infrastructure issues.
    4. Are all ACs testable? Yes — Section 2g provides concrete detection scripts, verification logic, and output templates. Section 3g provides actionable checklists.

    Verdict

    READY_FOR_MERGE

    Verdict Algorithm:

    • All ACs met: YES (7/7)
    • Previous blocking issues resolved: YES (2/2)
    • CI green: NO (pre-existing, not introduced by this PR)
    • New issues found: NONE
    • Template sync: VERIFIED (all 3 directories identical)
    • grep safety: VERIFIED (all commands guarded)

    Note: CI lint failures are pre-existing unused import warnings in src/commands/run.ts and src/lib/workflow/batch-executor.ts. These should be cleaned up in a separate PR but do not block this change (only .md files modified).

  11. added
    ready-for-review
    and removed
    needs-work
    on Mar 12, 2026
  12. added 2 commits that reference this issue on Mar 12, 2026
  13. admarble commented on Mar 12, 2026

    @admarble
    ContributorAuthor

    Documentation Review Complete

    This issue contains documentation-only changes. No additional documentation generation required.

    Files Modified:

    • .claude/skills/exec/SKILL.md — Added Section 3g: CLI Wiring Checklist
    • .claude/skills/qa/SKILL.md — Added Section 2g: CLI Registration Verification
    • skills/exec/SKILL.md — Mirror of exec skill update
    • skills/qa/SKILL.md — Mirror of QA skill update
    • templates/skills/exec/SKILL.md — Template mirror of exec skill update
    • templates/skills/qa/SKILL.md — Template mirror of QA skill update

    What Was Built:

    • QA skill (Section 2g): Detects new option interface fields with runtime usage but missing CLI flag registration; gates verdict so READY_FOR_MERGE is blocked on failures.
    • Exec skill (Section 3g): Proactive CLI wiring checklist with key file map and quick verification script, triggered when option interfaces are modified.
    • Both sections reference the fix: pre-flight state guard and worktree lifecycle management #305 incident as origin and exclude internal-only fields from checks.

    Status:

    Documentation changes are ready for review and merge.


    Ready to merge!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementready-for-review

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions