How to Save Tokens in Claude Code
A practical guide ordered by impact, based on the official Claude Code documentation and Anthropic pricing as of November 2026.
Every time you send a message, Claude Code sends the whole conversation again: your prompts, Claude's answers, and every tool result. It does not read from a saved history; it reprocesses the full history at every step. So your usage is not just "what you typed" but the running total of everything said or read in the session. With prompt caching, the repeated history is read at a lower rate, but it still counts toward your usage with every message.
The takeaway: high cost comes from a bloated context window, not from bad prompt engineering. Most tactics below are about keeping the context light and focused.
Use the right model for the task
The model is the biggest factor in cost. The current default model in Claude Code on paid plans and through the API is Opus 5.5. At official API prices per million tokens (input/output), Opus 5.5 costs $4/$20 and Sonnet 5.5 costs $2/$10, so Opus costs about twice as much as Sonnet. Haiku 5.5 costs $0.10/$0.50 for prompts up to 100,000 tokens, about one twentieth of Sonnet. You can switch mid-session with /model and keep your context. When you run /model with a model name, your choice is also saved as the default for new sessions. To switch for the current session only, open the /model menu and press s on the model's row.
/model # show available models
/model sonnet # best everyday choice, cheaper than the Opus default
/model opus # for complex problems
/model haiku # for routine tasks
/model opusplan # hybrid: Opus plans, Sonnet executes
/effort low # less thinking for simple tasksFor mechanical tasks: renaming variables, writing boilerplate, formatting data, quick syntax questions. Fastest and cheapest, but not for complex logic.
Your default choice: handles most coding tasks well and costs less than Opus.
For complex engineering decisions: large-scale refactoring and tracking down subtle bugs. Keep it for when you hit a wall.
For hybrid work: Opus does the architectural thinking in Plan mode, then Claude Code switches to Sonnet automatically for execution. Good for planning features and restructuring.
Extended thinking tokens are billed as output. For simple tasks, lower the thinking level with /effort low. The default level on the 5.5 models is medium.
Note: on subscription plans, all models share the session and weekly limits, so switching with /model does not restore access once you reach them. You can continue on another model only if the message says you hit a model-specific limit, such as the Opus limit.
Set up CLAUDE.md properly and keep it short
The CLAUDE.md file holds your project's permanent instructions. Run /init to create it in the project root. Claude reads it automatically at the start of every session, which saves you from restating project rules each time.
The common mistake: the file stays in the context window for the whole session and you pay for it with every message. A large file takes up part of the context all the time.
The official docs recommend keeping each CLAUDE.md file under 200 lines. Include:
- A project summary and the features currently in progress.
- The tech stack.
- Code style and naming rules.
- Known bugs and upcoming TODOs.
Move instructions for specific workflows, such as reviewing pull requests or database migrations, into Skills or into rule files in .claude/rules/ that load only when needed. Importing a file with @path inside CLAUDE.md saves nothing, because the imported file loads with it at the start of the session.
Clear and compact the context (Clear & Compact)
As the context grows, the model suffers from context rot: it loses focus, older information gets lost, and it starts repeating earlier solutions or forgetting the original constraints. The fix is not a bigger window but knowing when to trim.
/clear
Clears the current session and starts fresh. Use it when you move to a completely different task, so old search logs stop using tokens. Running it costs nothing.
/compact
Summarizes the conversation and replaces the full history with the summary. The session continues and keeps the working context, but usage drops sharply. Use it at a natural stopping point. /compact reads the whole conversation to summarize it, so it is a large request in itself.
Two tips for compacting:
- Compact early: automatic compaction starts near the context window limit, at about 967K tokens on models with a 1M window. Compact manually at a natural stopping point, or make auto-compaction start earlier with
/autocompact 200k. - Steer the summary: put the template below under a
# Compact instructionsheading inCLAUDE.mdso it applies every time, or briefly say what to focus on after the command, for example/compact Focus on code changes and failing tests.
# Compact instructions
When compacting, preserve:
- current task goal
- files changed
- commands already run
- failing tests and exact errors
- decisions made
- next action list
Drop:
- old exploration paths
- repeated logs
- irrelevant discussionControl the size of tool output
Tool output (such as the terminal) is one of the biggest token consumers, because it fills the context and is sent again with every turn.
- Bash output limit: by default Claude Code shows about 30,000 characters of output inline and saves anything beyond that to a file. To lower the limit, set
"bashOutputMaxChars"insettings.jsonto a value between 4000 and 128000, as in the example below. - Filter logs before Claude sees them: do not pass raw logs; extract only the lines that matter.
{
"bashOutputMaxChars": 10000
}pnpm test 2>&1 | grep -A 5 -E "FAIL|ERROR|Error|failed" | head -120This gives Claude only the error lines with a little context, instead of thousands of lines of passing tests.
Be precise to avoid random searching
Vague prompts make Claude play detective: it searches the code and reads several files to understand the context, and every read is added to the context window. Precision saves tokens and time.
Give file paths directly
If you know the file path, say it. That removes the need for costly searches through the code.
Describe expected vs actual
When you report a bug, describe the expected behavior and the actual behavior precisely instead of in general terms.
Plan ahead: naming file paths and splitting the work means Claude does not need to read the whole codebase to find where to edit.
Use subagents wisely
Subagents are isolated copies of Claude with their own context windows. The main session hands a task to the subagent, which does the heavy work (searching, reading logs, multi-step analysis) in isolation and returns only the summary to the main conversation.
Subagents are great for keeping the main context light, but each one makes its own requests, and those count toward your usage. For simple tasks, set model: haiku in the subagent's settings.
When to use them:
- The task produces very long output you do not need to keep.
- Deep exploration of the code that could bloat the main session.
- Parallel research tasks, or restricting a task to specific tools.
How to write a good subagent prompt: ask for structured, bounded output:
# Bad: vague, returns too much
"Look at the codebase"
# Good: specific, bounded output
"Find all React components that handle user input forms.
For each, report: 1. File path 2. What data it collects
3. How it validates input. Return as a bullet list.
Skip components unrelated to user data."Monitor your usage
- Bookmark the usage page
claude.ai/settings/usage, or open Settings > Usage on claude.ai. - Run
/usagein the session to see its cost, your plan limits and a breakdown of what uses your allowance, with recommendations to reduce it./costruns the same command. - Run
/contextin the session to see context use as a colored grid, with suggestions to improve it. - Opus 5.5, Sonnet 5.5 and Haiku 5.5 run with a 1M-token context window by default. A bigger window does not mean you should fill it: context rot lowers answer quality before you reach the limit, and you pay for the full context with every message.
Quick checklist
/effort low for simple tasks./init and keep it under 200 lines..claude/rules/ that load only when needed./clear when you switch to a completely different task./compact after finishing part of a task, with clear instructions on what to keep and what to drop.bashOutputMaxChars, and filter logs with grep/head before passing them on./usage and /context commands.Sources: official Claude Code documentation (code.claude.com/docs: Manage costs, Model configuration, Commands, Memory, Tools reference) and the Anthropic pricing page (platform.claude.com/docs/en/about-claude/pricing). Checked November 2026. Prices and models change, so always check /model and /usage.
Want your team to use this at work?
I'm Abdulaziz Alshamsi, a certified AI trainer and consultant in Abu Dhabi. I train government and company teams to use AI in their daily work. Message me to discuss a session for your team.