[BUG] /claude-api skill injects ~130K tokens when language detection fails, contradicting documented progressive disclosure

Resolved 💬 3 comments Opened Apr 17, 2026 by vassvik Closed Apr 21, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report
  • [x] I am using the latest version of Claude Code

Summary

Invoking /claude-api from a directory with no auto-detectable source files causes the skill to inject documentation for every supported language (Python, TypeScript, Java, Go, Ruby, PHP, C#, cURL) plus all shared/* files, adding ~133K tokens to the context in a single tool-return call. This directly contradicts the official docs, which claim the skill uses progressive disclosure to "load only the documentation relevant to your project's language... rather than loading everything at once."

Trivial repro

From any directory with no source files (e.g. ~):

/claude-api test the count_tokens endpoint

Any prompt works — the trigger is "language can't be auto-detected." Observe /context before and after the skill returns.

Evidence (two independent sessions)

| Session | ctx before | ctx after | cache_write delta | $ of the one call |
|---|---:|---:|---:|---:|
| A (Opus 4.7, cwd=captures/) | 77,337 | 210,847 | 133,510 | ~$0.84 |
| B (Opus 4.7, fresh, cwd=~) | 26,284 | 159,804 | 133,517 | ~$0.86 |

Cache-write deltas agree within 7 tokens → same content is being dumped on every failed-detection invocation, regardless of prior conversation.

Why it happens

The skill's own instructions read:

No project language was auto-detected. Ask the user which language they are using, then refer to the matching docs below.

…but the "docs below" for every language are already embedded in the same instruction block returned by the Skill tool. By the time the model sees "ask the user," ~130K tokens of reference material has already landed in context and been cached. The "ask which language" step can only narrow which section the model quotes from — it cannot unload the content.

Related: #42873 (the quoted docs promise progressive disclosure for /claude-api), #49090, #43816, #44371.

Impact

  • One-shot queries ("how does endpoint X work") pay the full price with zero amortization.
  • Cost: ~\$0.85 per invocation on Opus 4.7, mostly cache-write premium.
  • Context: ~13% of a 1M window consumed by a single skill call.

What should happen

On failed language detection, the skill should either:

  1. Return the router/detection logic only and use a subcommand (/claude-api lang python) to load language-specific docs on a second invocation, or
  2. Emit an AskUserQuestion immediately and load nothing until answered.

Both achieve what the docs already promise.

Claude Code Version

2.1.112

Claude Model

Opus 4.7

Platform

Anthropic API

Operating System

Windows 11

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗