[BUG] /claude-api bundled skill saturates context unconditionally — ~77% spike from neutral question
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
▎
▎ Version: 2.1.156
▎ Observed: Context window jumped from ~17% to ~94% when invoking /claude-api with a neutral question.
▎
▎ Root cause: The bundled skill at %LOCALAPPDATA%\Temp\claude\bundled-skills\<version>\<hash>\claude-api\ contains ~40 files totaling ~514 KB across 6 language SDKs (Python, TypeScript, Go, Java, C#, Ruby, PHP, curl) plus 12 managed-agents files and shared concept docs. There is no SKILL.md at the root with routing logic — all files are loaded unconditionally on every invocation, regardless of the user's language or topic.
▎
▎ Notable offenders loaded even for e.g. "how do I stream responses?":
▎ - shared/model-migration.md — 84 KB, irrelevant unless explicitly upgrading models
▎ - shared/managed-agents-*.md — ~150 KB total, irrelevant unless explicitly building agents
▎
▎ Expected: Detect language from file imports, detect topic from the question, load 1–3 relevant files. Most queries need ~15–30 KB, not 514 KB.
▎
▎ Suggested fix: Add a SKILL.md at the skill root that routes to the appropriate language folder and shared file based on detected context. The skill already has the right file structure — it just needs a router.
▎
▎ Workaround: A user command at ~/.claude/commands/claude-api.md overrides the bundled skill and implements on-demand loading. Effective but fragile — requires manual upkeep per version.
What Should Happen?
If the request from the user is NOT specific in terms of a language (se the attached conversation in a file), the skill should either suggest a differnt skill OR interview the user OR do a text-search (grep perhaps" in the files of the folder to LIMIT the context bloating !!!!!!
Error Messages/Logs
✻ Baked for 7m 36s · 1 shell still running
❯ i looked into it myself. while you analyzedd, and i agree: the skill loaded the ENTIRE folder and all subfolders into the context instead of searching with grep or somilar for keywords.
this MUST change in the future, I was asking a perfectly neutral question !!!! - what can we do ?
Let me look one more time — the user's "entire folder and subfolders" comment means there must be a file structure somewhere I missed.
Searched for 2 patterns, ran 1 shell command
Interrupted · What should Claude do instead?
❯ FYI : this is the folder in question: C:\Users\LARSGR~1\AppData\Local\Temp\claude\bundled-skills\2.1.156\d30268a0c2e076f2b8fde8396e2223c4\claude-api
Now we can see it. Let me inspect the actual structure and sizes.
Searched for 1 pattern, ran 1 shell command
Now the picture is complete and damning:
514 KB across 40 files. All loaded unconditionally. Including full docs for 6 languages (Python, TypeScript, Go, Java, C#, Ruby, PHP, curl) + 12 managed-agents files + shared concepts — regardless of what you asked.
The single biggest offender: shared/model-migration.md at 84 KB alone.
---
Two things we can do:
1. Local override now — Create ~/.claude/commands/claude-api.md as a single routing file. User commands take precedence over bundled skills. The file would instruct Claude to detect language + topic first, then read only the relevant files from the bundled path using Glob/Read. Instead of 514KB dumped upfront, it fetches 1–3 files on demand. Context impact: ~5% instead of 77%.
2. Report to Anthropic — This is a product-level design bug. The bundled skill has no routing logic at all — it just saturates the context. Worth filing at github.com/anthropics/claude-code/issues.
---
Want me to build the local override now? It would look like:
~/.claude/commands/claude-api.md
→ detect language from imports in current file
→ detect topic from user question (streaming? tool-use? migration? agents?)
→ Read only the 1-3 relevant files from the bundled path
→ proceed with ~30KB instead of 514KB
✻ Worked for 1m 2s · 1 shell still running
❯ ja lav den override nu, formuler så en kort (men beskrivende) tekst jeg kan rapportere til Anthropic
● Skill(/superpowers:writing-skills)
Successfully loaded skill
Let me check one existing command file for formatting conventions before writing.
Read 2 files
Let me check how _claude-global syncs to ~/.claude before deciding where to author.
Searched for 1 pattern, read 2 files, ran 1 shell command
Now I have everything I need. Writing both files in parallel.
● Write(_claude-global\commands\claude-api.md)
Wrote 64 lines to _claude-global\commands\claude-api.md
# /claude-api — Claude API / Anthropic SDK reference
Load documentation on demand. Never load all files upfront.
The bundled skill spans 6 languages + managed agents = ~514 KB. Load only what the question requires.
---
## Step 1 — Find the bundled docs path
Run this PowerShell command to locate the current installation (path changes per version):
… +54 lines
Now deploy it and sync:
Listed 1 directory, ran 2 shell commands
Good — 2.5 KB override deployed vs 514 KB bundle.
Steps to Reproduce
simply do this from a fresh session:
✳ Compare pricing between Opus 4.8 and 4.6.txt
Claude Model
Sonnet (default)
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
2.1.156
Platform
Anthropic API
Operating System
Windows
Terminal/Shell
Windows Terminal
Additional Information
this belong in your future QA loop for ALL skills !
Showing cached comments. Read the full discussion on GitHub ↗
6 Comments
The root cause is now confirmed from three angles (by my claude):
I am also seeing the
claude-apiskill immediately take up 200k in context upon invocation.Workaround: shadow the bundled skill with a user-level copy of the same name (verified on v2.1.199, Linux)
A user skill at
~/.claude/skills/claude-api/with the samenamecleanly overrides the compiled-in bundled skill — both in the skills listing (only one entry remains, the local one) and on invocation (/claude-apiloads the local SKILL.md, no<doc>-tag inlining):After this, loading the skill follows standard progressive disclosure: only SKILL.md (~74 KB ≈ 19K tokens) is injected, and reference docs are
Readon demand (0.5–5 KB each).For context on the size math (from spelunking the bundled variant in the binary): the compiled-in wrapper inlines the detected language's docs plus the entire
shared/directory (~570 KB ≈ 150K tokens for a Python project), and when language detection fails it falls back to inlining the entire multi-language corpus (~793 KB ≈ 210K tokens — enough to overflow a 200K window from an empty session, which matches #72790). Theanthropics/skillsrepo layout itself is already structured for progressive disclosure (per-language dirs +shared/); it's only the bundled wrapper that defeats it.shared/model-migration.mdalone is 144 KB (~39K tokens).Caveats for anyone using the workaround: the local copy is a snapshot (refresh it from
anthropics/skillsoccasionally), and re-verify the shadowing still holds after Claude Code upgrades.Ran into this on 2.1.205. Docs-only repo, so detection had nothing to find, and the fallback inlined all eight language docs at once — ~789 KB in a single message. On Haiku 4.5 (200k window) that killed the session outright,
/contextshowed 258k/200k afterwards. Full writeup with transcript numbers in #74473: https://github.com/anthropics/claude-code/issues/74473#issuecomment-4923882810Two data points to add:
Version regression: measuring the injected payload across bundled-skill versions extracted to
/tmp/claude-*/bundled-skills/: ~556k chars through 2.1.207 (survivable only in a near-empty window), jumping to ~785k chars (~196k tokens) at 2.1.209 when the managed-agents docs were added. Since then every invocation we've observed in a subagent with a normal prompt (~36k tokens in) died instantly with "Prompt is too long" — 3/3 on 2026-07-17, triggered by nothing more than aCo-Authored-By: Claudecommit trailer in the task prompt.Generic mitigation that works today: the payload arrives as an injected user message (
isMeta,sourceToolUseID), not the Skill tool result, so no PostToolUse hook can truncate it after launch. A PreToolUse hook onSkillcan, though: estimate the would-be injection (SKILL.md size if present, else the sum of all.mdfiles, since the no-SKILL.md fallback concatenates everything), and above a threshold returnpermissionDecision: "deny"with the entry content (SKILL.md head, or a generated file index) inadditionalContext. The agent then Reads individual files on demand — we verified an agent navigating the denial to a correct file-grounded answer at ~9k chars of context instead of ~785k. Fail-open, no effect on well-formed skills.Guys, can you please fix this? It's very annoying