token-x-ray — see where your context tokens went
Fixes:
#39686
What this prevents
"43 claude.ai Skills (3,950 tokens) and 26 Cowork plugins (2,020
tokens) silently injected into Claude Code context — no opt-out, ~6k
tokens wasted per session." — issue #39686
Claude Code's /context shows category totals but no per-item
breakdown. You see "Skills: 4,200 tokens" with no idea which of your
forty skills is doing the damage. token-x-ray itemizes every
auto-injected source so you can decide what to cut.
What this skill does
When invoked, run the bundled audit.py script (next to this
SKILL.md) and present its output verbatim. The script discovers:
| Source |
Where it looks |
| MCP servers |
~/.claude.json, ~/.claude/settings.json, <cwd>/.claude/settings*.json, <cwd>/.mcp.json |
| CLAUDE.md |
~/.claude/CLAUDE.md, <cwd>/CLAUDE.md, <cwd>/.claude/CLAUDE.md |
| Skills |
~/.claude/skills/, <cwd>/.claude/skills/, ~/.claude/plugins/*/skills/ |
| Subagents |
~/.claude/agents/, <cwd>/.claude/agents/ |
| Slash commands |
~/.claude/commands/, <cwd>/.claude/commands/ |
For each source, it estimates tokens using the
4-chars-per-token heuristic. MCP servers are flagged separately
because their tool schemas can only be measured by invoking the
server — the script uses a per-server estimate and points the
user at /context for the authoritative number.
How to invoke (the actual procedure)
Run the audit script with the user's current settings:
${CLAUDE_PLUGIN_ROOT}/skills/token-x-ray/audit.py
If the user passed arguments (e.g. --json, --cwd, --home),
forward them.
Show the script's output verbatim. The bar chart, the per-source
table, and the suggested cut commands are the value — reformatting
them defeats the purpose.
After showing the output, if the user asks "what should I cut?":
- Point them at the "Top cuts" section
- Note that MCP servers are the highest-leverage cut (1500+ tokens
each by heuristic) but require you to actually remove the server
entry from settings
- Recommend cutting unused skills/agents/commands first if MCP
servers are in active use
Never auto-disable anything. The suggested mv and "remove from
settings" hints are for the user to inspect and run themselves.
When to auto-invoke
- User runs
/claude-papercuts:token-x-ray
- User asks "where did my context go" / "what's eating my tokens"
- User says Claude feels slow, expensive, or laggy
- User mentions
/context showing surprising numbers
- User asks for a "context audit" or "token diet"
What this skill does NOT do
- It does not actually invoke MCP servers to measure their real tool
schemas. That would be slow and can fail; we use a heuristic and
flag it explicitly.
- It does not modify any files or settings. Suggestions are
copy-paste, not auto-apply.
- It does not count the conversation/transcript itself — that's
visible in
/context directly and changes every turn.
- It does not count fixed prompt overhead (Anthropic's system
prompt, tool catalog, etc.). Those are not user-controllable.
Configuration
# Machine-readable JSON for piping into other tools
${CLAUDE_PLUGIN_ROOT}/skills/token-x-ray/audit.py --json
# Audit a different project directory
${CLAUDE_PLUGIN_ROOT}/skills/token-x-ray/audit.py --cwd /path/to/project
Make it a habit
Run after every plugin/MCP install. If /context ever surprises you,
this is the first thing to run.
1---2name: token-x-ray3description: X-ray every source of auto-injected context Claude Code loads at session start — MCP servers, CLAUDE.md files, skills, subagents, and slash commands — and report estimated tokens per source. Use this skill when the user runs /claude-papercuts:token-x-ray, asks where their context tokens went, says Claude feels slow or expensive, mentions /context showing surprising numbers, or wants to know what to disable. Runs the audit.py script in this skill's directory and presents the result verbatim.4---56# token-x-ray — see where your context tokens went78**Fixes:**9[`#39686`](https://github.com/anthropics/claude-code/issues/39686)1011## What this prevents1213> *"43 claude.ai Skills (~3,950 tokens) and 26 Cowork plugins (~2,02014> tokens) silently injected into Claude Code context — no opt-out, ~6k15> tokens wasted per session."* — issue #396861617Claude Code's `/context` shows category totals but no per-item18breakdown. You see "Skills: 4,200 tokens" with no idea which of your19forty skills is doing the damage. `token-x-ray` itemizes every20auto-injected source so you can decide what to cut.2122## What this skill does2324When invoked, run the bundled `audit.py` script (next to this25SKILL.md) and present its output verbatim. The script discovers:2627| Source | Where it looks |28|---|---|29| MCP servers | `~/.claude.json`, `~/.claude/settings.json`, `<cwd>/.claude/settings*.json`, `<cwd>/.mcp.json` |30| CLAUDE.md | `~/.claude/CLAUDE.md`, `<cwd>/CLAUDE.md`, `<cwd>/.claude/CLAUDE.md` |31| Skills | `~/.claude/skills/`, `<cwd>/.claude/skills/`, `~/.claude/plugins/*/skills/` |32| Subagents | `~/.claude/agents/`, `<cwd>/.claude/agents/` |33| Slash commands | `~/.claude/commands/`, `<cwd>/.claude/commands/` |3435For each source, it estimates tokens using the364-chars-per-token heuristic. MCP servers are flagged separately37because their tool schemas can only be measured by invoking the38server — the script uses a per-server estimate and points the39user at `/context` for the authoritative number.4041## How to invoke (the actual procedure)42431. Run the audit script with the user's current settings:4445 ```bash46 ${CLAUDE_PLUGIN_ROOT}/skills/token-x-ray/audit.py47 ```48492. If the user passed arguments (e.g. `--json`, `--cwd`, `--home`),50 forward them.51523. Show the script's output verbatim. The bar chart, the per-source53 table, and the suggested cut commands are the value — reformatting54 them defeats the purpose.55564. After showing the output, if the user asks "what should I cut?":57 - Point them at the "Top cuts" section58 - Note that MCP servers are the highest-leverage cut (1500+ tokens59 each by heuristic) but require you to actually remove the server60 entry from settings61 - Recommend cutting unused skills/agents/commands first if MCP62 servers are in active use63645. Never auto-disable anything. The suggested `mv` and "remove from65 settings" hints are for the user to inspect and run themselves.6667## When to auto-invoke6869- User runs `/claude-papercuts:token-x-ray`70- User asks "where did my context go" / "what's eating my tokens"71- User says Claude feels slow, expensive, or laggy72- User mentions `/context` showing surprising numbers73- User asks for a "context audit" or "token diet"7475## What this skill does NOT do7677- It does not actually invoke MCP servers to measure their real tool78 schemas. That would be slow and can fail; we use a heuristic and79 flag it explicitly.80- It does not modify any files or settings. Suggestions are81 copy-paste, not auto-apply.82- It does not count the conversation/transcript itself — that's83 visible in `/context` directly and changes every turn.84- It does not count fixed prompt overhead (Anthropic's system85 prompt, tool catalog, etc.). Those are not user-controllable.8687## Configuration8889```bash90# Machine-readable JSON for piping into other tools91${CLAUDE_PLUGIN_ROOT}/skills/token-x-ray/audit.py --json9293# Audit a different project directory94${CLAUDE_PLUGIN_ROOT}/skills/token-x-ray/audit.py --cwd /path/to/project95```9697## Make it a habit9899Run after every plugin/MCP install. If `/context` ever surprises you,100this is the first thing to run.