If you use Claude inside VS Code—whether through the official Anthropic extension, Cursor, Cline, or Roo Code—this guide will save you money today.
If you feel like your session limits are evaporating, it is likely not a limits problem—it is a context hygiene problem. After extensive testing and research, I have compiled 18 token management hacks ranked from basic to advanced. By implementing these, you can easily double, triple, or even 5x your Claude Code usage.
How Tokens Actually Work
Before optimizing, you must understand how Claude consumes tokens. A token is the smallest unit of text the AI reads and charges you for (roughly one word).
Here is the ultimate light bulb moment: Every time you send a message, Claude re-reads the entire conversation from the beginning.
Your token cost does not just add up; it compounds exponentially. Message 1 might cost 500 tokens, but by Message 30, it could cost 15,000 tokens because it is re-reading everything before it. In a 100-message chat, up to 98.5% of all tokens spent are just the AI re-reading old history.
On top of this, Claude reloads invisible overhead on every single turn: your skills.md, MCP servers, system prompts, and files. This bloated context not only drains your limits but also produces worse outputs due to a phenomenon called “loss in the middle,” where the model ignores instructions buried deep in a long session.
Tier 1: The Quick Wins
These simple habits will immediately extend your session life.
- Start fresh conversations: Use the
/clearcommand between unrelated tasks. Do not carry context from Topic A into Topic B. A fresh chat is exponentially cheaper than continuing a long one. - Disconnect MCP servers: Every connected server loads its tool definitions into your context on every message (sometimes costing up to 18,000 tokens). Disconnect what you don’t need, or use CLIs instead.
- Batch prompts into one message: Instead of asking Claude to “summarize,” then “extract issues,” then “fix,” send it all as one prompt. If Claude makes a mistake, edit your original message instead of sending a follow-up correction.
- Use Plan Mode: Let Claude map out an approach before writing code. This prevents the ultimate token waste: letting the AI go down the wrong path and having to scrap the entire output.
- Run
/contextand/cost: These commands make invisible token drains visible. You might find out you are losing 50,000 tokens per prompt before you even say hello. - Set up a status line: Run
/statuslinein your terminal to create a visual progress bar of your usage, context percentage, and active model. - Keep your dashboard open: Keep the Claude usage dashboard in a nearby tab. Check it every 30 minutes to pace yourself.
- Be smart with pasting: Does Claude need the entire 50-page document, or just a single function? Be precise with what you feed it.
- Watch Claude work: Don’t fire off a prompt and walk away. If you see Claude getting stuck in a loop or reading the wrong files, stop it immediately.
Tier 2: Intermediate Tactics
Ready to level up? These tricks require a slight shift in how you manage your environment.
- Keep your
claude.mdfile lean: Place this in your project root, but keep it under 200 lines. Include your tech stack, rules, and build commands. Treat it like an index that points Claude to where bigger files live, rather than stuffing the file with raw data. - Be surgical with file references: Use
@filenameto point Claude to specific files (e.g., “Check the verify function inside auth.js”) rather than letting it freely explore your whole repo. - Compact at 60% capacity: Auto-compact triggers at 95%, which is too late. Run
/contextto check your capacity, and manually run/compactaround 60%. After 3 or 4 compacts, clear the session entirely. - Beware of short breaks: Claude’s prompt caching has a 5-minute timeout. If you walk away for 10 minutes and send a message, it reprocesses everything from scratch at full cost. Always compact or clear before taking a break!
- Limit command output bloat: When Claude runs shell commands, the full terminal output enters your context window. Deny permissions for commands that spit out massive, unnecessary data logs.
Mindset Shift: Is Hitting Your Limit Actually Bad? Hitting your limit shouldn’t always have a negative connotation. If you are using these optimization hacks and still hitting your cap, it just means you are a true power user. You are extracting massive leverage and productivity out of the tool.
Tier 3: Advanced Optimization
For the developers who want to squeeze every last drop out of their token allocation.
- Create a self-learning constitution: Use your
claude.mdto save decisions, not conversations. Add an “Applied Learning” section where Claude records one-line bullet points about repeated failures, workarounds, or platform limitations so you never have to waste tokens re-explaining them. - Pick the right model: Use Sonnet for default coding, Haiku for simple formatting or sub-agents, and Opus exclusively for deep architectural planning. If you have a massive codebase, consider using Codex alongside Claude to handle reviews and save your Anthropic tokens.
- Watch the cost of sub-agents: Agent workflows use 7 to 10 times more tokens because they spin up entirely separate instances with full context. Delegate them strictly for one-off tasks and default them to Haiku to save money.
- Exploit Peak and Off-Peak hours: Peak hours (8 AM – 2 PM ET, Weekdays) drain your allocation faster. Schedule massive multi-agent tasks and heavy refactoring for off-peak hours (afternoons, evenings, weekends).
The Bottom Line
Treating 1-million token windows as an excuse to be messy is how developers end up with massive API bills and degraded code. Context hygiene isn’t just about saving money—it’s about keeping the AI focused, sharp, and reliable. Build the habits of using fresh sessions, lean instruction files, and surgical file references, and you’ll get far more mileage out of every single prompt.
Context Rot (AI Dementia)
As your session grows, you experience “Context Rot.” The model’s attention gets spread across every single token, causing it to get distracted, contradict itself, and edit files without reading them properly.

A recent GitHub analysis of 18,000 sessions showed that as sessions get longer, “thinking depth” drops by 67%, and the AI’s tendency to edit code without reading it jumps from 6% to 34%. Furthermore, retrieval accuracy drops from 92% at 256,000 tokens down to just 78% at 1,000,000 tokens. As the model gets worse, your token efficiency plummets because you have to spend 500,000 tokens to get an output that should have taken 200,000.
- Managing Token Costs: A Developer’s Guide to Making Claude Last in VS Code
- Driving Solution Delivery Excellence: Achieving Repeatable, High-Quality Delivery with Custom AI Agent Skills
- The Integration Gap: Why 95% of Enterprise AI Projects Fail and How Azure Integration Services Solves It
- Microsoft Copilot Studio vs Azure AI Studio: A Feature Overview
- Leveraging Azure OpenAI and Cognitive Search for Enterprise AI Applications
- Logging and Monitoring strategy for Azure Integration Components using OpenAI
