Skip to content

bug(skills): potential silent misroute when unqualified Skill("security-review") added — mirrors #562 #568

Closed

Description

@admarble

Summary

Pre-emptive issue, not an active bug. Filed as the follow-up promised in #562's Non-Goals: "Not auditing other sequant skills for similar unqualified Skill() calls. If any exist that hit collisions, file separately."

#562 fixed the silent-misroute pattern for loop. The same structural collision exists for security-review:

  • Anthropic ships a top-level security-review skill (built-in, ships with Claude Code): "Complete a security review of the pending changes on the current branch".
  • Sequant ships sequant:security-review: "Deep security analysis for sensitive features (auth, payments, admin, API routes, file operations)".

Both are visible at the top level. Per #562's empirical observation, when both are present the bare name resolves to Anthropic's. So Skill(skill: \"security-review\", args: ...) from any sequant skill would silently invoke Anthropic's review instead of sequant's.

No Active Bug Today

Verified across the entire repo:

```
$ grep -rn 'Skill(skill: "security-review"' . --include='*.md' | grep -v node_modules | grep -v '.git/'
(no matches)
```

No sequant skill currently calls Skill(skill: \"security-review\", ...). The same is true for the other Anthropic top-level names (init, review, simplify, etc.). Only loop had active call sites — those got fixed in #562 / #565.

Why File This Now

The bug surfaces only at runtime, only when an affected branch fires. It's invisible to TypeScript, build, lint, and unit tests (per #562). Adding a Skill(skill: \"security-review\", ...) call months from now without remembering this footgun will reproduce the same silent misroute.

Acceptance Criteria

  • AC-1: Defensive guard. Pick ONE of:
    • (a) Pre-emptively qualify all future calls. Add a memory/CLAUDE.md note instructing skill authors to always use Skill(skill: \"sequant:<name>\", ...) when invoking sequant skills, regardless of whether the bare name collides today.
    • (b) Lint check. Add a script (e.g., scripts/lint-skill-calls.ts) that scans all */SKILL.md files for Skill(skill: \"<name>\", ...) patterns where <name> matches a known Anthropic top-level skill (loop, security-review, init, review, simplify, setup, schedule, etc.) and flags as a CI failure.
    • (c) Both. Belt-and-suspenders.
  • AC-2: If (a), update CLAUDE.md / memory; if (b), wire script into a CI step (validate-skills or new); if (c), do both.
  • AC-3: Document the chosen approach in the PR body, citing bug(fullsolve): unqualified Skill("loop") resolves to recurring-prompt skill, breaking quality loop #562 as the precedent.

Non-Goals

  • Not changing how the Skill tool resolves names — harness behavior, out of scope.
  • Not auditing skill-name collisions in other plugins — sequant-only.

Complexity

trivial-to-small — depends on which AC-1 option is chosen. (a) is doc-only. (b) is a small script + CI wiring (~50–100 LOC). (c) is both.

Self-Assessed Workflow

spec → exec → qa — non-trivial design choice (which option), so spec is warranted.

Related

Activity

  1. added
    bug
    on May 3, 2026
  2. admarble commented on May 4, 2026

    @admarble
    ContributorAuthor

    Assessment

    → PROCEED — Defensive guard mirroring #562 pattern; spec needs to pick AC-1 option (a/b/c)

    Workflow: spec → exec → qa

    npx sequant run 568
    

    ⚠ AC-1 offers 3 options (doc-only / lint script / both) — spec must choose before exec

  3. admarble commented on May 6, 2026

    @admarble
    ContributorAuthor

    Plan Complete (/spec)

    Complexity: Standard (3 ACs, ~3 directories)

    AC Checklist (verified zero current violations across .claude/skills/, templates/skills/, skills/)

    Implementation Plan

    Phase 1 — Lint script: Create scripts/lint-skill-calls.ts (~80–120 LOC). Hardcoded ANTHROPIC_TOP_LEVEL_NAMES = ["loop", "security-review", "init", "review", "simplify", "schedule", "release"]. Walks all three skill mirror dirs for **/SKILL.md, per-line regex /Skill\(skill:\s*"(?!sequant:)([a-z-]+)"/g, flags any captured name in the list, exits 1 on violations. Mirrors style of scripts/check-skill-sync.ts.

    Phase 2 — Test: scripts/lint-skill-calls.test.ts (vitest, fixture-based). Cases: unqualified colliding name flagged; sequant:loop ignored; non-colliding spec ignored; clean repo → exit 0.

    Phase 3 — CI + package wiring: Add "lint:skill-calls" script entry to package.json. Append a Lint skill calls step inside the existing validate-skills job in .github/workflows/ci.yml.

    Phase 4 — Docs: One-paragraph note in CLAUDE.md pointing at the lint script and citing #562/#568. CHANGELOG entry under [Unreleased] / ### Added.

    Key Decisions

    • Recommend (b) lint + small CLAUDE.md hint rather than (a)-only or full requalification across all skills. bug(fullsolve): unqualified Skill("loop") resolves to recurring-prompt skill, breaking quality loop #562 AC-3 explicitly forbids defensive requalification of non-colliding names; the load-bearing guard is the lint, the CLAUDE.md note is supporting prose.
    • Extend existing validate-skills job (no new CI job) to keep skill-related guards co-located.
    • Hardcoded Anthropic name list with comment pointing to user memory + session available-skills reminder. Drift detection is out of scope (one-line const edit if Anthropic adds more).

    Design Review (Q1/Q3)

    • Q1 (where does this belong?): Standalone scripts/lint-skill-calls.ts parallel to scripts/check-skill-sync.ts. CI-time guard, not runtime, so not under src/.
    • Q3 (what existing pattern?): check-skill-sync.ts + validate-skills CI job — same shape (walk dirs, regex check, exit code).

    Open Questions

    1. AC-1 choice? → Recommend (b) lint + thin CLAUDE.md note. Falls back to pure (b) if reviewer rejects the doc note.
    2. HTML-comment escape hatch for legitimate doc-pattern false positives? → Defer until needed.

    Recommended Workflow

    spec → testgen → exec → qa — quality loop disabled. ACs include Unit/Integration Test verification methods, so testgen is recommended to stub the script's test cases before implementation.

  4. added
    planned
    on May 6, 2026
  5. admarble commented on May 6, 2026

    @admarble
    ContributorAuthor

    Implementation Complete (/exec)

    PR: #590 — #590
    Branch: feature/568-bug-skills-potential-silent-misroute-when-unqu

    Pre-PR AC Verification

    AC Source Description Status Evidence
    AC-1 Original Defensive guard (lint + light doc note) ✅ Implemented scripts/lint-skill-calls.ts, CLAUDE.md ## Skills
    AC-2 Original Wire chosen approach into CI ✅ Implemented Lint skill calls step in validate-skills job, npm run lint:skill-calls
    AC-3 Original PR body documents approach + cites #562 ✅ Implemented PR #590 description

    Key Files Changed

    • scripts/lint-skill-calls.ts (new, ~120 LOC) — ANTHROPIC_TOP_LEVEL_NAMES const + findViolations() + lintSkillCalls() + CLI wrapper
    • scripts/lint-skill-calls.test.ts (new, 10 vitest cases)
    • .github/workflows/ci.yml — new Lint skill calls step in validate-skills job
    • package.json — lint:skill-calls script
    • CLAUDE.md — new ## Skills paragraph
    • CHANGELOG.md — [Unreleased] / ### Added entry

    Quality Plan Alignment

    N/A — no formal quality plan was generated by /spec; the spec output's "Feature Quality Planning" section flagged only false-positive risk (mitigated via YAGNI defer) and cross-platform/three-mirror concerns, both addressed.

    Verification

    Check Result
    npm run build (tsc) ✅ Clean
    npm run lint (eslint) ✅ Clean
    npx vitest run scripts/lint-skill-calls.test.ts ✅ 10/10 in 2.27s
    npm run lint:skill-calls (smoke against live repo, 51 SKILL.md files) ✅ exit 0, no violations

    Pre-PR Confidence Check

    • Weakest part: The hardcoded ANTHROPIC_TOP_LEVEL_NAMES list is a manually-maintained snapshot. If Anthropic ships a new top-level skill that collides with a future sequant skill, the list won't auto-detect it. Mitigation: the upstream skill's release-monitoring flow surfaces new Anthropic skills; the list is a one-line const edit when needed. Documented inline.
    • Coverage gaps: scripts/lint-skill-calls.ts has full unit + filesystem coverage in lint-skill-calls.test.ts (10 cases including every name in the catalog, the qualified-form ignore path, multi-line position tracking, scan-only-SKILL.md filtering, and empty-tree handling). The CLI wrapper's exit-code path is not directly unit-tested but is exercised by the live smoke run reported above. Acceptable: the wrapper is 4 lines and trivially auditable.
  6. admarble commented on May 6, 2026

    @admarble
    ContributorAuthor

    QA Review for Issue #568

    AC Coverage

    AC Source Description Status Notes
    AC-1 Original Defensive guard (lint check + light doc note, effectively option (c)) ✅ MET scripts/lint-skill-calls.ts exports findViolations() + lintSkillCalls(), walks .claude/skills, templates/skills, skills for **/SKILL.md, flags any Skill(skill: "<name>", ...) whose <name> ∈ ANTHROPIC_TOP_LEVEL_NAMES and isn't sequant:-prefixed. Exit 1 on violations, with file:line + offending snippet. CLAUDE.md ## Skills paragraph added.
    AC-2 Original Wire chosen approach into CI ✅ MET New Lint skill calls step appended to existing validate-skills job in .github/workflows/ci.yml. npm run lint:skill-calls exposed locally. CI run on this PR's validate-skills job ran the new step and passed.
    AC-3 Original PR body documents approach + cites #562 ✅ MET PR #590 description names the chosen option (effectively (c)), justifies why over (a) alone (per memory + #562 AC-3), explains the hardcoded names list, and cites #562 / #565 as precedent.

    Coverage: 3/3 AC items fully met
    Original ACs: 3/3 met
    Derived ACs: None (no formal Derived AC table in spec)


    Quality Plan Verification

    N/A — /spec did not emit a formal Feature Quality Planning section. Standard QA only.


    CI Status

    Check State Bucket Impact
    validate-skills SUCCESS pass ✅ MET (runs new Lint skill calls step)
    build (20.x) SUCCESS pass ✅ MET
    build (22.x) SUCCESS pass ✅ MET
    typecheck SUCCESS pass ✅ MET
    validate-plugin SUCCESS pass ✅ MET

    CI Summary: 5 passed, 0 pending, 0 failed.
    CI-related: AC-2 (CI wiring) is empirically verified — the new step ran in CI and passed.


    Quality Metrics

    Metric Value Status
    Type issues (any) in diff 0 ✅ OK
    Deleted tests 0 ✅ OK
    Files changed 6 ✅ OK
    Lines added +312 -
    Lines deleted -0 -

    Test Coverage Analysis

    Changed File Tier Has Tests? Test File
    scripts/lint-skill-calls.ts Standard ✅ Yes scripts/lint-skill-calls.test.ts (10 cases)

    Coverage: 1/1 new source files have tests.
    Critical paths without tests: None.

    Test file covers: every name in ANTHROPIC_TOP_LEVEL_NAMES flagged; sequant:-qualified ignored; non-colliding bare names ignored; line-number tracking; multiple violations in one file; whitespace-tolerant regex; clean tree; violation in any of three mirror dirs; SKILL.md-only filtering; empty-tree (scanned=0).


    Code Review

    Strengths:

    • Clean three-function decomposition (findViolations per content, walkSkillFiles per dir, lintSkillCalls orchestrator) makes the script trivially unit-testable without subprocesses.
    • ANTHROPIC_TOP_LEVEL_NAMES is exported, so the test iterates the catalog (catches drift if a name is removed).
    • isDirectRun guard (process.argv[1] && fileURLToPath(import.meta.url) === process.argv[1]) prevents the CLI side effects (printReport + process.exit) from firing when imported by the test, which is why tests can run cleanly without mocking process.
    • Mirrors scripts/check-skill-sync.ts style end-to-end (fileURLToPath(import.meta.url), __dirname, PROJECT_ROOT = join(__dirname, ".."), process.exit(...)).
    • name.startsWith("sequant:") skip is explicit and conservative — avoids false-flagging the legitimate qualified form.
    • Regex /Skill\(\s*skill:\s*"([^"]+)"/g is intentionally narrow: tolerates whitespace variants but requires the exact skill: keyword and double-quoted string. Test covers the whitespace case.
    • The __dirname symbol is reused for PROJECT_ROOT, matching check-skill-sync.ts. (__filename is declared but only used as the input to fileURLToPath-derived __dirname — same shape as the sibling script. scripts/ is excluded from npm run lint's eslint scope, so this isn't a lint regression.)

    Issues: None blocking.

    Suggestions (non-blocking):

    • The doc-comment line Exit codes: 1 - Violations found (or invalid args) mentions arg validation that the script doesn't actually do (no args are accepted). Minor cosmetic; not worth a follow-up commit.
    • The regex doesn't match Skill(skill: 'loop', ...) (single-quoted name). Acceptable today: every existing Skill(skill: ...) call in the repo's SKILL.md tree uses double quotes, and the issue body's verbatim grep pattern uses double quotes. If a single-quoted variant ever appears, the regex can be extended; not worth pre-emptive complexity.

    Test Quality Review

    Category Status Notes
    Behavior vs Implementation ✅ OK Tests assert on findViolations() / lintSkillCalls() outputs (counts, names, line numbers, file paths) — not on internals.
    Coverage Depth ✅ OK Both happy path (clean tree) and unhappy path (violation in each mirror dir) covered, plus boundary cases (empty tree, README.md filter).
    Mock Hygiene ✅ OK No mocks. Filesystem tests use a real mkdtempSync per case with afterEach cleanup — no shared state.
    Test Reliability ✅ OK Deterministic — no timing, no network, no env dependencies. Per-case temp dirs prevent cross-test contamination.

    Issues Found: None.


    Anti-Pattern Detection

    Dependency Audit

    N/A — package.json was modified only to add a script entry (lint:skill-calls). No dependencies/devDependencies changes.

    Code Patterns

    File:Line Category Pattern Suggestion
    (none) - - -

    Critical Issues: 0
    Warnings: 0


    Call-Site Review

    N/A — the new exported functions (findViolations, lintSkillCalls, ANTHROPIC_TOP_LEVEL_NAMES) are call-only from scripts/lint-skill-calls.test.ts (verified via test-suite pass). The CLI wrapper at the bottom of lint-skill-calls.ts is the sole runtime caller and is gated by isDirectRun so it doesn't fire under test imports. No misalignment with AC.


    Execution Evidence

    Test Type Command Exit Code Result
    Smoke (clean tree, live repo) npm run lint:skill-calls 0 "Files scanned: 51 / No violations."
    Negative (inject violation) printf '\nSkill(skill: "loop", args: "x")\n' >> qa/SKILL.md && npm run lint:skill-calls 1 Reported .claude/skills/qa/SKILL.md:2909: Skill(skill: "loop") collides ... — qualify as "sequant:loop" then Found 1 violation(s). Restored file → exit 0 again.
    Unit + filesystem npx vitest run scripts/lint-skill-calls.test.ts 0 10/10 passed in 3.14s.
    CI (the new step in validate-skills) GitHub Actions 0 validate-skills job passed.

    Evidence status: Complete.


    Skill Command Verification

    N/A — no .claude/skills/**/*.md, templates/skills/**/*.md, or skills/**/*.md files modified.


    Detection Pattern Verification

    N/A — no skill markdown files were modified, so no grep/awk/jq/sed or regex literals inside skill prose were added or changed. The regex in scripts/lint-skill-calls.ts is TypeScript code (covered by the unit tests), not skill prose.


    CLI Registration Verification

    N/A — RunOptions and bin/cli.ts were not modified. The new lint:skill-calls is a top-level npm script invocation, not a sequant CLI subcommand.


    Smoke Test

    Test Command Result Notes
    Happy path npm run lint:skill-calls (clean tree) ✅ exit 0 51 files scanned, no violations
    Edge case (negative) Inject Skill(skill: "loop", ...) then re-run ✅ exit 1 Correct file:line reported, fix recommendation in output
    Recovery Revert file, re-run ✅ exit 0 Clean again, confirming no state leakage
    CI integration validate-skills GitHub Actions job ✅ pass New step appended to existing job runs npm run lint:skill-calls and exits 0

    Smoke Test Status: Complete.


    Manual Test ACs

    N/A — no ACs in the spec plan use Manual Test verification. AC-1 → Integration Test (covered by unit/filesystem tests + live smoke). AC-2 → Integration Test (covered by CI run on this PR). AC-3 → PR body review (this comment + PR #590 description).


    CHANGELOG Verification

    Check Status
    CHANGELOG.md exists ✅ Found
    User-facing changes ✅ Yes (developer-facing CI guard)
    [Unreleased] entry ✅ Present (under ### Added, top of section)
    Entry format ✅ Valid (action verb implicit via "lint:skill-calls CI guard …", includes (#568))

    Result: CHANGELOG requirements met.


    Risk Assessment

    • Likely failure mode: A future contributor adds a Skill(skill: "<colliding>", ...) call from a script that uses single quotes (') instead of double quotes — the lint would silently miss it. Same failure mode applies if Anthropic ships a new top-level skill (e.g. assess) and a sequant skill of the same name pre-dates the manual update of ANTHROPIC_TOP_LEVEL_NAMES. Both are acceptable: single-quoted invocations are not the convention in this repo, and Anthropic-skill drift is monitored by /upstream.
    • Not tested: No coverage for single-quoted skill names (intentional — not a real pattern in-repo). The CLI wrapper's exit-code + printReport formatting paths are not asserted by unit tests; live smoke covers them and the wrapper is 4 lines (if (isDirectRun) { … process.exit(...) }), trivially auditable.
    • Sibling sites considered: N/A — sibling-site scan does not apply. The change introduces a brand-new file (scripts/lint-skill-calls.ts) with no in-tree siblings sharing the same root cause; the closest pattern peer is scripts/check-skill-sync.ts, which addresses a different concern (file-content sync, not Skill-call shape). The single-pattern criterion is satisfied.

    Adversarial Re-Read

    # Sub-prompt Finding
    1 Verbatim fixtures The issue body's only verbatim payload is the shell snippet $ grep -rn 'Skill(skill: "security-review"' . --include='*.md' | grep -v node_modules | grep -v '\.git/' returning (no matches). Re-ran the exact pattern against the worktree: 0 matches across .claude/skills/, templates/skills/, skills/. The lint script's behavior on this corpus matches the issue's claim of zero current violations (Files scanned: 51, no violations). Fixture verified.
    2 Evidence framing Two evidence claims to scrutinize. (a) "Negative case confirmed" by injecting Skill(skill: "loop", args: "x") and observing exit 1 at line 2909 — this is post-fix validation of the new lint, not a pre-fix bug repro. Correctly framed. (b) "validate-skills CI job passed running the new step" — also post-fix validation; the CI checkpoint in this PR exercises the new step. Correctly framed. No bug-repro/validation conflation.
    3 Process state Worktree clean post-revert (git status --short showed only the staged/committed diff before commit; HEAD is 7b27afb; no stash; on feature/568-…, not main). The negative-case smoke modified .claude/skills/qa/SKILL.md and reverted via backup file, leaving zero residual changes.
    4 Sibling sites Per Section 5: N/A — single-pattern file (a brand-new script). The validate-skills CI job already had two steps (Validate all skills, now Lint skill calls); both delegate to disjoint mechanisms. Nothing else in .github/workflows/ mirrors this concern.
    5 Out-of-scope/Non-Goals Issue Non-Goals: (i) Not changing how the harness resolves Skill() names — confirmed, harness behavior untouched; the lint is a static guard, not a runtime intercept. (ii) Not auditing collisions in other plugins — confirmed, SCAN_DIRS is hardcoded to sequant's three skill mirror dirs. Neither boundary was crossed. The ANTHROPIC_TOP_LEVEL_NAMES list is bounded to known top-level names that collide with sequant skills today.

    Findings: No gaps found because: (a) the issue's verbatim grep fixture was re-run and matched the pre-fix expected zero-match outcome that the lint preserves on the post-fix tree; (b) every "evidence" claim above is post-fix validation, not pre-fix repro; (c) the working tree is clean post-revert; (d) no sibling pattern exists in the same module/file; (e) Non-Goals were respected.

    Status: Clean.


    Verdict: READY_FOR_MERGE

    All three ACs are MET literally (not just in spirit):

    Quality gates: build ✅, lint ✅, unit tests ✅ (10/10), CI ✅ (5/5), smoke positive + negative + recovery ✅, CHANGELOG ✅, CLAUDE.md note ✅. No anti-patterns; no test-coverage gaps; no AC literal-text divergence; Adversarial Re-Read clean; Non-Goals respected.

    Documentation

    Next Steps

    1. Merge PR feat(#568): lint:skill-calls CI guard for unqualified Skill() collisions #590 once review is complete.
    2. After merge, the validate-skills job on every future PR will run npm run lint:skill-calls automatically — no further action needed.
    3. If Anthropic ships a new top-level skill that collides with a sequant skill, add the name to ANTHROPIC_TOP_LEVEL_NAMES in scripts/lint-skill-calls.ts (one-line const edit).
  7. added a commit that references this issue on May 7, 2026
  8. admarble commented on May 7, 2026

    @admarble
    ContributorAuthor

    QA Follow-up (post-adversarial)

    After the structured QA pass returned READY_FOR_MERGE, an adversarial re-read prompted by the user surfaced four gaps. Pushed b80f85c on top of 7b27afb to fix all four in this PR rather than spawning follow-up issues.

    Gaps Closed

    1. Multi-line Skill() false negative. The regex \s* already matched newlines, but findViolations was iterating content.split("\n") per-line, so Skill(\n skill: "loop", ...\n) escaped the lint. Verified locally with a fixture: the per-line walker found 1/2 calls (only the single-line one). Fix: run the regex against the full file content; derive line numbers from match.index. Two new tests pin the behavior (one violation, one qualified-OK).

    2. Markdown scope too narrow. walkSkillFiles filtered entry === "SKILL.md" only, but the harness loads referenced markdown (references/*.md, _shared/*.md, prompt-templates.md, etc.) alongside SKILL.md, and a Skill() call in any of those is equally runtime-dangerous. The issue body's verbatim grep used --include='*.md' (broader than my implementation). Fix: broaden to entry.endsWith(".md"). Live scan went from 51 → 100 files; still 0 violations across all colliding names.

    3. ANTHROPIC_TOP_LEVEL_NAMES drift. Cross-checked against this session's available-skills block:

      • Removed release — Anthropic no longer ships a top-level release; sequant ships sequant:release, so flagging bare Skill(skill: "release", ...) would produce false positives with broken advice.
      • Added claude-api, update-config, keybindings-help, fewer-permission-prompts — all currently registered Anthropic top-level skills. Defensive coverage against a future sequant skill collision.
      • Kept: loop, security-review, init, review, simplify, schedule.
    4. Doc-comment nit. Removed the spurious "(or invalid args)" exit-1 case from the script header — the script accepts no args.

    Verification

    • npx vitest run scripts/lint-skill-calls.test.ts → 13/13 passed (was 10/10).
    • npm run lint:skill-calls → 0 violations across 100 .md files.
    • Multi-line negative smoke (inject Skill(\n skill: "loop", ...\n) into a SKILL.md): exit 1, file:line reported correctly, revert → exit 0.
    • npm run build, npm run lint → green.

    Adversarial Re-Read (after fix)

    Status: Clean. The 4 gaps were the surface area; verbatim issue-body grep still produces 0 matches; multi-line and broadened-md scope are now empirically covered; names list matches the current harness output.

    Verdict: Still READY_FOR_MERGE, with the gap fixes folded into the PR.

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

    bugplanned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions