wiki / concepts / context-budget-audit

Context Budget Audit

high confidence updated 2026-08-30 context-engineering · agents · cost

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

  1. Measure with /context (Claude Code): per-category token counts — system prompt, system tools, MCP tools, memory files, messages. Baseline before changing anything.
  2. 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. /context reports tools as one aggregate; the proxy gives per-tool rankings.
  3. Switch off whole features with disable* flags.
  4. Remove individual tools with deny rules.
  5. 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.

prompt bloat, progressive disclosure, tool calling loop, context rot, deterministic lint gates, smart zone.

Evidence — verified primary sources
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