claude-code - 💡(How to fix) Fix feat: extend ToolSearch deferral to plugin skills [1 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#45332Fetched 2026-04-09 08:07:48
View on GitHub
Comments
0
Participants
1
Timeline
4
Reactions
0
Author
Participants
Timeline (top)
labeled ×4

Plugin skills inject their name and description into an <available_skills> XML block in the system prompt on every turn. There is no deferral mechanism equivalent to what built-in tools received in v2.1.69 (#31002) or what MCP tools support via defer_loading: true. The result is a fixed per-turn token cost that scales linearly with the number of installed plugins regardless of whether any of those skills are relevant to the current task.

Root Cause

Plugin skills inject their name and description into an <available_skills> XML block in the system prompt on every turn. There is no deferral mechanism equivalent to what built-in tools received in v2.1.69 (#31002) or what MCP tools support via defer_loading: true. The result is a fixed per-turn token cost that scales linearly with the number of installed plugins regardless of whether any of those skills are relevant to the current task.

Fix Action

Fix / Workaround

Current Workarounds

RAW_BUFFERClick to expand / collapse

Summary

Plugin skills inject their name and description into an <available_skills> XML block in the system prompt on every turn. There is no deferral mechanism equivalent to what built-in tools received in v2.1.69 (#31002) or what MCP tools support via defer_loading: true. The result is a fixed per-turn token cost that scales linearly with the number of installed plugins regardless of whether any of those skills are relevant to the current task.

The Numbers

A user with 14 enabled plugins has approximately 152 skills and 35 agents listed every turn. At roughly 200 characters per entry, that is ~37,400 characters (~9,350 tokens) of skill descriptions baked into every system prompt. The SLASH_COMMAND_TOOL_CHAR_BUDGET caps injection at ~1% of the context window, which on a 200K-token model still permits 8,000–16,000 characters of skill descriptions per turn as a floor.

On Opus with the 5-hour rate limit, this overhead accumulates across every session. Users who install plugins for occasional use — image generation, marketing copy, PDF export — pay the full per-turn cost even when those skills will never be invoked.

What Already Works (And Doesn't Apply Here)

Built-in tools moved behind ToolSearch deferral in v2.1.69 (#31002). The partial reversion in v2.1.72 kept 9 core tools pre-loaded and deferred the rest — a "keep essential, defer the rest" pattern that is exactly what plugin skills need. MCP tools support defer_loading: true at the API level.

Plugin skills have no equivalent. Every enabled plugin, every turn.

Current Workarounds

None of the existing options are workable:

  • Disable plugins entirely — loses access to agents and bundled tools, not just skills
  • disable-model-invocation: true in SKILL.md — removes from context but makes it undiscoverable by Claude; manual-only invocation
  • Lower SLASH_COMMAND_TOOL_CHAR_BUDGET — truncates all descriptions, degrading Claude's ability to match any skill to any task
  • Permission deny rules — may still inject descriptions even when invocation is blocked

Proposed Solution

Extend ToolSearch deferral to plugin skills using the existing architecture.

  1. Register each plugin skill as a deferred entry in the ToolSearch index, keyed on name and description, rather than injecting into <available_skills> every turn
  2. Claude discovers skills via ToolSearch when it encounters a relevant task — same as deferred built-in tools
  3. The Skill tool itself remains pre-loaded. Only the per-skill description injection is deferred
  4. Skills with user-invocable: true continue to appear in the / command menu regardless of deferral state
CurrentProposed
Per-turn skill costO(n) — all installed skillsO(1) base + O(k) on query
Prompt cache efficiencyLow — prefix changes with skill countHigher — stable prefix
DiscoverabilityFull descriptions always presentToolSearch-indexed, on demand

Related Issues

  • #31002 — Built-in tools deferred behind ToolSearch
  • #39686 — Cloud-synced skills silently consuming ~6K tokens with no opt-out
  • #14549 — marketplace.json duplication inflating skill count
  • #12836 — Original ToolSearch feature request
  • #32485 — Custom agents undiscoverable via ToolSearch

extent analysis

TL;DR

Extend ToolSearch deferral to plugin skills to reduce per-turn token cost by registering each skill as a deferred entry in the ToolSearch index.

Guidance

  • Register plugin skills as deferred entries in the ToolSearch index to avoid injecting skill descriptions into the system prompt every turn.
  • Modify the Skill tool to remain pre-loaded while deferring per-skill description injection.
  • Ensure skills with user-invocable: true continue to appear in the / command menu regardless of deferral state.
  • Test the proposed solution to verify that the per-turn skill cost is reduced from O(n) to O(1) base + O(k) on query.

Example

No code snippet is provided as the issue does not contain explicit code references.

Notes

The proposed solution aims to reduce the per-turn token cost by deferring skill description injection, but its implementation may require additional changes to the ToolSearch architecture and plugin skill registration.

Recommendation

Apply the proposed workaround by extending ToolSearch deferral to plugin skills, as it addresses the root cause of the issue and provides a scalable solution.

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