Four levers — /clear between unrelated topics, /compact mid-task, /cost to surface surprises early, and Sonnet for routine sessions — cut Claude Code cost without cutting capability.
By Pawan Nayar · from the LLOS AI Learning record
Four levers — /clear between unrelated topics, /compact mid-task, /cost to surface surprises early, and Sonnet for routine sessions — cut Claude Code cost without cutting capability.
/clear resets the context completely. Use it when a topic changes so the new conversation does not carry the weight of the old one. /compact summarises the current history and discards the raw turns. Run it when a long session is going well but growing expensive. /cost shows the running bill. Check it at natural pauses so a $2 surprise stays $2 and does not reach $40. On model choice: Sonnet runs at roughly 40% of Opus 5's per-token cost. Use Sonnet for routine sessions — scaffolding, small edits, explanation. Reserve Opus for long agentic runs where fewer retries justify the higher rate. Cache hits cost one tenth of standard input — repeated system prompts and static context become nearly free on a warm cache.
A developer switches from Opus to Sonnet for day-to-day Claude Code work, runs /compact every 30 minutes, and checks /cost at each break. A week's bill drops from $120 to $28 with no change in output quality.
Resolved from this lesson's own record — real definitions, not invented for this page.
More from the same record, pulled by shared topic — not written new for this page.
An AI model should first state what it already knows from a file. If the AI model can recall the information, it does not need to read the file again.
An AI model can use a fast, local database for common expressions. This database should contain curated quotes, proverbs, and idioms.
A developer can ask an AI model to check many items at once. The AI model looks for things like typos or missing information.
When Claude Code hit the 200K context limit, it compacted the history — summarising and discarding old turns. This was friction, but it was also a cost governor.
Four levers — /clear between unrelated topics, /compact mid-task, /cost to surface surprises early, and Sonnet for routine sessions — cut Claude Code cost without cutting capability.