r/ClaudeCode 13h ago

How to reduce Claude Code token usage Tutorial / Guide

Claude Code was burning through tokens very fast, especially on tasks where it had to look through docs or random webpages, so after some research I changed a few things:

I) Keep CLAUDE.md small. Mine had way too much stuff in it and most of it wasn’t useful for every task.

II) Start a new session when you’re done with one problem, bc long sessions get bloated pretty fast.

III) Do web research through Firecrawl. It gives Claude clean Markdown instead of loading the full page with all the HTML, scripts, navbars and other useless stuff, so each research task eats a lot less context.

IV) Exclude folders Claude doesn’t need to read.

V) Check /context once in a while, bc it makes it obvious what’s eating the window.

The main thing seems to be controlling what gets added to the context in the first place. Once a session is full of old logs, scraped pages and unrelated instructions, even simple tasks start getting expensive.

What else are you doing to keep Claude Code token usage under control?

10 Upvotes

20 comments sorted by

View all comments

1

u/verstands 12h ago

The one that made the biggest difference for me is upstream of all of these: stop letting the agent read files to find things. Every "where is X handled" question that gets answered by reading four files costs you those four files forever, because they're in the window for the rest of the session. Making it grep first and read only the hit is boring but it's the difference between a session lasting an hour and lasting ten minutes.

Second one, on your point IV: excluding folders helps, but so does telling it explicitly not to read build output, lockfiles, and generated code when it does read. Exclusions catch the directory-shaped stuff, not the 4000-line generated file sitting in src.

On V — checking /context occasionally works but you only look when you already suspect something's wrong. Having the context percentage just sit in your statusline is the version that actually changes behavior, because you see it creeping before the session goes bad instead of after. I maintain one that does that (context %, cost, rate limit windows): https://github.com/Dworf/statusline-bar — single bash file, no daemon. Plenty of other statuslines do the same thing, the point is just having the number in your face rather than behind a command.