Saltar al contenido principal

Context Budget Audit: /skill-doctor, Output Caps and the Six Numbers That Fill Your Window

Intermedio

A Claude Code project accumulates context debt the way a laptop accumulates browser tabs. Every skill you installed adds a line to a listing Claude re-reads on every turn. Every subagent adds a description. Every CLAUDE.md paragraph you wrote in March loads in September whether the task needs it or not. And every npm test dumps up to 30,000 characters into the conversation. None of it is visible until the session starts forgetting instructions or the bill stops matching the work.

Context management covers the two commands you use in the moment, /clear and /compact. This page is the audit you run once per project: six places where Claude Code spends context before you type anything or between your turns, the setting that governs each, and the number it defaults to. Everything here is in the official docs as of September 2026, and most of the knobs are newer than the folklore about them.

What you'll learn
  • Measure before you cut: read /context, /usage attribution, and /doctor's listing estimate so you fix the biggest line item first
  • Prune the skill listing with /skill-doctor (v2.1.252+) and the four skillOverrides states, and know the 1%-of-window budget the listing is capped at
  • Cap what a shell command or background task returns inline (30,000 and 32,000 characters by default) with bashOutputMaxChars and taskOutputMaxChars
  • Stop paying for CLAUDE.md in every subagent with omitClaudeMd (v2.1.271+) and keep subagent descriptions under the 15,000-token warning line
  • Set the auto-compact window on purpose (/autocompact, autoCompactWindow) and understand the 25,000-token budget that decides which invoked skills survive compaction
  • Cap effort fleet-wide with maxEffortLevel when thinking tokens, not context, are the real bill

What is in the window before you type​

Two facts make this diagram actionable. Everything in the left box is paid on every request, because Claude Code sends the full conversation each turn and only the cache-read discount softens it. And the right box is where a single verbose command can add more than the whole left box in one step. The audit below works left to right.

The audit​

Guided walkthrough1 of 9
  1. Run /context for a live breakdown by category with optimization suggestions, including which CLAUDE.md and auto-memory files loaded. On a Pro, Max, Team, or Enterprise plan, /usage attributes recent usage to skills, subagents, plugins, and individual MCP servers as percentages, and flags behaviors (long context, cache misses) that account for 10% or more. /doctor estimates the skill listing's context cost and its biggest contributors. Write the three biggest line items down before changing anything.

A settings block you can paste​

Project-local context caps (.claude/settings.local.json)

{
"bashOutputMaxChars": 12000,
"taskOutputMaxChars": 12000,
"skillOverrides": {
  "legacy-migration-notes": "name-only",
  "deploy-prod": "user-invocable-only",
  "old-design-system": "off"
},
"autoCompactWindow": 500000,
"maxEffortLevel": "high"
}

Read it top to bottom as decisions, not defaults. The two output caps assume a chatty test runner; drop them back toward the 30,000 / 32,000 defaults if Claude starts opening the saved output file on every run. The three overrides keep the skills reachable without paying for their descriptions. The compaction window is an explicit choice for a 1M-context model where you would rather compact at half than at the model-tuned point. The effort cap is the one line here that changes output quality, so set it last and only after /usage shows thinking tokens dominating.

Subagent that does not load CLAUDE.md (.claude/agents/repo-auditor.md)

---
name: repo-auditor
description: Audits a repository for dead code and unused exports. Use for read-only sweeps.
tools: Read, Grep, Glob, Bash
model: sonnet
omitClaudeMd: true
---
You are a read-only auditor. Everything you need is in the delegation prompt.
Report findings as a table of path, symbol, and evidence. Do not edit files.

Run the skill report in a headless session

claude -p "/skill-doctor"

Common mistakes​

Watch out
  • Deleting skills instead of collapsing them. name-only keeps a skill invocable at near-zero listing cost; off removes it from the / menu too. Most 'unused' skills should become name-only, not disappear.
  • Raising bashOutputMaxChars to the 128,000 ceiling because one build log overflowed. That makes every future command up to 4× more expensive inline. Filter the log with a PreToolUse hook (grep for FAIL, head -100) instead; the costs docs show the exact hook.
  • Setting autoCompactWindow above the model's context. Claude Code caps it at the window silently, so the setting looks applied and does nothing.
  • Assuming a subagent is cheap because its context is separate. Its startup still includes every CLAUDE.md level and a git snapshot unless it is Explore, Plan, or sets omitClaudeMd.
  • Reading /skill-doctor over Remote Control from a phone. It returns 'Skill usage reports are not available on this connection.' Run it in the terminal where the session lives.
  • Expecting an invoked skill to survive /compact. Only the most recent invocations fit in the 25,000-token re-attach budget, at 5,000 tokens each. Re-invoke the ones you still need.

Quick check​

Check yourself

0/6
  1. What does /skill-doctor report, and what does it deliberately leave out?
  2. Your skill listing has overflowed its budget. What happens?
  3. A successful npm test prints 80,000 characters. With default settings, what does Claude receive?
  4. Which subagents skip your CLAUDE.md files without any configuration?
  5. You invoked six skills in a long session and /compact just ran. Which survive?
  6. maxEffortLevel is set to 'medium' in managed settings and 'high' in your user settings. What runs?
Pulsa Intro o Espacio para girar la tarjeta. Usa las flechas izquierda y derecha para moverte entre las tarjetas.Término mostrado.
1 / 10
Key takeaways
  • Measure first: /context for the live breakdown, /usage for attribution by skill, subagent, plugin, and MCP server, /doctor for the listing estimate.
  • The skill listing is a per-turn tax capped at 1% of the window. /skill-doctor tells you what to collapse; name-only keeps a skill usable at near-zero cost.
  • Tool output is the fastest way to blow a window: ~30,000 characters inline per successful command, 32,000 per background task. Cap with bashOutputMaxChars / taskOutputMaxChars, or filter with a hook.
  • Subagents are not free at startup: every CLAUDE.md level plus git status, unless Explore, Plan, or omitClaudeMd. Keep custom descriptions under 15,000 tokens combined.
  • Compaction keeps only the most recent invoked skills (5,000 each, 25,000 total). Set autoCompactWindow deliberately, and re-invoke what must survive.
  • When thinking tokens dominate the bill, maxEffortLevel caps effort fleet-wide; lowest scope wins and it holds on every provider.

Sources & further reading​

Next​

  • Context management — /clear vs /compact in the moment, once the audit is done
  • Skills — writing skills that earn their listing line
  • Subagents — designing the delegation prompt so omitClaudeMd is safe