With token-based AI coding tools like Claude Code, your editor no longer costs a flat fee — every edit has a price, and the same task can cost very different amounts depending on how you structure your session. Anthropic engineer Lydia Hallie breaks down what actually determines those costs and how to make every token count.
The key mechanics:
- Prompt caching is your biggest lever. Reading from cache costs 0.1x the input price. But switching models, effort levels, or fast mode mid-session busts the cache and forces full re-prefill of every token in the conversation.
- @-mention files instead of naming paths. The file attaches directly to your first request, saving a Read call and the grepping the model would do on its own.
/clearbetween tasks. Irrelevant context from a prior task gets sent on every turn for the rest of the session — cheap per-turn, but it adds up and crowds the model’s attention window./compactbefore walking away. The prompt cache expires after an hour. Summarizing a warm cache is far cheaper than coming back to a cold one.
The less obvious traps:
- Noisy command output sticks around. A test runner printing 400 passing lines adds 400 lines to every remaining turn. Quiet flags (
--reporter=dot) or subagents for heavy commands keep the main context lean. /rewindbeats/compactfor recent missteps. Rewinding cuts turns off the end for free (cache survives). Compacting rewrites the whole conversation and always costs something.- Subagents run in their own context. Heavy jobs (logs, builds) stay in the subagent’s window — only the summary comes back to the main session. Define them with cheaper models for routine work.
The essay’s real contribution is framing cost optimization as a context-hygiene discipline: the same attention to prompt precision and session structure that makes agents more reliable also makes them cheaper. This pairs naturally with the argument from Don’t be a meat proxy — effective AI-assisted engineering requires deliberate craftsmanship, not just throwing more tokens at the problem.