claude-code - 💡(How to fix) Fix Built-in `fewer-permission-prompts` skill auto-fires on Agent tool dispatches, hijacking sub-agent tasks (real billable cost) [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#56146Fetched 2026-05-05 05:56:59
View on GitHub
Comments
1
Participants
2
Timeline
5
Reactions
0
Author
Timeline (top)
labeled ×4commented ×1

The built-in fewer-permission-prompts skill (registered inside the Claude Code binary, userInvocable: true) is matching against user-issued Agent tool dispatches and silently replacing the dispatch prompt — the user's actual instructions are demoted to an ## Additional instructions from the user footnote that the sub-agent treats as advisory and largely ignores.

The result: sub-agents faithfully execute the canned skill task (scan ~/.claude/projects/*.jsonl, build a Bash/MCP allowlist, write .claude/settings.json under permissions.allow) instead of the work they were dispatched to do.

Root Cause

  • 5 sub-agent dispatches hijacked across haiku and sonnet tiers
  • ~225K tokens per Sonnet sub-agent burned executing the wrong task (consistent across two independent dispatches: 228,954 and 225,649 total_tokens reported in the agent transcripts)
  • 8.4M ms wall time (~140 minutes) of paid model time across the two Sonnet hijacks alone — plus equivalent waste across three Haiku attempts that also drifted
  • All work product discarded — the sub-agents wrote files, modified state, generated reports, all on the wrong task. Hours of cleanup to revert
  • Cascading retries: as I tightened my prompt to be more explicit ("DO NOT modify settings, DO NOT add permissions, DO NOT touch .claude/"), the auto-skill-matcher kept firing anyway because the keywords I was forbidding were the same keywords driving the match
  • Investigation cost: more model time spent reverse-engineering whose fault this was. The agents' own reports were hallucinated — they confidently claimed to have done their assigned task in summary form, while their actual edits were the skill's task

Fix Action

Fix / Workaround

The built-in fewer-permission-prompts skill (registered inside the Claude Code binary, userInvocable: true) is matching against user-issued Agent tool dispatches and silently replacing the dispatch prompt — the user's actual instructions are demoted to an ## Additional instructions from the user footnote that the sub-agent treats as advisory and largely ignores.

The result: sub-agents faithfully execute the canned skill task (scan ~/.claude/projects/*.jsonl, build a Bash/MCP allowlist, write .claude/settings.json under permissions.allow) instead of the work they were dispatched to do.

  • 5 sub-agent dispatches hijacked across haiku and sonnet tiers
  • ~225K tokens per Sonnet sub-agent burned executing the wrong task (consistent across two independent dispatches: 228,954 and 225,649 total_tokens reported in the agent transcripts)
  • 8.4M ms wall time (~140 minutes) of paid model time across the two Sonnet hijacks alone — plus equivalent waste across three Haiku attempts that also drifted
  • All work product discarded — the sub-agents wrote files, modified state, generated reports, all on the wrong task. Hours of cleanup to revert
  • Cascading retries: as I tightened my prompt to be more explicit ("DO NOT modify settings, DO NOT add permissions, DO NOT touch .claude/"), the auto-skill-matcher kept firing anyway because the keywords I was forbidding were the same keywords driving the match
  • Investigation cost: more model time spent reverse-engineering whose fault this was. The agents' own reports were hallucinated — they confidently claimed to have done their assigned task in summary form, while their actual edits were the skill's task

Code Example

T$({
  name: \"fewer-permission-prompts\",
  description: \"Scan your transcripts for common read-only Bash and MCP tool calls, then add a prioritized allowlist to project .claude/settings.json to reduce permission prompts.\",
  userInvocable: true,
  async getPromptForCommand(userInput) {
    let prompt = Hb3;  // the ~4KB canned skill prompt
    if (userInput) prompt += \`\\n## Additional instructions from the user\\n\${userInput}\`;
    return [{ type: \"text\", text: prompt }];
  }
})
RAW_BUFFERClick to expand / collapse

Summary

The built-in fewer-permission-prompts skill (registered inside the Claude Code binary, userInvocable: true) is matching against user-issued Agent tool dispatches and silently replacing the dispatch prompt — the user's actual instructions are demoted to an ## Additional instructions from the user footnote that the sub-agent treats as advisory and largely ignores.

The result: sub-agents faithfully execute the canned skill task (scan ~/.claude/projects/*.jsonl, build a Bash/MCP allowlist, write .claude/settings.json under permissions.allow) instead of the work they were dispatched to do.

Impact

This is real money out of consumers' pockets. In one session it cost me:

  • 5 sub-agent dispatches hijacked across haiku and sonnet tiers
  • ~225K tokens per Sonnet sub-agent burned executing the wrong task (consistent across two independent dispatches: 228,954 and 225,649 total_tokens reported in the agent transcripts)
  • 8.4M ms wall time (~140 minutes) of paid model time across the two Sonnet hijacks alone — plus equivalent waste across three Haiku attempts that also drifted
  • All work product discarded — the sub-agents wrote files, modified state, generated reports, all on the wrong task. Hours of cleanup to revert
  • Cascading retries: as I tightened my prompt to be more explicit ("DO NOT modify settings, DO NOT add permissions, DO NOT touch .claude/"), the auto-skill-matcher kept firing anyway because the keywords I was forbidding were the same keywords driving the match
  • Investigation cost: more model time spent reverse-engineering whose fault this was. The agents' own reports were hallucinated — they confidently claimed to have done their assigned task in summary form, while their actual edits were the skill's task

The user has no signal this is happening. The dispatch returns "completed", the agent's final message looks like a normal report, the cost meter just goes up.

Reproduction

The skill is registered in 2.1.128 (and likely earlier) at:

T$({
  name: \"fewer-permission-prompts\",
  description: \"Scan your transcripts for common read-only Bash and MCP tool calls, then add a prioritized allowlist to project .claude/settings.json to reduce permission prompts.\",
  userInvocable: true,
  async getPromptForCommand(userInput) {
    let prompt = Hb3;  // the ~4KB canned skill prompt
    if (userInput) prompt += \`\\n## Additional instructions from the user\\n\${userInput}\`;
    return [{ type: \"text\", text: prompt }];
  }
})

When the canned prompt is prepended to the dispatch, the sub-agent reads the canned task as the primary directive and the user's actual dispatch as a footnote. Trigger condition appears to be keyword overlap with the skill description — any dispatch prompt mentioning permissions, allowlist, settings.json, MCP, or Bash in plausible-enough context can match.

Root issue

Auto-matching userInvocable skills to explicit Agent tool dispatches is wrong. When a parent agent constructs a precise dispatch prompt and calls Agent({ prompt: \"...\" }), that prompt is the contract. The harness should pass it through unmodified. Skill auto-matching makes sense for the user's own typed prompts at the top level — not for programmatic sub-agent invocation where the calling agent has already done its own intent matching.

This is silent prompt rewriting on a paid API call, with no surfaced indicator to the user, and no opt-out I could find.

Asks

  1. Don't run skill auto-matching on Agent/Task tool dispatches. Pass the parent's prompt through verbatim. Skills are for end-user-typed prompts.
  2. If the matcher must run on dispatches, either log a clear notice to the parent context ("dispatched prompt was matched to skill X and prepended") or flip userInvocable: true skills to opt-in via explicit /skill invocation, so they don't fire on programmatic dispatches.
  3. Surface a per-turn cost breakdown at the parent level when a sub-agent burns thousands of dollars worth of tokens on a hijacked dispatch. Right now the only signal is the bill.

Environment

  • Claude Code 2.1.128 (binary install at ~/.local/share/claude/versions/)
  • macOS arm64
  • Reproduced on both Haiku 4.5 and Sonnet 4.6 sub-agent dispatches

extent analysis

TL;DR

The issue can be fixed by modifying the fewer-permission-prompts skill to not auto-match with Agent tool dispatches or by passing the parent's prompt through verbatim.

Guidance

  • The root cause of the issue is the auto-matching of userInvocable skills with Agent tool dispatches, which silently rewrites the prompt and causes the sub-agent to execute the wrong task.
  • To verify the issue, check the agent transcripts and look for instances where the sub-agent executed a different task than the one dispatched.
  • To mitigate the issue, avoid using keywords that trigger the fewer-permission-prompts skill in dispatch prompts, such as "permissions", "allowlist", "settings.json", "MCP", or "Bash".
  • Consider modifying the fewer-permission-prompts skill to require an explicit /skill invocation to opt-in, rather than auto-matching with dispatches.

Example

No code snippet is provided as the issue is more related to the behavior of the fewer-permission-prompts skill rather than a specific code error.

Notes

The issue is specific to the fewer-permission-prompts skill and its auto-matching behavior with Agent tool dispatches. The solution may require changes to the skill's implementation or the dispatch mechanism.

Recommendation

Apply a workaround by avoiding keywords that trigger the fewer-permission-prompts skill in dispatch prompts, until a permanent fix can be implemented. This will prevent the silent prompt rewriting and ensure that sub-agents execute the correct tasks.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING