Guide

How to save Claude Code tokens

Most of it is habits. One step is a tool, and we make one, so read that part with the usual grain of salt.

Where the tokens go

Claude Code sends your whole conversation with every request. Each time Claude uses a tool, the result (a file it read, a search, a test run) joins that conversation and rides along on every request after it. Prompt caching makes the repeats cheaper, but they still count against your usage.

So the job is mostly keeping stuff out of the conversation that didn’t need to be there. Run /context to see what’s taking up space and /usage to see what the session has used.

One thing to keep straight: on a Pro or Max plan, fewer tokens doesn’t mean a smaller bill. It means hitting your limits later. On the API, it’s money.

Clear between unrelated tasks

Old context costs tokens on every message that follows it. When you switch to something unrelated, /clear and start fresh. /rename the session first if you might want it back, then /resume finds it.

/compact is for when you want to keep going on the same work. It has to read the whole conversation to summarize it, so on a big session the compaction is itself a big request. /clear costs nothing.

Ask for something specific

“Improve this codebase” sends Claude off scanning everything. “Add input validation to the login function in auth.ts” lets it go straight there. Anthropic’s own cost guide uses nearly that exact example, and it’s the cheapest fix on this page.

Point Claude at the exact code

Name the file and the function when you know them. When you don’t, Claude goes looking: search for a word, open the files that match, read them top to bottom. Every file it opens lands in the conversation whole, even when it needed twenty lines of it.

Tools that navigate by symbol fix the looking part. Claude Code’s docs suggest code intelligence plugins for typed languages, where one “go to definition” call replaces a search plus several file reads. If your language has one, try it.

jCodeMunch is ours. It’s an MCP server that indexes your repo with tree-sitter (70+ languages) and hands Claude one function or class by its byte offsets, instead of the file it lives in. On our benchmark, 15 lookups (5 each on express, fastapi and gin at pinned commits), jCodeMunch (one symbol search, then the source of the top 3 matches) returned 96.2% fewer tokens than a scripted grep-and-read baseline (search the query terms, read the top 3 matching files), counted with the cl100k tokenizer. That’s per lookup. What it does to a whole session depends on how much of your session is reading code.

To try it: uv tool install jcodemunch-mcp, then jcodemunch-mcp init in your project. Free for personal and other non-commercial use; commercial license, paid once. The benchmark and its scripts are on GitHub if you’d like to poke holes in the number.

Language servers and jCodeMunch can share the job

Anthropic ships code intelligence plugins for twelve languages (as of October 2026), TypeScript, Python, Go and Rust among them. Each one connects Claude to a language server you install separately, like pyright for Python or gopls for Go. With that server running, go-to-definition in a typed language is exact, and the server reports type errors after an edit as a bonus. If you have it, keep using it.

jCodeMunch is for the parts a running language server doesn’t cover. It parses with tree-sitter, so there’s no server to start, which helps in a language without a plugin or a repo that mixes several. It also answers what calls a function and what a change would touch, across every language in the index. Each of those is one lookup that returns symbols and file paths, not whole files.

Keep CLAUDE.md short

CLAUDE.md loads at the start of every session, whether today’s work needs it or not. The docs suggest keeping it under 200 lines. Instructions for one workflow (PR reviews, database migrations) can move into a skill, which loads only when it’s used.

Turn off MCP servers you aren’t using

Claude Code now defers MCP tool definitions, so a server mostly costs its tool names and instructions until Claude calls it. Mostly isn’t nothing. Run /mcp and disable what you aren’t using this week, ours included. For a job a CLI already does (gh, aws), the CLI is lighter still.

Match the model and the effort to the job

Sonnet handles most coding. Save Opus for the hard architectural calls. /model switches mid-session, and /effort turns down the thinking on simple tasks (thinking is billed as output). A subagent doing grunt work can run on Haiku.

Keep noisy output out of the main conversation

A full test run or a long log can be thousands of lines when you wanted the three that failed. A hook can filter the output before Claude sees it (the cost guide has one that keeps only test failures). Or hand the noisy job to a subagent, so the output stays in its context and only a summary comes back.

Stop wrong turns early

The most expensive tokens are the ones spent building the wrong thing. For bigger changes, Shift+Tab into plan mode and approve the approach before any code gets written. If Claude heads off the wrong way, Escape stops it, and /rewind puts the conversation and the code back.

Claude Code commands and figures are from Anthropic’s Manage costs effectively page, checked 28 October 2026. Commands change between versions; claude --version tells you which one you have.