Using a coding agent
Reduce token usage in Claude Code
Claude Code already does 3 of the fixes for you, and 8 settings cut more. Each setting below links to the page it was read on.
Try it on one of your agent's tasks
The optimizer is set to Claude Code. Describe a task, and the fixes come back ranked for this harness.
StackOne agentFixing your agent
Example result
Claude Code
ServiceNow List Incidents
Your agent answers in 0.6 s, not 2.4 min
Same question, answered from a synced copy of your ServiceNow data: 50 live calls become 2 reads.1,2
Share
| Switch | Setting | Today | With fixes |
|---|---|---|---|
| Deep Query | 50 live calls · 2.4 min | 2 reads · 0.6 s | |
| Model | Opus 5.5 $107 a month | Haiku 5.5 $2.66 a month | |
| Thinking | High effort | Low effort | |
| Side tasks | Main model | Small model | |
| Unused tools | Loaded | Switched off | |
| On | Prompt cache | Already on in Claude Code | |
| On | Old results | Already on in Claude Code | |
| On | Tool search | Already on in Claude Code |
The fixes, biggest saving first
Deep QueryStackOne50 → 2 calls1
Data Sync keeps a copy of ServiceNow List Incidents, so 5,000 records take 2 reads instead of 50 live calls.
The live API returns 100 a page, assumed.
Waiting 2.4 min → 0.6 s at production averages; 33% to 74% fewer tokens per connector on 1,345 benchmark tasks.2
Data Sync on ServiceNow List Incidents
list_incidents_s1querywith filter, source and aggsRun it on Haiku 5.5$107 → $2.66 a month3,1
This task doesn't need Opus 5.5.
Haiku 5.5 for counts and lookups, Sonnet 5.5 for filtering and summarising, Opus 5.5 for multi-step work. This one is counts, totals and lookups, where Deep Query or the API does the work and the model reads one small result, so Haiku 5.5 fits. Check it on your own runs first.
Over 1,000 runs, the 27K tokens of tool definitions per request cost $107 a month on Opus 5.5, $53 on Sonnet 5.5 and $2.66 on Haiku 5.5, at list input prices.
Claude Code
Model: haiku # in a subagent's file
Measure what fills the window
See what fills the window before you change anything.
Claude Code
/context,/usage,/skill-doctor,/doctorprompt-auditKeep instruction files short
Instruction files load into every session.
Claude Code
Keep
CLAUDE.mdunder 200 lines; move detail into skillsRun side tasks on a smaller model
Searches and file reads rarely need a frontier model.
Claude Code
Model: haiku in the subagent's file, or
CLAUDE_CODE_SUBAGENT_MODEL=haikufor allKeep live questions liveStackOne
Keep the live action for questions about one record or the provider's state this minute.
Your agentKeep the live action next to the
_s1querytoolLower the effort setting
Counting and retrieval rarely need high effort.
Claude Code
/effortlow for lookups, orCLAUDE_CODE_EFFORT_LEVEL=lowTurn off tools you don't use
Switch off servers and tools this agent never calls.
Claude Code
/mcpto switch off servers you don't use; prefer CLIs such as gh over an MCP serverTool PoliciesStackOne
Narrow which actions and fields the agent can use, per project.
No token figure: it's a control.
StackOne
Tool Policies on the project
7 more we checked
- Already onLoad tools when neededClaude Code already loads tool definitions when needed, so the 27K tokens don't load up front.
- Already onPrompt cachingAlready on in Claude Code: the prompt is cached for you; ENABLE_PROMPT_CACHING_1H=1 keeps it an hour on API keys.
- Doesn't fitLet the agent run code over results2 calls left, and Anthropic reports no gain on flows of one or two calls.
- Already onClear old tool resultsAlready on in Claude Code: auto-compaction summarises old turns; CLAUDE_AUTOCOMPACT_PCT_OVERRIDE=50 makes it compact earlier.
- Doesn't fitCap tool outputDeep Query already returns a small result.
- Doesn't fitRead web pages as textYour task doesn't browse the web.
- Doesn't fitBatch scheduled jobsYour agent answers people live.
Sources
- Arithmetic on your inputsEstimated from your inputs
- StackOne production averageMeasured by StackOne
- Published list pricePublished by the vendor or in our docs
How we worked this out
This result
- ServiceNow: 77 actions; matched List Incidents (
list_incidents, Data Sync available). - Records: 5,000, you gave. Runs: 1,000 a month.
- Calls: 50 live calls at 100 records a page, assumed, 2.9 s each in production. Deep Query: 2 reads at 0.3 s.
- Tool definitions: 27K tokens with every tool loaded, 7.8K with tool search, from our benchmark or its median per tool.
- Matched by rules over the catalogue. Rules do every calculation.
How every result is worked out
- Matching
- Your question is matched to connectors and list actions in StackOne's catalogue of 770+ connectors, and to the list actions Data Sync can copy. An action has to share a word with your question, so no match is shown rather than an unrelated one.
- Live calls
- A list action pages through every record a question covers, at the page size its config sets, or 100 when it doesn't say, and the result says which. Each live call takes 2.9 s, the production average over two weeks of traffic.
- Deep Query
- Two reads, 0.3 s each on average in production: the queryable fields, then the query. Tokens are 33% to 74% lower per connector across 1,345 benchmark tasks. On a single page, the optimizer makes no Deep Query claim.
- Tool definitions
- Input tokens per request with every tool loaded and with Tool Search are measured per connector on our benchmark of 47 connectors. For other connectors we multiply the action count by the median, about 346 tokens per tool, and mark it as an estimate.
- Ranking
- Rules decide which fixes apply and do every calculation, in your browser. Fixes with a sourced number show it; fixes without one say why they apply and show no number. Vendor figures are labelled as the vendor's own.
Benchmark and production figures are explained on the Deep Query page and the Tools Discovery page. Your own systems will differ.
Want us to look at your agent with you?
Go through your harness, your apps and these numbers with our engineers.
What Claude Code already does
These are on by default, so there's nothing to change.
-
Load tools when neededOn by default
Tool search defers MCP tools (ENABLE_TOOL_SEARCH, auto:N to tune).
code.claude.com, read 30 Nov 2026 -
Prompt cachingOn by default
The prompt is cached for you; ENABLE_PROMPT_CACHING_1H=1 keeps it an hour on API keys.
code.claude.com, read 30 Nov 2026 -
Clear old tool resultsOn by default
Auto-compaction summarises old turns; CLAUDE_AUTOCOMPACT_PCT_OVERRIDE=50 makes it compact earlier.
code.claude.com, read 30 Nov 2026
Settings that cut more in Claude Code
Off until you turn them on. The ones that matter most for coding agents come first.
-
code.claude.com, read 30 Nov 2026/context,/usage,/skill-doctor,/doctorprompt-audit -
code.claude.com, read 30 Nov 2026/mcpto switch off servers you don't use; prefer CLIs such as gh over an MCP server -
Let the agent run code over results Experimental
code.claude.com, read 30 Nov 2026CLAUDE_CODE_EXPERIMENTAL_CODE_MODE=1(v2.1.323 or later, interactive terminal) -
code.claude.com, read 30 Nov 2026MAX_MCP_OUTPUT_TOKENS(default 25,000) andBASH_MAX_OUTPUT_LENGTH(default 30,000 characters) -
github.com, read 30 Nov 2026npm i -g agent-browser, thennpx skills add vercel-labs/agent-browser -
Keep
code.claude.com, read 30 Nov 2026CLAUDE.mdunder 200 lines; move detail into skills -
Run side tasks on a smaller model
Model: haiku in the subagent's file, or
code.claude.com, read 30 Nov 2026CLAUDE_CODE_SUBAGENT_MODEL=haikufor all -
code.claude.com, read 30 Nov 2026/effortlow for lookups, orCLAUDE_CODE_EFFORT_LEVEL=low
With StackOne
What changes when Claude Code reaches your business apps through StackOne's Tool Gateway MCP server, which connects to it as one MCP server.
-
Add
https://mcp.stackone.com/mcp, then ask in plain words33% to 74% fewer tokens per connector across 1,345 benchmark tasks; 0.3 s per read against 2.9 s per live call in production. How it was measured
-
Add
https://mcp.stackone.com/mcp; Advanced Tool Search is on by default3.8x cheaper per request than loading every tool, across 824 tasks; Anthropic reported over 85% fewer tool-definition tokens with its tool search. How it was measured
-
Source on any
_s1querycallOne benchmark list went from 1.33M tokens to 18.9K for the same correct answer. How it was measured
-
Keep the live action next to the
_s1querytool -
Tool Policies on the project
Other techniques for coding agents
How well each one fits this kind of agent. Open one for the setting in every harness that has it.
-
Batch scheduled jobsNot available
Interactive.