Anthropic Releases Official Cost-Optimization Guide for Claude Code
Just now, Anthropic published an official blog post with a clear and urgent message: “Stop wasting tokens — we can’t watch you overspend anymore.”
The post reveals that many developers are unintentionally inflating their Claude Code usage costs by orders of magnitude — not due to model limitations, but through suboptimal interaction patterns. To help users maximize value, Anthropic details six actionable, engineering-first optimization strategies.

✅ Six Proven Cost-Saving Techniques
-
/clearafter every task
Reset context immediately after resolving a bug or completing a task. Avoid carrying forward irrelevant files, command outputs, or exploration history into the next session — each retained token incurs cost in every subsequent round-trip. -
Lock model and effort level upfront
Switching models (e.g., Sonnet → Opus) or adjusting inference intensity (/effort) invalidates the entire prompt cache. Prefill computations must be re-run at full price — no discount applies. -
Use
@filereferences — never raw paths
Attach files directly via@filename.txt. This bypasses costly tool-calling overhead and prevents Claude from blindly scanning multiple files (which bloats history with failed attempts). -
Enable quiet flags for verbose commands
Configure CLI tools like Vitest with compact reporters (e.g.,--reporter=dot). Replace 400-line test logs with 3-line summaries — dramatically reducing output token volume. -
Run
/compactbefore idle breaks
Compressing active cache costs just 10% of normal prefill. Wait until cache expires? You’ll pay full price to reload and compress — a 10× penalty. -
Delegate heavy-output tasks to subagents
Subagents operate in isolated contexts. They execute file reads, command runs, and analysis internally — only returning concise conclusions. No intermediate artifacts pollute your main conversation.

💡 Understanding Token Economics
Every Claude Code interaction involves two distinct phases:
- Prefill (input tokens): Parallel GPU processing of system prompts,
CLAUDE.md, messages, and full conversation history. - Decode (output tokens): Serial token-by-token generation — including reasoning steps, tool calls, and final output.
⚠️ Critical insight: Output tokens cost up to 5× more than input tokens — because decoding is computationally serial and latency-sensitive.
| Model | Input ($/M tokens) | Output ($/M tokens) |
|---|---|---|
| Opus 5 | $5.00 | $25.00 |
| Sonnet 5 | $2.00 | $10.00 |
| Haiku 4.5 | $1.00 | $5.00 |
💡 Rule of thumb: Use Sonnet for routine tasks; reserve Opus only for high-stakes, complex reasoning.

🧠 Prompt Caching: Your Biggest Leverage Point
Claude Code caches identical request prefixes — saving 90% on prefill cost (just 0.1× base rate). But cache hits require byte-perfect prefix matches. Six common pitfalls break it:
- 🔁 Switching models (
/model opus) - ⚙️ Changing effort level (
/effort max) - ⚡ Toggling Fast Mode
- 📄 Running
/compactmid-session - ⏳ Cache expiration (1 hr for subscribers, 5 min for API users)
- 🔄 Resuming stale sessions
✅ Pro tip: Lock model + effort at session start, defer /compact to idle time, and avoid opusplan mode’s repeated model switching.

📉 Why Your Session Is Silently Getting Heavier
Each file read or command output appends content to your history. By round #40, you’re re-sending all prior rounds’ cumulative tokens — resulting in near O(n²) growth.
Claude Code caps raw output at 30,000 chars (then uses temp files), but smaller outputs — like 400-line test reports — persist fully in history. Every round carries them forward.
Smart “Diet” Tactics:
- ✅
@fileinstead of manual path lookup - ✅ Quiet CLI flags (
--reporter=dot) - ✅ Subagents for log scanning / large-file review
- ✅
/clearbetween unrelated tasks - ✅
/rewindto discard missteps without breaking cache

🌐 Token Awareness: A New Developer Competency
This isn’t just about saving dollars — it’s about cultivating LLM-native engineering discipline. Anthropic’s own engineers report:
- 80% of production code written with AI
- 8× increase in merged PRs/year
- 52× acceleration in benchmark iteration
Without token hygiene, those gains would vanish under runaway inference costs.
🎯 The core skill isn’t using AI — it’s orchestrating it: selecting models wisely, guarding cache integrity, managing context weight, and calibrating inference depth. That’s how $3 tasks stay $3 — not $30.

Source: Anthropic Blog: Maximizing the Value of Your Claude Code Sessions