wiki / concepts / context-budget-audit
Context Budget Audit
loading…
Context Budget Audit
Every message to a harness-based agent ships a payload you never see: tool definitions, skills catalogs, system instructions for features you never touch — billed on every request, every turn. A context budget audit makes the invisible measurable and then cuts it.^[raw/aihero/how-to-kill-the-bloat-in-claude-codes-system-prompt.md]
The Six-Step Audit Loop
- Measure with
/context(Claude Code): per-category token counts — system prompt, system tools, MCP tools, memory files, messages. Baseline before changing anything. - Find the biggest offenders with a logging proxy: the CLI talks plain HTTP to the model API, so a no-dependency forwarding proxy can record every request body untouched.
/contextreports tools as one aggregate; the proxy gives per-tool rankings. - Switch off whole features with
disable*flags. - Remove individual tools with
denyrules. - Apply the configuration, then re-measure — the loop closes only with a before/after number.
Matt Pocock’s result: tens of thousands of tokens per turn cut.^[raw/aihero/how-to-kill-the-bloat-in-claude-codes-system-prompt.md] This is prompt bloat remediation with instrumentation.
Design Rule
Anything resident in the system prompt or tool registry must earn its per-turn cost — that’s why harness design pushes to progressive disclosure (load skills on demand) and why tool calling loop carries an under-6-tools budget. Feedback-loop infrastructure (typecheck, tests, pre-commit hooks via Husky + lint-staged) belongs at the harness layer, not in context: it gives the agent verification without spending a single context token.
Related
prompt bloat, progressive disclosure, tool calling loop, context rot, deterministic lint gates, smart zone.
| raw/aihero/how-to-kill-the-bloat-in-claude-codes-system-prompt.md | internal workspace doc | |
| raw/aihero/essential-ai-coding-feedback-loops-for-type-script-projects.md | internal workspace doc | |
| raw/aihero/how-to-use-claude-code-hooks-to-enforce-the-right-cli.md | internal workspace doc | |
| raw/aihero/never-run-claude-init.md | internal workspace doc |