Skip to content

fix(skills): narrow broad allowed-tools grants — bare Bash, Bash(*), and runner wildcards hold the directory listing for review #1287

Closed

Description

@admarble

Tier: judgment Found: 2026-10-02, plugin directory submission (path plugin). The portal's policy-review hold "Pre-approves broad shell access in allowed-tools" covers 9 findings.

Problem. While a skill is active, its allowed-tools entries let Claude Code run matching commands without asking. The directory holds a plugin for review when an entry is bare Bash, Bash(*), or a wildcard directly after a shell, interpreter, package manager or runner, and asks for "the exact commands the component needs, or remove it". From plugin/skills/*/SKILL.md on main:

  • Bare Bash: fullsolve, loop, test
  • Bash(*): verify
  • Wildcard after the tool: improve (Bash(gh *), Bash(git *), Bash(npm run *), Bash(npx *)) and upstream (Bash(gh *), Bash(git *))
  • Runner wildcards:
    • exec: Bash(npm install:*), Bash(npx tsc:*)
    • qa: Bash(npx semgrep:*), Bash(npx tsx scripts/semgrep-scan.ts:*), Bash(npx sequant worktree:*)
    • setup: Bash(node -e:*)
    • test: Bash(npx tsx:*)
  • Unrendered placeholder: test ships Bash({{PM_RUN}} dev:*). plugin/skills/ is copied from templates/ without placeholder rendering, so the entry never matches anything.
  • Related notes: "Allowed tools unscoped write" (9: bare Write/Edit) and "Allowed tools skill any" (fullsolve: bare Skill).

Who it affects. Phases started by sequant run use permissionMode: "bypassPermissions" (src/lib/workflow/drivers/claude-code.ts:137), so narrowing these entries changes interactive use only. Users running /fullsolve, /verify etc. by hand will get permission prompts for commands that ran silently before. That's a product trade-off, so it's judgment tier.

AC

  • AC-1: No plugin/skills/*/SKILL.md allowed-tools entry is bare Bash, Bash(*), or Bash(<tool> *) for gh/git/npm run/npx. Each is replaced by the specific subcommands that skill's body runs, or removed. Evidence: a gate test over the frontmatter of all three skill copies, mutation-verified by re-adding Bash to one skill
  • AC-2: Runner wildcards (npx …:*, npm install:*, node -e:*) are narrowed to the exact invocation the skill uses, or removed where the skill body doesn't run them. Evidence: the AC-1 gate test also rejects npx [^ ]+:\*, node -e:\* and npm install:\*
  • AC-3: test's Bash({{PM_RUN}} dev:*) becomes an entry that works unrendered (for example Bash(npm run dev:*), Bash(pnpm dev:*), Bash(yarn dev:*)), or is removed. Evidence: grep -n '{{' plugin/skills/*/SKILL.md finds nothing in any allowed-tools block
  • AC-4: Bare Write/Edit/Skill grants are scoped to the paths or skills each skill writes or starts, or kept with a one-line reason in the PR. Evidence: PR body table, one row per skill
  • AC-5: Interactive smoke: /verify and /fullsolve on a scratch issue still complete; any new prompts are listed in the PR. Evidence: the PR body
  • AC-6: (human-required) The directory portal's Validate on the PR branch (path plugin) no longer lists "Pre-approves broad shell access in allowed-tools". Evidence: portal result pasted in the PR

Non-Goals

  • Changing headless phase permissions (bypassPermissions).

May touch

  • templates/skills/*/SKILL.md, .claude/skills/*/SKILL.md, skills/*/SKILL.md, plugin/skills/*/SKILL.md (via sync), a frontmatter gate test

Activity

  1. added
    enhancement
    on Oct 3, 2026
  2. admarble commented on Oct 3, 2026

    @admarble
    ContributorAuthor

    Runner context (2026-10-03) — read before exec

    • Edit .claude/skills/*/SKILL.md only, then run npm run sync:skills. .claude/skills is the canonical copy (scripts/check-skill-sync.ts:8), and that one command writes the other three mirrors from it: templates/skills/, skills/ and plugin/skills/. If you edit templates/ first, the sync silently reverts it. There are four copies, not three. AC-1's gate test should iterate all four roots. Copy the SKILL_ROOTS + it.each pattern from src/lib/__tests__/fullsolve-merge-gate-skill.test.ts:138, which already asserts over the allowed-tools frontmatter.
    • Producers: the allowed-tools frontmatter has one source (.claude/skills/) and one copier (sync:skills). Nothing in src/ reads or writes it. Its only test readers are the fix(fullsolve): Phase 5.3 auto-merges the PR — the skill's own stop-list says to halt at the final summary #958 merge-gate test and this new gate. When you narrow fullsolve, keep fullsolve-merge-gate-skill.test.ts green. Its "other gh pr entries are untouched" case pins specific gh pr grants.
    • Narrow the grants to what the body runs. For each skill, grep that skill's body for the commands it invokes before you write its grant list. Don't guess.
    • Scope the gate test to the frontmatter block (between the first two --- lines), not the whole file. Mutation-verify it by re-adding bare Bash to one .claude/skills copy, re-syncing, and confirming exactly that test fails, then restore. The SEQUANT_MUTATION marker's failedTest must start with the test file path.
    • AC-5 and AC-6 are outside the phase agents' reach. Phases run under bypassPermissions, so they can't observe permission prompts. The runner does the AC-5 interactive smoke after exec, and the owner runs AC-6 (portal Validate). QA: mark both as pending-runner and pending-owner. Don't mark them met.
    • exec and qa phases: do not run the full npm test. Run only the targeted files (npx vitest run <new gate test> src/lib/__tests__/fullsolve-merge-gate-skill.test.ts, npm run lint:skill-sync, npm run lint:skill-calls), in the foreground. CI runs the full suite.
  3. admarble commented on Oct 3, 2026

    @admarble
    ContributorAuthor

    Complexity: Standard (6 ACs, 2 directories: .claude/skills/ (+3 synced mirrors), src/lib/__tests__/)

    AC Quality Check

    All six ACs parse, and each has an Evidence: clause. AC-1–3 → integration_test; AC-4–6 → manual.

    • AC-3: the linter flags "for example" as open-ended. Its evidence (grep -n '{{' plugin/skills/*/SKILL.md) also matches body text today, for example test's {{DEV_URL}} at line 237. Resolution: fold AC-3 into the frontmatter gate test, so it asserts that no allowed-tools block contains {{.
    • AC-2's evidence regex is too narrow. npx [^ ]+:\* fails on main today, so it is not vacuous. But it misses two entries the issue names itself: npx sequant worktree:* and npx tsx scripts/semgrep-scan.ts:*. Both have a space before :*. See Design Review Q4 for the stricter rule.
    • AC-1 says "all three skill copies". There are four roots: .claude/skills (canonical), templates/skills, skills, plugin/skills. The gate iterates all four.

    Scope Assessment

    Non-Goals: headless bypassPermissions stays unchanged.

    Metric Value Status
    Feature count 1 (frontmatter policy + gate) ✅
    AC items 6 (2 out-of-phase: AC-5 runner, AC-6 owner) ✅
    Directory spread 2 (+ sync) ✅

    Verdict: ✅ SCOPE_OK

    The issue's inventory is incomplete (literal AC-1 scope)

    The issue's list follows the portal's 9 findings. On main, these entries also break AC-1/AC-2 as written, so the gate fails unless they are narrowed too:

    • assess and solve: Bash(git *), Bash(gh *)
    • upstream: also Bash(npx tsx *), Bash(jq *), Bash(base64 *)
    • merger: Bash(git:*), Bash(gh pr:*), Bash(gh issue:*). git:* has the same semantics as git *, so the gate normalizes X:* ≡ X *.
    • npx sequant worktree:* also appears in assess, loop, merger and testgen, not only qa. Skill bodies run only its resolve and verify subcommands.

    Grants with no body use (AC-2: remove them):

    • exec's npx tsc:*
    • qa's npx semgrep:* and npx tsx scripts/semgrep-scan.ts:*
    • upstream's npx tsx *

    Grep confirms that none of these appears outside the frontmatter. Exec should re-check each skill's references/ before removing anything.

    Acceptance Criteria

    AC-1: no bare Bash, Bash(*) or Bash(<gh|git|npm run|npx> *|:*) in any root

    Verification: Integration Test (file-reading gate)
    Scenario: Given the frontmatter of every */SKILL.md in all 4 roots → When the gate parses each allowed-tools list → Then no entry matches the broad forms. Mutation: add bare Bash to one .claude/skills copy, run npm run sync:skills, and confirm exactly the gate fails.
    Assumptions: the frontmatter is the span between the first two --- lines.

    AC-2: runner wildcards narrowed or removed

    Verification: Integration Test (same gate)
    Scenario: Given an entry starting npx/node -e/npm install/tsx that ends in * → Then it fails unless listed in the gate's explicit allowlist, where each allowlisted entry carries a one-line reason.

    AC-3: no {{…}} placeholder in any allowed-tools block

    Verification: Integration Test (same gate, scoped to the frontmatter)

    AC-4: bare Write/Edit/Skill scoped or justified

    Verification: Manual (a PR-body table with one row per skill)

    AC-5: interactive /verify + /fullsolve smoke

    Verification: Manual — pending-runner. Phases run under bypassPermissions and can't observe prompts.

    AC-6: portal Validate no longer lists the hold

    Verification: Manual — pending-owner.

    Implementation Plan

    Phase 1: Inventory (per skill, before any edit)

    1. For each skill in the list below, grep the body and references/ for every command it runs. Record a grant list. Don't guess.
      • Skills: fullsolve, loop, test, verify, improve, upstream, assess, solve, merger, exec, qa, setup, testgen
    2. Check the vendor docs or CLI tarball for whether Skill(<name>) and path-scoped Write(...)/Edit(...) rules are supported. Record what you find; AC-4 depends on it.

    Phase 2: Narrow .claude/skills/*/SKILL.md frontmatter only

    1. Bare Bash / Bash(*) → the explicit subcommand grants the body runs. Applies to fullsolve, loop, test and verify. verify runs arbitrary user commands, so those now prompt. That is the intended trade-off; list it under AC-5.
    2. Bash(gh *) / Bash(git *) / Bash(git:*) / Bash(npm run *) / Bash(npx *) → per-subcommand grants (gh issue view:*, git diff:*, …). Applies to improve, upstream, assess, solve and merger.
    3. Runner entries:
      • npx sequant worktree:* → npx sequant worktree resolve:* + npx sequant worktree verify:*. These go on the gate allowlist, with the reason: the issue number varies.
      • Remove the entries with no body use (listed above).
      • setup's node -e:* → the exact script the body runs, or remove it.
      • exec's npm install:* → Bash(npm install) (no args) or Bash(npm ci), whichever the body runs.
      • test's npx tsx:* → npx tsx scripts/seed-test- is a variable path, so remove it.
    4. test: replace {{PM_RUN}} dev:* with literal entries: npm run dev:*, pnpm dev:*, pnpm run dev:*, yarn dev:*, bun run dev:*. Leave the body's {{PM_RUN}} alone. init.ts:969 still renders it for consumers.
    5. Run npm run sync:skills. Never edit templates/ first: the sync reverts it.

    Phase 3: Gate + docs

    1. Add src/lib/__tests__/skill-allowed-tools-gate.test.ts.
      • Copy SKILL_ROOTS and it.each from fullsolve-merge-gate-skill.test.ts, then add plugin/skills. The existing test omits that root.
      • Parse each frontmatter allowed-tools list and strip # comments.
      • Assert: AC-1 forms (normalizing :* ≡ *), AC-2 runner rule + allowlist, AC-3 no {{.
      • Add a sanity check: ≥20 skills parsed per root, so an empty glob can't pass.
    2. Update docs/reference/permissions.md. Its skill-frontmatter section says allowed-tools "restrict" tools, but they pre-approve. Add one line on the narrowing policy.
    3. Mutation-verify and record the SEQUANT_MUTATION marker. failedTest must start with the test file path.

    Design Review

    1. Where does this logic belong? Skill frontmatter in .claude/skills/ (the one source), plus a test-only gate. Nothing in src/ reads allowed-tools.
    2. What's the simplest correct approach? Hand-narrow each list from the body's commands, plus one data-driven gate.
      • Rejected: generating grants from bash blocks. The blocks are prose-embedded and full of placeholders, so the false-positive risk is high.
      • Rejected: dropping all Bash grants. It over-prompts qa/exec interactive users for no portal gain.
    3. What existing pattern does this follow, and how often has it been re-patched? The pattern is the fix(fullsolve): Phase 5.3 auto-merges the PR — the skill's own stop-list says to halt at the final summary #958 frontmatter gate (fullsolve-merge-gate-skill.test.ts, which removed gh pr merge:*). There is one prior allowed-tools fix (fix(fullsolve): Phase 5.3 auto-merges the PR — the skill's own stop-list says to halt at the final summary #958); feat(evals): assess-dashboard claude plugin eval case — needs a Bash(gh issue view) exception or a local-fixture read path in /assess #1008 is related (an eval needing Bash(gh issue view)). That is <2 fix issues, so precedent applies. This change is the class-level fix: one gate over every skill, not one per skill.
    4. What would a senior reviewer challenge?
      • "Why not literal AC-2's regex?" Because it passes npx sequant worktree:*, which the portal flagged. The stricter rule is: any runner entry ending in * fails unless explicitly allowlisted with a reason.
      • "Will npx sequant worktree resolve:* still be flagged?" Unknown until AC-6. If the portal still flags it, drop the allowlist entry. Headless runs are unaffected either way.
    5. Every producer and consumer of the artifact (whole-repo grep).
      • Producer: .claude/skills/*/SKILL.md. Copier: scripts/check-skill-sync.ts --fix.
      • Consumers:
        • Claude Code (interactive pre-approval)
        • the plugin directory portal
        • src/commands/init.ts:969 (renders {{PM_RUN}} into templates for consumer projects)
        • fullsolve-merge-gate-skill.test.ts: keep gh pr create:* + gh pr list:* in fullsolve
        • release-checkout-lock-skill.test.ts: a comment only, not affected
        • docs/reference/permissions.md
      • There is one producer, so no parity test is needed.

    No design choice between architectures, so no ADR is required.

    Feature Quality Planning

    Notable items:

    Open Questions

    1. Narrow assess/solve/merger/upstream's extra entries, which AC-1's literal text covers but the issue's list omits? Recommendation: yes, or the gate can't pass. Impact if wrong: a gate with per-skill exemptions.
    2. Is subcommand-prefixed npx sequant worktree resolve:* acceptable? Recommendation: allowlist it with a reason, and let AC-6 decide. Impact if wrong: one more portal round, then remove it.
    3. Scope Skill in fullsolve as Skill(sequant:spec)…? Recommendation: only if Phase 1 confirms Claude Code supports per-skill rules; otherwise keep it with a reason. Impact if wrong: a dead grant, and the sub-skills prompt.

    Recommended Workflow

    Phases: exec → qa
    Quality Loop: disabled
    Reasoning:

    • The change is mechanical frontmatter edits plus one gate test. The gate is the only code, so testgen adds little.
    • AC-5/AC-6 sit outside the phase agents' reach. QA marks them pending-runner and pending-owner, never met.
    • Exec and QA run only the targeted tests (npx vitest run src/lib/__tests__/skill-allowed-tools-gate.test.ts src/lib/__tests__/fullsolve-merge-gate-skill.test.ts, npm run lint:skill-sync, npm run lint:skill-calls). CI runs the full suite.

    Label Review

    Current: enhancement
    Recommended: + planned
    Quality Loop: won't auto-enable (SCOPE_OK).

  4. added
    planned
    on Oct 3, 2026
  5. admarble commented on Oct 3, 2026

    @admarble
    ContributorAuthor

    QA Verdict: AC_NOT_MET

    AC coverage: 3/6 met

    Gaps:

    • AC-4 bare Write/Edit/Skill grants are neither scoped nor justified with a per-skill reason in the PR body
    • AC-1 gate test has no recorded mutation result in the PR body
    • spec still pre-approves arbitrary git via git -C, the same broad access class as git *, and the gate does not reject it
    • qa semgrep-scan grant was removed although qa references run it, where AC-2 asks for narrowing instead
    • AC-5 interactive smoke and AC-6 portal Validate are not yet done, and newly prompting commands are not listed in the PR
    • Sibling broad grants not flagged by the portal have no follow-up issue — unresolved
    • Required CI checks still pending
  6. added a commit that references this issue on Oct 3, 2026
  7. admarble commented on Oct 3, 2026

    @admarble
    ContributorAuthor

    QA Verdict: NEEDS_VERIFICATION

    AC coverage: 4/6 met

    Pending ACs:

    • AC-5
    • AC-6

    Needs human review:

    • Required CI check test still pending
    • Interactive /verify and /fullsolve smoke not yet run
    • Portal Validate on path plugin not yet run
  8. added a commit that references this issue on Oct 4, 2026
  9. admarble commented on Oct 4, 2026

    @admarble
    ContributorAuthor

    Owner decision (2026-10-04): AC-5 is accepted on the PR's "New prompts" list. PR #1291 lists the commands each narrowed skill will now prompt for in interactive use. The owner accepted that list as AC-5's evidence in place of an interactive /verify + /fullsolve run on a scratch issue. No interactive run was performed. If a prompt turns out to be disruptive in real use, file it against #1292 or as a new issue, and add the narrowest grant that covers it.

    The other ACs were checked by the runner:

    • AC-1–AC-3: the gate test was mutation-verified per AC, plus the global-option, relative-path, package-manager-flag and curl rules.
    • AC-4: the PR-body table.
    • AC-6: the portal Validate on the branch at fda34ab no longer lists "Pre-approves broad shell access in allowed-tools".
    • CI: 11/11 green at d9f4d7e2.
  10. added 2 commits that reference this issue on Oct 7, 2026
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

    enhancementplanned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions