token-x-ray
Skill0 starsChanged 7 months agoMITView on GitHub
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.
In this repository9 other files it gives its agents.
- amnesia-fixSkill
- compact-guardSkill
- done-proverSkill
- onboardSkill
- safe-shellSkill
- skill-budgetSkill
- skill-doctorSkill
- subagent-brokerSkill
- unclearSkill
The file
We split this skill into the rules it gives an agent
6 rules. About 0 are common, 2 are distinctive, and 4 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 25
When invoked, run the bundled audit.py script (next to this SKILL.md) and present its output verbatim.
- Distinctive: line 44
Run the audit script with the user's current settings:
- Very specific: line 50
If the user passed arguments (e.g.
- Distinctive: line 57
After showing the output, if the user asks "what should I cut?":
- Very specific: line 65
Never auto-disable anything.
- Very specific: line 100
Run after every plugin/MCP install.
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
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
mvand "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
/contextshowing 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
/contextdirectly 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/projectMake it a habit
Run after every plugin/MCP install. If /context ever surprises you,
this is the first thing to run.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

