Skip to main content
Most Claude Code spend is cache reads and cache writes: across 105 organisations on LangWatch over 30 days, cache reads were 49% of API-equivalent spend and cache writes 32%. The settings below change how much context each call carries, how often it is written again, and which model reads it. The skill on this page reads your sessions, runs one check per recommendation, and writes a report with the ones your data supports. Each recommendation states its evidence, the settings.json change and the expected saving.

How you pay changes what a saving means

On a Claude subscription a saving is more work before you reach the plan’s usage limits. LangWatch shows those sessions in API-equivalent USD, the price the same tokens would have at Anthropic’s list prices. On an API key, Amazon Bedrock, Google Cloud, Microsoft Foundry or usage credits, every token is billed, and a saving is cash.

Run the check

Where can my coding agents save tokens?
Install via CLI
npx skills add langwatch/skills/coding-agent-cost
Skill Usage
/coding-agent-cost
Copy Full PromptRun skill without installing
Download SKILL.mdManual installation

The recommendations

Measured means a controlled A/B run on the same tasks, described in Run your own cost experiments. Estimated means the same tokens repriced or re-simulated from 30 days of real sessions. Ranges are per organisation where the check fires, as a share of its Claude Code spend. The savings overlap. An old Opus running your sub-agents counts in the first and fourth rows, and a long session counts in the compaction and split rows, so the rows do not add up.

The prompt cache lifetime

Claude Code caches each request for five minutes or one hour. On a subscription within plan usage, the main conversation gets one hour and sub-agents five minutes. On an API key, a cloud provider or usage credits, everything gets five minutes. A one-hour write costs 2x the base input price and a five-minute write 1.25x. With five minutes, a pause of 5 to 60 minutes expires the cache and the next call writes the whole context again. Applied to 101 organisations’ real pause patterns, the one-hour main cache comes out cheaper for 84 of them. For sub-agents it came out cheaper for none of 95, because their calls run back to back. So pay-per-token users should set "promptCacheTtl": "1h" (Claude Code v2.1.242 or later) and leave subagentPromptCacheTtl alone. To see which lifetime your main conversation uses, run claude -p "hello" --output-format json and read usage.cache_creation: one-hour writes are under ephemeral_1h_input_tokens, five-minute writes under ephemeral_5m_input_tokens.

Put settings in settings.json

A value in the env block of any settings.json wins over a shell export, so the export can be silently ignored. Put each setting in ~/.claude/settings.json, in the project’s .claude/settings.json, or in managed settings for a team. Check every level for a conflicting value first, including ANTHROPIC_MODEL, CLAUDE_CODE_AUTO_COMPACT_WINDOW and CLAUDE_CODE_PROMPT_CACHE_TTL in an env block, because each environment variable overrides the setting of the same purpose. The sub-agent model has no setting of its own, so it goes in env.
~/.claude/settings.json
Pay-per-token users add "promptCacheTtl": "1h".

Check the effect

Run the same check on a window that starts after the change. The sessions list shows peak context, compactions and cost per session, and usage analytics shows the model mix and cache split over time. Also check: Run your own cost experiments to measure a setting on your own work before rolling it out, and Find your context sweet spot to pick a compaction window from your own sessions.
Last modified on October 12, 2026