Invite & Earn

How invite rewards work

Share your invite link. When a friend registers through it and tops up, you receive the displayed reward on their subsequent top-ups.

Claude Code Context Usage: Diagnose Unnecessary Tokens

Measure one repeatable Claude Code task with /context and /usage, isolate token noise, compare A/B metrics, and verify correctness.

Contents

In the Claude Code community, a user reported that a fresh session started at roughly 35,000 tokens and later dropped to about 13,000 after cleaning up repository instructions. That is a useful reminder to inspect your own project setup, but not a universal benchmark: codebase size, instruction length, MCP tools, and measurement methods differ across projects.

You can inspect your setup in two controlled runs. Measure baseline context using native Claude Code commands and API metadata, modify exactly one reversible context source, and repeat the same request. Then compare token usage, cost, and task correctness.

Measure baseline context with built-in commands

You do not need to guess context sizes. Claude Code provides native commands:

  • /context — displays the breakdown of active context: project instructions, connected MCP tools, cached files, and conversation history;
  • /usage — shows the usage information available for the current account and authentication mode. Depending on the version and sign-in method, this may include plan usage, activity, credits, or session token statistics; a cost status line may be available for API users, but no field should be assumed universally.

For a separate API workflow, the API Dashboard provides per-request accounting: input tokens, output tokens, cache hits, HTTP status, and actual balance charges.

Use one task with a checkable answer

Start with a small read-only query that does not modify files:

Find where validateInvoice is defined.
Name the function file and one test that checks an empty amount.
Do not edit anything.

This request produces a clear binary outcome: two correct file paths or a failure.

Before running, fix the baseline variables:

  • identical Git branch and commit revision;
  • identical prompt text;
  • identical model selection;
  • identical project instructions, skills, and MCP tools;
  • expected target paths for the function and test.

Run A: record the baseline metrics

Open a fresh session, execute /context to inspect baseline load, run the test query, and record the metadata:

FieldRun A
Request statusrecord the actual value
Input tokensrecord the actual value
Output tokensrecord the actual value
Cache tokensactual value or not shown
Cost / chargeactual value or not shown
Resultcomplete / partial / error

Do not substitute zero for a missing metric. Record live values from the current Claude Code interface or the dashboard for the selected API path, and mark unavailable fields as not shown.

Do not include API keys, private source code, full proprietary prompts, or sensitive logs in notes. Metadata, source names, and task outcomes are sufficient.

Prioritized diagnostics order

Do not disable all configuration at once. Investigate context sources in priority order:

  1. Project Instructions (CLAUDE.md) — check for outdated build logs, duplicated API specs, and oversized reference blocks.
  2. MCP Servers and Skills — disconnect heavy external tools that are not needed for the current isolated task.
  3. Session History — ensure old tasks or long terminal outputs are not polluting context (use /compact or start fresh with a handoff if needed).
  4. File Read Scope — restrict search scope to specific directories if the agent scans the entire repository tree.

Suppose CLAUDE.md contains a 12,000-line build log. Make one reversible change: move the log to docs/build.log and keep a concise pointer in CLAUDE.md. Do not change the model, MCP tools, or prompt at the same time.

Run B: repeat the query and compare metrics

Keep the revision, model, and prompt unchanged. After the single modification, rerun the request and complete the A/B comparison table:

FieldRun ARun BDifference
Request statusactualactualcompare
Input tokensactualactualB - A
Output tokensactualactualB - A
Cache tokensactual or not shownactual or not showncalculate only with two values
Cost / chargeactual or not shownactual or not showncalculate only with two values
Function foundyes / noyes / nosame criterion
Test foundyes / noyes / nosame criterion

If input tokens dropped but Run B identified the wrong test or ignored a mandatory project constraint, the change degraded performance. Restore the original instruction.

Step-by-step verification

Retain configuration changes only when all five criteria are met:

  1. Single variable per test: exactly one context source changed.
  2. Maintained accuracy: the function and test are correctly located.
  3. Constraint preservation: safety, styling, and architectural rules remain enforced.
  4. Usage confirmation: /usage and the dashboard confirm expected metadata changes.
  5. Secondary confirmation: the result is reproduced on one more small task.

Compare API usage in BetterToken Dashboard

For your own API workflow, the BetterToken Dashboard displays balance, active model, exact timestamp, HTTP status, input, output, and cache tokens, along with the resulting charge. Match records by timestamps from Runs A and B and record them in your comparison table. The dashboard stores request metadata without storing complete private prompt text or responses.

BetterToken provides independent Anthropic-compatible API access with pay-as-you-go billing, separate from Claude.ai subscriptions. Check the current BetterToken documentation for Claude Code, generate an API Key in your workspace, and track token usage directly in the dashboard.

Diagnostic summary

The purpose of context optimization is removing irrelevant noise without losing essential context. Measure baseline context with /context and /usage, adjust one source at a time, verify task accuracy, and cross-reference API usage metadata.

Sources

Ready to optimize your LLM workflow?

Join thousands of developers building faster, smarter, and more cost-effective AI applications with BetterToken.

Get Started for Free