Cost Optimization
Claude Code is powerful, but used carelessly, costs add up fast. Once you understand token efficiency and build the right habits, you can cut costs dramatically while keeping your productivity.
Understanding the Cost Structureโ
Subscription vs APIโ
| Method | Cost model | Where to check usage |
|---|---|---|
| Max/Pro subscription | Flat monthly fee, usage included | /stats |
| API key | Billed by token usage | /cost |
| Bedrock/Vertex | Billed by the cloud provider | Cloud console |
/cost shows API token usage and cost. If you're on a Max/Pro subscription, your usage is included in the subscription, so use /stats to review your usage patterns instead.
Average Cost Benchmarksโ
- Typical developer: about $13 per active day; 90% of users stay under $30 per active day
- Monthly: $150โ250 per developer (varies widely with concurrent instances and level of automation)
These are enterprise-environment figures from the official docs (code.claude.com/docs/en/costs). If you're using a subscription, these amounts have nothing to do with your bill.
Building Token Intuitionโ
- 1 English word โ 1.3 tokens
- 1 Korean character โ 1.5โ2 tokens
- 100 lines of code โ 1,000โ2,000 tokens
- A typical file โ 500โ5,000 tokens
The Main Drivers of Cost Growthโ
1. Unnecessarily Long Conversation Sessionsโ
The longer the conversation, the more all previous messages get included as input every single time.
# When the task changes, reset the context with /clear
> /clear
# Name the session before clearing so you can come back with /resume
> /rename auth-module
> /clear
2. Overly Broad Requestsโ
# Inefficient: exploring everything
> Analyze the project structure and find problems
# Efficient: scoped
> Analyze only the error handling patterns in the src/api/ directory
3. Repeating the Same Contextโ
Instead of re-explaining the same background every time, define it once in CLAUDE.md.
4. Retries Caused by Low-Quality Promptsโ
Vague request โ wrong result โ correction request โ repeat. Be precise from the start.
Token-Saving Strategiesโ
Strategy 1: Context Managementโ
# Separate contexts between tasks with /clear
[Feature A done]
> /clear
# Compress the context with /compact (custom instructions supported)
> /compact Summarize with a focus on the code samples and API usage
You can also set default compaction instructions in CLAUDE.md:
# Compact instructions
When compacting, focus the summary on test output and code changes
Strategy 2: Optimize Model Selectionโ
# Use Haiku for simple tasks
claude --model claude-haiku-4-5-20251001 "Convert this JSON to a TypeScript interface"
# Switch models mid-session
> /model
- Sonnet: fits most coding tasks and is cheaper than Opus
- Opus: use for complex architecture decisions or multi-step reasoning
- Haiku: best for simple conversion, classification, and formatting tasks
Setting model: haiku in a subagent configuration cuts the cost of simple tasks.
Strategy 3: Tune Extended Thinkingโ
Extended Thinking is enabled by default (31,999-token budget), and thinking tokens are billed as output tokens:
- Adjust Opus's effort level via
/modelor/effort - Disable thinking in
/config - Cap the budget with an environment variable:
MAX_THINKING_TOKENS=8000
Note that Fable 5 is the exception โ thinking can't be turned off (the /config toggle and MAX_THINKING_TOKENS=0 have no effect), and it always runs adaptively with no fixed budget. On Fable 5, control thinking depth via the effort level (for a one-off deeper pass, add ultrathink to your prompt). Its pricing is also 2x Opus 4.8 ($10/$50 vs $5/$25), so it's not recommended for cost-sensitive work.
Strategy 4: Reduce MCP Server Overheadโ
Each MCP server adds its tool definitions to your context:
- Prefer CLI tools:
gh,aws,gcloud,sentry-cli, and the like are more context-efficient - Disable unused servers: review in
/mcpand turn off what you don't need - Tool Search: when MCP tool descriptions exceed 10% of the context, they're lazy-loaded automatically. Set the threshold with
ENABLE_TOOL_SEARCH=auto:<N>
Strategy 5: Isolate Verbose Output in Subagentsโ
Delegate output-heavy work โ running tests, fetching docs, processing logs โ to subagents. The verbose output stays in the subagent's context, and only a summary returns to the main conversation.
Strategy 6: Use Hooks and Skillsโ
- Hooks: preprocess data before Claude sees it (e.g. extract only the errors from a 10,000-line log)
- Skills: provide domain knowledge without file exploration
// settings.json โ a Hook that filters test output
{
"hooks": {
"PreToolUse": [
{
"matcher": "Bash",
"hooks": [
{
"type": "command",
"command": "~/.claude/hooks/filter-test-output.sh"
}
]
}
]
}
}
Strategy 7: Split CLAUDE.md into Skillsโ
- Keep
CLAUDE.mdwithin ~500 lines - Move specialized instructions (PR reviews, DB migrations, etc.) into Skills
- Skills load only when invoked, so your baseline context stays small
Team Cost Managementโ
Workspace Spend Limitsโ
When using the API, you can set an overall spend limit for the Claude Code Workspace in the Console. On first authentication, a "Claude Code" workspace is created automatically, enabling centralized cost tracking.
Recommended Rate Limits by Team Sizeโ
| Team size | TPM / user | RPM / user |
|---|---|---|
| 1โ5 | 200kโ300k | 5โ7 |
| 5โ20 | 100kโ150k | 2.5โ3.5 |
| 20โ50 | 50kโ75k | 1.25โ1.75 |
| 50โ100 | 25kโ35k | 0.62โ0.87 |
| 100โ500 | 15kโ20k | 0.37โ0.47 |
| 500+ | 10kโ15k | 0.25โ0.35 |
As teams grow, the share of concurrent users drops, so per-user TPM decreases. Rate limits apply at the organization level.
Agent Teams Token Costโ
Agent Teams run multiple Claude Code instances simultaneously, each maintaining its own context window:
- In Plan mode, roughly 7x the token usage of a regular session
- Cost management tips:
- Use Sonnet for teammates (balance of capability and cost)
- Keep the team small
- Make spawn prompts specific
- Clean up the team when the work is done
Background Token Usageโ
Claude Code uses a small amount of tokens even while idle:
- Summarizing previous conversations (for
claude --resume) - Processing commands like
/cost
Typically under $0.04 per session.
Cost vs Productivityโ
Don't sacrifice productivity by obsessing over cost savings. Even if you spend $1 on Claude Code, it's more than worth it if it saves you 10 minutes on the task.
Tasks where you should spend freely on Claude:
- Complex refactorings that would take days
- Unfamiliar tech stacks
- When you're stuck identifying the cause of a bug
- Repetitive, tedious bulk work
Tasks where you should save the cost:
- Easy work you already know how to do
- Information lookups a simple search can answer
- Code under 10 lines that's faster to write yourself
Efficient Work Habitsโ
- Use Plan mode: press
Shift+Tabto plan and explore before implementing complex work - Change direction fast: interrupt a wrong direction with
Esc; roll back with/rewindorEsc+Esc - Provide verification criteria: supply test cases, screenshots, and expected output up front
- Test incrementally: write one file โ test โ move on
Checklistโ
- Describe your project context thoroughly in
CLAUDE.md(within ~500 lines) - Make
/cleara habit when switching tasks - Use the Haiku model for simple tasks
- Scope requests specifically instead of asking broadly
- Disable unused MCP servers
- Move specialized instructions into Skills
- Verify team Rate Limit settings