Skip to content

← Back to home

Token-budgeted codebase context

Reduce Claude Code token usage without losing the context it needs

If Claude Code feels too expensive, the tokens are going somewhere specific: whole-file reads, the same files re-read every turn, and grep output dumped into the context window. Context Engine puts a hard token budget on every retrieval and returns only the code that matters.

Read the FAQ

Where Claude Code burns tokens

Token cost in an agent loop is dominated by context, not by the answer. Every turn, the agent re-sends the context it is carrying — and if that context is stuffed with whole files it grepped and read earlier, you pay for those tokens again and again. On a large codebase the bill climbs fast.

  • whole-file reads pull in hundreds of lines to use a handful
  • re-reading the same files each turn re-bills the same tokens
  • grep / glob dumps large, low-signal blocks into the window
  • context bloat forces auto-compact, which then loses useful detail

A hard token budget on every retrieval

With Context Engine, the agent calls one MCP tool — codebase_context — and passes a tokenBudget. The service runs hybrid retrieval (dense + sparse + symbol graph), reranks and de-duplicates, then assembles a file-level pack that stops at the budget. It returns the relevant spans rather than whole files, and skips files the agent has already seen.

So the context window carries only what answers the current question, the same code is not paid for twice, and you control the ceiling per call. Lower the budget for cheap sweeps, raise it for hard tasks.

Why this cuts cost without cutting quality

The naive way to save tokens is to feed the agent less — but blind truncation drops the wrong things and the agent flails, costing more in retries. Context Engine saves tokens the other way: by spending the budget on the highest-signal spans first. You are not sending less context, you are sending better context. That is what keeps quality up while the token count comes down.

Works across every agent you use

The same token-budgeted context pack is available to Claude Code, Cursor, Codex, Windsurf, or any MCP-compatible client — one config block each. If you run more than one agent, they all draw from the same fresh index of your codebase.

Whole-file reads vs. a token-budgeted pack

Context EngineDefault read + grep
Unit returnedRelevant spans, de-dupedWhole files
Repeat costAlready-seen files skippedRe-read and re-billed each turn
CeilingHard token budget per callNone — grows with the session
Context windowStays leanBloats, triggers auto-compact
Quality under budgetHighest-signal spans firstBlind truncation loses detail

FAQ

How much can I save?

It depends on your repo and how the agent was searching before, so we do not quote a fixed percentage. The mechanism is concrete: no whole-file reads, no re-reading already-seen files, and a hard budget per call. The free quota lets you measure the difference on your own codebase.

Does a lower budget hurt answer quality?

Less than blind truncation does. The budget is spent on the highest-signal spans first, so a smaller budget still carries the code that matters. You can raise it for hard tasks and lower it for cheap sweeps.

How is the budget enforced?

You pass tokenBudget on the codebase_context call. The pack is assembled span by span and stops when it reaches the budget, returning how many tokens it actually used and whether it truncated.

Which agents does it work with?

Any MCP client — Claude Code, Cursor, Codex, Windsurf and others. It is a remote MCP server, added with one config block.

Is it free to try?

Yes, there is a free quota on signup with GitHub.

Related

Stop paying for the same files twice

Put a token budget on your agent’s codebase context. Sign in with GitHub and try it free on your own repo.

← Back to home