anthropics / anthropics/claude-code
claude-api bundled skill inlines ~227K tokens on invocation — progressive disclosure defeated by bundled packaging
- Dominant language
- Python
- Stars
- 145k
- Forks
- 23.1k
- PR merge metrics
- PR metrics pending
Description
**Note on venue:** verified before filing — the skill source at [anthropics/skills](https://github.com/anthropics/skills/blob/main/skills/claude-api/SKILL.md) uses an on-demand file-read model with no inlined reference docs, while the bundled variant delivers those files pre-rendered. The regression is in the bundled-skill packaging/render step, so filing here rather than anthropics/skills. Distinct from #14882 / #14834 / #16616 / #39686, which cover startup loading and /context display — this is invocation-time payload size.
**Environment:** Claude Code 2.1.220 (Linux), Opus 5 (1M context), bundled
skill at `bundled-skills/2.1.220//claude-api`. Repo: Go + Rust + TS
monorepo, `go.mod` at root, no Anthropic SDK imports anywhere (project targets
Ollama / OpenAI-compatible endpoints).
**What happened:** One invocation of the claude-api skill (Skill tool, args:
"Opus 5 model ids, 1M context pricing tier, effort levels, when to use opus vs
sonnet vs haiku for subagents") added **+227,284 tokens** to the context in a
single step — 66% of the session's total context at that point. Measured from
the session transcript's per-request `usage` fields: prompt total jumped
53,590 → 280,874 on the request following the skill turn. The skill content
arrived as one user turn containing a single **598,008-character** block.
**What the docs say should happen:**
https://platform.claude.com/docs/en/agents-and-tools/agent-skills/claude-api-skill
claims: "Claude loads only the documentation relevant to your project's
language, surface (Messages API or Managed Agents), and the specific task at
hand (tool use, streaming, batches, and so on), rather than loading everything
at once."
**Observed vs claimed, per axis:**
- Language: WORKED — only `go/` docs were included (not the other 7 languages).
- Surface: FAILED — both Messages API docs AND the full Managed Agents doc set
(~14 `shared/managed-agents-*.md` files: core, environments, events, memory,
multiagent, outcomes, overview, scheduled-deployments, self-hosted-sandboxes,
tools, webhooks, client-patterns, api-reference, onboarding) were inlined.
The task mentioned nothing about Managed Agents.
- Task: FAILED — the full model-migration guide (largest single doc),
prompt-caching, error-codes, anthropic-cli, platform-availability,
token-counting, tool-use-concepts, agent-design all arrived regardless of the
task, which needed roughly 2K tokens of model-table + effort-ladder content.
**Mechanism (verified, not hypothesized):** the source SKILL.md at
anthropics/skills instructs on-demand reads of separate files and embeds no
reference docs. The bundled payload received in Claude Code 2.1.220 contained
those same files pre-rendered inline as `` blocks under an
"## Included Documentation" section. The inlining therefore happens in Claude
Code's bundled-skill packaging/render step, which forecloses the on-demand
disclosure the source implements and the docs page advertises. Selection
survives only at the language level (Go-only was correctly chosen).
**Measurement caveat (for precision):** the 598,008-char block against the
+227,284-token delta implies ~2.6 chars/token — dense but plausible for
table/code-heavy markdown; the delta window includes a small amount of other
turn content. Order of magnitude is not in question; the exact figure is
±~10%.
**Impact:** in a repo with no Anthropic SDK code, any prompt that merely names
a Claude model can trigger the skill and consume a quarter of a 1M window (or
exceed a 200K window outright) for a lookup-sized question. The skill's SKIP
heuristic (grep for other providers) does not protect repos that use neither
the Anthropic SDK nor a competitor's (e.g. local-model tooling).
**Suggested directions (either would resolve it):**
1. Render only the sections matching the detected surface + a task keyword
match, keeping the rest as on-demand file reads (the model the docs already
describe); or
2. Split the payload: always-inline the quick-reference tables (~2-5K), and
gate the migration guide + managed-agents corpus behind explicit
subcommands (`migrate`, `managed-agents-onboard`) that already exist.
**Repro:** in any Go repo without Anthropic SDK imports, invoke
`/claude-api ` and inspect the next request's
`cache_creation_input_tokens` / prompt-size delta in the session transcript.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by tracing the bundled-skills/2.1.220//claude-api payload and the packaging/render step that produces the `## Included Documentation` and `` blocks; compare it with the source SKILL.md at anthropics/skills. Reproduce the issue in a Go repository without Anthropic SDK imports, then verify that unrelated Managed Agents and migration documents remain on demand and the prompt-size delta is reduced.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, rust, typescript
- Domain
- cli, developer-experience, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100