---
title: "Context Budget Audit"
description: "Measuring and cutting per-turn token overhead — /context, logging proxies, disable flags, and deny rules to kill harness bloat."
section: "concepts"
type: "concept"
created: "2026-08-30"
updated: "2026-08-30"
confidence: "high"
tags: ["context-engineering", "agents", "cost"]
canonical: "https://pyweb.dev/wiki/context-budget-audit"
---
# 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](/wiki/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](/wiki/progressive-disclosure) (load skills on demand) and why [tool calling loop](/wiki/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](/wiki/prompt-bloat), [progressive disclosure](/wiki/progressive-disclosure), [tool calling loop](/wiki/tool-calling-loop), [context rot](/wiki/context-rot), [deterministic lint gates](/wiki/deterministic-lint-gates), [smart zone](/wiki/smart-zone).

---

## Agent Navigation

cluster: person (170 pages) | betweenness: 8.3

### References (outbound)
- [Prompt Bloat](https://pyweb.dev/wiki/prompt-bloat.md)
- [Progressive Disclosure](https://pyweb.dev/wiki/progressive-disclosure.md)

### Referenced by (inbound)
- [Context Engineering](https://pyweb.dev/wiki/context-engineering.md)
- [Model Context Protocol Basics](https://pyweb.dev/wiki/model-context-protocol-basics.md)

### 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)

### Machine endpoints
- Knowledge graph: https://pyweb.dev/api/graph.json
- Graph analysis: https://pyweb.dev/api/graph-analysis.json
- Context index: https://pyweb.dev/llms.txt
