12 Practical Tips to Save Tokens in Claude Code: From Context Management to Model Selection

Claude Code token consumption comes from accumulated context; you can systematically save money through diagnosis, clearing, leaner config, and matching models.
The article points out that every Claude Code request carries the full conversation history, and even with prompt caching the history still counts toward consumption, so "smaller context equals cheaper messages" is the core principle. The author gives 12 actionable methods: first diagnose where tokens go with /usage and /context, prioritizing lengthy CLAUDE.md, too many MCP tools, and huge file reads; use /clear to reset for free when switching tasks, and only use /compact when continuity is truly needed; keep CLAUDE.md to around 200 lines and move long workflows into on-demand Skills; disable unused MCP servers; match model and reasoning intensity to task difficulty with /model and /effort; ask precisely, plan first for big tasks, and hand noisy tasks to sub-agents; and use Hooks to pre-clean test output before data enters the context.
Why Are You Always Running Out of Tokens?
If you frequently hit your Claude Code usage limits, or your API bill keeps climbing, the problem is very likely context management. Understanding how Claude Code works is the first step to saving money: every time you send a message, it carries the entire conversation history—including your instructions, the files it has read, and all tool call results. Even with Prompt Caching enabled to make repeated history cheaper, this content still counts toward consumption. This means that if you ask a simple question in a session that's been open all day, you still pay for the context accumulated throughout the day.
The core principle is just one: smaller context means cheaper messages. The following 12 methods, from diagnosis to execution, help you systematically cut token consumption.
Prompt Caching is an optimization mechanism provided by the Anthropic API: when the prefix of a request (such as the system prompt, CLAUDE.md, or the first few turns of conversation history) is exactly the same as the previous request, that portion is billed at the cache read price, typically only about one-tenth of the normal input price, with lower latency as well. But the cache has a lifespan (about 5 minutes by default, refreshed on each hit) and expires after a period of inactivity, so the next message must reprocess the history at full price. In addition, caching only reduces the unit price, not the token count—the longer the context, the more significant the accumulated absolute cost remains even with cache hits. This is why the article repeatedly emphasizes "clearing is cheaper than compacting": /clear resets the context to zero, fundamentally eliminating the basis for repeated billing.
Diagnose First: See Where Your Tokens Go
Use /usage and /context to Locate the Big Spenders
You can't fix what you can't see. Two commands are the starting point: type /usage, and API users can view the token usage and cost for the current session; Pro or Max subscribers can also see what's consuming their limits—how much Skills, Sub-agents, and MCP servers each take up, along with optimization suggestions. Then type /context, which shows what's filling the current context window, letting you know exactly what to trim. Focus on the big items: lengthy CLAUDE.md files, too many MCP tools, huge file reads, and command outputs—these are your primary targets.
Context Management: The Most Direct Way to Save Money
Decisively /clear When Switching Tasks
The biggest single gain is also the simplest: when you switch to unrelated work, type /clear. The old conversation is wiped, and the next message starts fresh from a small context. A good habit is—finish a feature, commit the code, then clear before the next task. Clearing costs nothing, and CLAUDE.md reloads in the new session. If you want to return to a session later, first name it with /rename, then retrieve it with /resume.

Use /compact When You Need Continuity, But Do the Math
Sometimes you want to continue the same task, but the conversation has grown too long. This is when you use /compact: Claude summarizes the history and continues with the summary instead of the full record. A better approach is to tell it what matters, e.g., /compact focus on the API changes and the failing tests. An honest warning: compaction itself has to read the entire conversation, so it is itself a large request. If you don't actually need the history, /clear is cheaper.
Slim Down CLAUDE.md and Move Long Workflows into Skills
CLAUDE.md loads at the start of every session, so every line in it is billed in every conversation. Keep it to around 200 lines or fewer, retaining only the essentials: commands, key rules, and places where Claude repeatedly makes mistakes. For example, how to build and test, a folder structure in three lines or fewer, and the two or three most important rules—not an entire style guide. Move lengthy specific workflows (such as how to review a PR or how to perform migrations) into Skills; skills load only when needed. You can even add a brief compaction instruction to CLAUDE.md so that every summary preserves what you care about.
Skills are an on-demand capability encapsulation mechanism in Claude Code, typically existing as a directory containing documentation and optional scripts. Unlike CLAUDE.md, which is fully injected at the start of every session, a skill is read only when Claude judges that the current task needs it, so its content does not occupy the context budget of everyday conversations. This makes skills ideal for carrying lengthy but infrequent workflows, such as code review checklists, database migration steps, and release checklists. Moving such content from CLAUDE.md into skills is like changing "resident memory" to "demand paging"—it preserves reusability while avoiding continuous payment for workflows that never trigger.
Streamline MCP Servers and Tools
Every connected MCP server adds tool names and descriptions to the context. Type /mcp to view the list and disable servers you're not currently using. When a command-line tool exists, prefer it—for example, use gh for GitHub, which Claude can run directly without adding any tool list to the context.
Model and Reasoning Cost Control
Choose Models by Task: Switch Anytime with /model
Not every task needs the biggest model. Sonnet can handle most coding work at a lower cost than Opus. Reserve Opus for difficult architectural decisions and long chains of multi-step reasoning. Use /model to switch anytime, even mid-session. Note: sub-agents that inherit your model also inherit the price—give them Haiku for simple auxiliary tasks.
Use /effort to Lower Reasoning Intensity
Thinking tokens are billed as output tokens, and at high intensity settings each request can add tens of thousands of tokens. For simple tasks like renaming, small fixes, and formatting, use /effort to lower the intensity; turn it up when you hit a real problem. Matching reasoning intensity to task difficulty is free money.

Prompting and Workflow Optimization
Ask Precisely and Point to Specific Files
Vague requests are expensive. "Improve this codebase" makes Claude scan everything, guessing your intent file by file. "Add input validation to the login function in auth.ts" sends it straight to one file. Use the @ symbol to point to the exact file, and state the criteria for "done," such as which test should pass. The most expensive tokens are the ones spent building the wrong thing.

Plan First for Large Tasks, Take Small Steps
For larger tasks, press Shift+Tab to switch to Plan Mode: Claude explores and proposes an approach before writing any code. If it still goes the wrong way, press Escape immediately; double-press Escape or type /rewind to return to an earlier point. Work in small steps—write a file, test it, then continue.
Hand Noisy Tasks to Sub-agents
Running tests, reading logs, and fetching documentation flood the context with output you'll never read again. Hand these tasks to sub-agents: the noisy output stays in their own context, and only a brief summary comes back. Sub-agents still consume tokens, so give simple tasks a smaller model, such as Haiku.
Sub-agents are independent Claude instances spawned from the main session, each with its own context window. All the intermediate output produced while it performs a task (such as running tests, reading logs, or fetching web pages) stays within its own window, and when it finishes it returns only a condensed conclusion to the main agent. This achieves context "isolation"—the main session won't be overwhelmed by reading tens of thousands of lines of logs at once. The cost is that sub-agent tokens are billed the same way, and it needs to re-establish its understanding of the task, so it's not suitable for complex reasoning that requires a lot of main-session background; for auxiliary work with clear boundaries and noisy output, it's the most cost-effective choice.
Advanced Technique: Pre-clean Data with Hooks
Keep Only Failure Information from Test Output
An advanced technique from the official documentation: Hooks can clean data before Claude sees it. This pre-tool-use hook fires before every bash command runs; when the command is a test run, it rewrites the command to keep only failure information. Add it to settings.json and put the small script it calls in the hooks folder. So instead of thousands of lines of passing tests, Claude reads a few lines explaining what's broken. Type /hooks to confirm it's active. The same idea applies to log files: return only the error lines.
Hooks are Claude Code's event hook mechanism, allowing user-defined scripts to run automatically at specific lifecycle points (such as before a tool call, after a tool call, or at session start). Configuration goes in the hooks field of settings.json, and the scripts themselves go in an agreed directory. The pre-tool-use hook fires when Claude initiates a tool call but before the command actually executes, so data can be rewritten, filtered, or intercepted before it enters the model's context. The test output cleaning in the article uses exactly this: rewriting a verbose test command into a version that outputs only a failure summary, cutting tokens at the source rather than compressing after the fact.
Turn Everything into a Daily Routine

Turn the above methods into habits: start each task with a clear, specific prompt; plan before big changes; default to Sonnet with normal reasoning intensity; clear when switching tasks; compact only when you need the history; hand noisy work to sub-agents. After a long break the cache has expired, and the next message will pay full price for the entire history—if it's a new task, clear first. Check /usage and /context once a week and fix the biggest item.
Smaller context, the right model, fewer wrong turns—that's how to do more with the same tokens. You can start today with three things: /clear between tasks, default to a simpler model, and keep CLAUDE.md lean.
Related articles
Tech FrontiersSherlock: An Open-Source Tool for Tracking Usernames Across Social Networks
Sherlock is an open-source Python tool that tracks social accounts across networks by username. This article covers its core features, why developers love it, typical use cases, and privacy compliance considerations.
Tech FrontiersGitHub Daily·Nov 07: Agent-Ready and Context Compression
GitHub Trending Nov 07: meta's agent-ready design system astryx, billion-context's 5x context compression, sherlock nearing 100k stars, plus local-first localthings and bare-metal GPU orchestration nvke.
Tech FrontiersBuoyant Open-Sources Kinference: An Inference Control Plane for vLLM on K8s
Buoyant open-sources Kinference, an inference control plane for vLLM on Kubernetes, with declarative routing, KV-cache-aware load balancing, and per-tenant metrics—claiming 95% lower median TTFT in official benchmarks.