L
LLLOS.ai
Career
L
◆ AI Learning · Situational

What concrete steps reduce the cost of a Claude Code session without changing the work?

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

The rule

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.

Words you'll need

Resolved from this lesson's own record — real definitions, not invented for this page.

Prompt Engineering

Crafting questions to get better AI responses

Computational Efficiency

How much computing power a task actually needs

Resource Allocation

Deciding who gets what when there is not enough

Questions people ask

More from the same record, pulled by shared topic — not written new for this page.

How can an AI model avoid re-reading files it has already processed?

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.

How can an AI model quickly find quotes, proverbs, or idioms?

An AI model can use a fast, local database for common expressions. This database should contain curated quotes, proverbs, and idioms.

How can an AI model fix many small errors efficiently?

A developer can ask an AI model to check many items at once. The AI model looks for things like typos or missing information.

Why did moving from a 200K to a 1M context window make Claude Code sessions more expensive, not just longer?

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.

What to remember

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.