Guide · checked against the Claude Code docs, 17 Nov 2026

How to reduce Claude Code token usage

Claude Code sends your whole conversation with every request, so most of what you pay for is context, not the prompt you just typed. These are the changes that actually shrink it, roughly in order of impact, with the command or setting for each. To see which files in your repo an agent can't use, run the free ctxray scan (step 6).

1. Where the tokens go

Every request carries the full conversation: CLAUDE.md, every file Claude has read, every tool result and every message. Each tool call is another request carrying that history again. Prompt caching makes the repeated part much cheaper, but not free, so a one-line question at the end of a long session still pays to re-read everything before it. After a break longer than the cache lifetime, the first message misses the cache and pays full price for the whole context.

Two other costs build up quietly. Extended thinking is billed as output tokens, the expensive kind. And every subagent sends its own requests on top of the main conversation.

For scale, Anthropic reports an average of about $13 per developer per active day across enterprise deployments, with 90% of users under $30.

2. Clear between tasks, compact on purpose

3. Match the model and effort to the job

Sonnet handles most coding work. Keep Opus for architecture and long multi-step reasoning, and switch with /model. Subagents that only search or summarize can run on Haiku: set model: haiku in the subagent's configuration. Note that switching models mid-session re-reads the conversation uncached, because each model has its own cache.

Per million tokensInputOutputCache read
Opus 5.5$4.00$20.00$0.20
Sonnet 5.5$2.00$10.00$0.10
Haiku 5.5, prompt ≤ 100k$0.10$0.50$0.01
Haiku 5.5, prompt > 100k$0.50$2.50$0.05

Haiku's price jumps five-fold once a single request goes over 100k input tokens, cache reads included. A long main session is often past that line, so Haiku pays off most in short, focused subagents.

Thinking is the other lever. You can't switch it off on the 5.5 models or Fable, but /effort lowers how much of it you pay for on simple tasks. On models with a fixed thinking budget, MAX_THINKING_TOKENS caps it.

4. Keep the always-loaded context small

5. Keep noisy output out of the main conversation

6. Stop Claude reading files it can't use

Most guides skip this one. Lockfiles, snapshots, generated code, minified bundles, fixtures and large data files cost tokens whenever a search or a read lands in them, and they teach the model nothing about your code.

A .claudeignore file does nothing. Claude Code doesn't read it. The supported mechanism is a Read deny rule in .claude/settings.json.

{
  "permissions": {
    "deny": [
      "Read(package-lock.json)",
      "Read(dist/**)",
      "Read(tests/__snapshots__/**)"
    ]
  }
}

Rules use gitignore syntax. A bare filename such as package-lock.json matches at any depth, and a single-directory deny pattern such as dist/** also matches nested copies. Claude Code applies Read rules to its file tools, to Grep and Glob, and to @-mentions on a best-effort basis, and to shell commands it recognizes, such as cat and head. They don't stop a recursive grep -r or a script that opens files itself; the sandbox covers that.

Which files? Measure instead of guessing

ctxray walks a repo the way an agent would, counts every file in tokens and flags the ones an agent can't use. On fresh shallow clones of six popular repos (12 and 13 Nov 2026):

RepoTokensFlaggedBiggest single source
langchain9.82M55%22 uv.lock files, 5.11M tokens
ollama9.26M51%shakespeare.txt test data, 1.33M tokens
excalidraw4.50M54%a wasm wrapper and a font source file, ~590k
fastapi8.47M43%one drawio SVG, 631k tokens
shadcn/ui7.79M38%22 lockfiles, 813k tokens
express196k~0%nothing worth flagging

These are whole-repo totals, so treat them as an upper bound: no agent reads everything. They show where a stray search or read is expensive.

Run it, review the .agentignore it writes, then turn that file into deny rules:

npx github:geraltbhai/ctxray         # breakdown by file and category
npx github:geraltbhai/ctxray init    # writes .agentignore and an AGENTS.md scaffold

# .agentignore uses gitignore syntax, so each line maps to a Read deny rule
grep -vE '^[[:space:]]*(#|$)' .agentignore \
  | sed -E 's#/$#/**#; s#.*#Read(&)#' \
  | jq -R . | jq -s '{permissions:{deny:.}}'

Merge the output into .claude/settings.json; deny lists from different settings files combine, so existing rules stay. On shadcn/ui this produced 144 rules covering 2.85M tokens, 37% of the repo. Read the list before you commit it: anything you actually want Claude to see must not be on it, and paths containing brackets or parentheses, such as Next.js route groups, are worth a second look.

7. Ask precisely, plan first

8. Measure what changed

FAQ

How much does Claude Code cost per day?

Anthropic reports an average of about $13 per developer per active day across enterprise deployments, with 90% of users under $30. Your number depends mostly on how much context each request carries.

Does .claudeignore work?

No. Claude Code doesn't read a .claudeignore file. To keep lockfiles, builds and fixtures out of context, add Read deny rules under permissions.deny in .claude/settings.json (step 6).

Do @imports in CLAUDE.md save tokens?

No. Imported files load at launch together with CLAUDE.md. What does load on demand: rules in .claude/rules with a paths: frontmatter, CLAUDE.md files in subfolders, and skills (step 4).

Is /clear or /compact cheaper?

/clear costs nothing: it just starts fresh. /compact has to read the whole conversation to summarise it, so it is a large request in itself. Clear between unrelated tasks; compact once, deliberately, when you need continuity (step 2).

Can I turn extended thinking off to save tokens?

Thinking is billed as output tokens. On the current 5.5 and Fable models it can't be switched off completely, but /effort lowers how much the model thinks (step 3).

Does Haiku cost the same for long prompts?

No. Haiku 5.5 costs $0.10 per million input tokens up to a 100k-token prompt and $0.50 above it, so a Haiku subagent that reads a lot can lose its price advantage. Keep Haiku jobs small (step 3).

Sources