← Reports
Report preview
Buy report
01/00·Title
Agentic Coding Economics · Engineering Research · June 2026

Claude Code Token Optimization: Context, Tools, and Compaction Cost

Chander Dhall
Chander Dhall Builder • Leader • Speaker

A source-backed engineering report on where Claude Code spends tokens and the documented controls, tool search, prompt caching, CLAUDE.md discipline, compaction, and subagents, that cut waste without hiding project context.

Snapshot

The highest-value controls are visible in the docs.

The report keeps only source-backed metrics and treats savings as workload-dependent unless the cited source gives a number.

Source-backed10-20K

Tool definitions can consume this many tokens for 50 tools.

Source-backedTool search

Loads relevant tools on demand instead of carrying every schema.

Source-backedPrompt caching

Rewards stable reusable context and disciplined project memory.

Source-backed/compact

Summarizes long conversations when old detail stops paying rent.

Cost Surface

Token waste usually comes from repeated context, not one bad prompt.

Claude Code token usage is dominated by repeated context: instructions, project memory, tools, MCP surfaces, prior messages, file content, command output, web content, images, and compaction summaries.

Decision Rule

Short durable context, scoped tools, measured output, and deliberate compaction beat blanket context hoarding.

Risk

Always-on instructions

Large memory files and broad project docs are paid for repeatedly.

Control

Scoped surfaces

Expose only the tools, files, and context needed for the current workflow.

Discipline

Measure first

Usage commands and context inspection prevent guesswork.

Primary Lever

Tool Search Changes the Math

Large tool libraries should be discoverable, not permanently loaded.

What changes

Anthropic describes the context pressure directly: 50 tools can consume 10K-20K tokens. Tool search reduces that pressure by discovering relevant tools on demand.

Controls

The practical levers are small enough to operate.

Tool search

Discovers and loads needed tools on demand.

Use for large custom tool or MCP catalogs.

Tool names and descriptions

Search matching uses tool names and descriptions.

Make tools searchable and specific so fewer retries are needed.

CLAUDE.md discipline

Project memory is loaded into context at session start.

Keep base memory short and move workflows into on-demand skills.

Source-backed number
10-20K

Tool definitions can consume this many tokens for 50 tools.

Do not convert this into a universal savings percentage. The report keeps the number tied to its original source and context.

Decision Matrix

Controls map to operating decisions.

LeverDocumented behaviorOperating decisionSource
Tool searchDiscovers and loads needed tools on demand.Use for large custom tool or MCP catalogs.[claude-tool-search], [anthropic-tool-search]
Tool names and descriptionsSearch matching uses tool names and descriptions.Make tools searchable and specific so fewer retries are needed.[claude-tool-search]
CLAUDE.md disciplineProject memory is loaded into context at session start.Keep base memory short and move workflows into on-demand skills.[claude-costs]
/compact and /clearCompaction and clearing are documented context controls.Compact at milestones and clear after commits or task changes.[claude-costs]
Preprocessing hooksCommand output can be filtered before it enters context.Trim noisy logs and long tool results.[claude-costs]
Workflow

Lowest-waste default workflow

The operating pattern keeps useful context close and noisy context out of the recurring prompt path.

1

Check usage

Check cost or usage commands before and after large tasks in the installed Claude Code build.

2

Use tool search

Use tool search for large tool catalogs and keep MCP servers project-scoped.

3

Keep CLAUDE.md lean

Keep CLAUDE.md stable and concise so prompt caching can help.

4

Read targeted ranges

Read targeted line ranges and symbols instead of whole files.

5

Filter noisy logs

Filter tests and build logs to failing cases.

Integrity

Claims Removed or Downgraded

The older report included fixed token counts for Claude Code hidden prompts, exact MCP totals, and version-specific behavior claims. This version keeps numbers only where Anthropic documentation supports them.

Approval rule

No fabricated stats, no fake case studies, no universal savings claims without a source-backed measurement path.

Source

[claude-costs]

Claude Code cost docs

Source

[claude-tool-search]

Claude Code tool search docs

Source

[anthropic-tool-search]

Claude API tool search docs

Full report · Claude Code economics

Make Claude Code cost a managed system.

Move from anecdotal token pressure to a source-backed operating model for tool search, context discipline, compaction, and measured engineering workflows.

A practical report for teams operating Claude Code at scale.

© 2026 Chander Dhall Methodworks, LLC. All rights reserved.
Get the complete report

Bring the controls into the room.

The full report turns the research into decisions your engineering team can operate.

  • Source-backed cost and context controls
  • Tool search and compaction workflow
  • Decision matrix for day-to-day use