# Context Budget Guard

> Audit and optimize Claude Code context usage by identifying overlapping skills, unused plugins, and bloated configs.

Context Budget Guard is a free AI agent skill on Agensi by Ali Ahmed, in LLM Ops. It loads into your AI agent through the Agensi MCP server, always in its latest approved version.

- Price: Free
- Creator: [Ali Ahmed](https://www.agensi.io/creators/ali-ahmed-1)
- Category: [LLM Ops](https://www.agensi.io/skills/llm-ops)
- Version: 1.0
- Last updated: 2026-11-28
- Security: scan passed (2026-11-28); every new listing is also reviewed by a person
- Listing: https://www.agensi.io/skills/context-budget-guard
- Tags: llm-ops, claude-code, context-management, token-optimization, python

## About this skill

Bloated context windows lead to slow responses, high token costs, and agents selecting the wrong tools. This skill audits your Claude Code environment to identify exactly what is consuming your always-on token budget and provides a path to a leaner setup.

### What it does
- **Analyze token consumption** by scanning `CLAUDE.md`, project skills, subagents, and MCP configurations.
- **Detect skill overlap** using lexical similarity checks to find descriptions that confuse the agent.
- **Identify unused assets** by cross-referencing local session transcripts to see which plugins or skills haven't been invoked.
- **Calculate budget baselines** to track how configuration changes affect your permanent context load over time.
- **Surface high-impact fixes** by ranking findings based on potential token savings.

### How it works
1. Run the `cbg.py` script against your project root or an uploaded configuration bundle to generate a `context-report.md`.
2. Review the always-loaded estimate and top three findings surfaced by the agent.
3. Save a baseline snapshot before applying suggested fixes like merging overlapping skills or moving reference docs to on-demand skills.
4. Execute a comparison run to verify token reduction and confirm the agent's improved focus.

### Frameworks & tools
Python 3 standard library. Integrates with Claude Code, `.claude` configuration folders, `CLAUDE.md` files, and `.mcp.json` server definitions.

### Why this beats prompting it yourself
Standard prompts cannot see your local session history or calculate cross-file token estimates with consistency. This skill uses a specialized script to parse local transcripts and configurations that are normally invisible to a generic chat session.

### Use cases
- Reducing "token fever" when sessions hit limits too early in the workday.
- Debugging why an agent picks the wrong skill for a specific task.
- Auditing a complex multi-agent workspace before a production deployment.
- Cleaning up legacy plugins and MCP servers that are no longer in use.

### Known limitations
Token counts are ±25% estimates as no tokenizer is bundled. MCP tool schemas are not fetched; costs are based on flat estimates. Overlap detection uses TF-IDF, which may miss some semantic clashes.

## Requires

- Python 3.10+

## How to use this skill

1. Connect your AI agent to Agensi once: add the MCP server https://mcp.agensi.io/mcp/auth and sign in with your Agensi account (OAuth, no API key). Steps for Claude, ChatGPT, Claude Code, Codex, Cursor, VS Code and other agents: https://www.agensi.io/docs/mcp-setup
2. Ask your agent: "Use the Context Budget Guard skill from Agensi" and describe your task.
3. Your agent loads the skill from Agensi when it needs it. Nothing is downloaded.

## Frequently asked questions

### How does this skill help reduce my Claude Code token usage?

Context Budget Guard identifies 'context bloat' by auditing your CLAUDE.md, MCP configurations, and project skills to find redundant or unused assets that slow down responses and drive up token costs.

### Which AI agents and configurations are compatible with this audit tool?

The skill is designed specifically for the Claude Code CLI environment and integrates with .claude folders, .mcp.json server definitions, and standard project instruction files.

### What specific files or assets are included in the download?

The purchase includes the core cbg.py analysis script, documentation for interpreting the context-report.md, and a guide for establishing token budget baselines.

### Can the tool detect skills or plugins that I'm not actually using?

Yes, the script cross-references your local session transcripts to identify plugins, skills, and MCP tools that haven't been invoked, highlighting them as candidates for removal.

### Do I need to install any heavy dependencies to run the audit?

Setup is minimal; simply run the provided Python script against your project root or configuration bundle to generate your first audit report.

### How accurate are the token consumption estimates in the report?

Token counts are provided as ±25% estimates based on character density, as the tool uses a lightweight approach without bundling a heavy tokenizer to ensure fast, local execution.

---

Source: [Agensi](https://www.agensi.io), the marketplace of skills for AI agents. Any MCP-compatible agent (Claude, ChatGPT, Claude Code, Codex, Cursor, VS Code and more) connects at https://mcp.agensi.io/mcp/auth and signs in with an Agensi account; setup for every agent: https://www.agensi.io/docs/mcp-setup. Append .md to any skill, guide or docs address on agensi.io for its markdown version.
