N 5 ways to save tokens in claude code - Netscape _ ×
Back Forward Home Reload Guides Sign
URL: http://www.nicnonac.com/guides/save-tokens-claude-code/
5 ways to save tokens in claude code - nicnonac guides _×

← back to guides

5 ways to save tokens in claude code

Hacks · 4 min read · posted Apr 28, 2026, 6:07 pm

Five low-friction habits that compound across every coding session, every project, every day.

Most Claude Code users blow through context budgets without realizing where it's going. Each tip below is a single habit. Apply all five and you'll get 3-5x more useful conversation on the same prompts.

1. use .md, not pdf or screenshots

The pain: every PDF you upload burns about 3,000 tokens just to parse. Every screenshot burns about 1,200. That's context you'll never get back, and it stacks across every message.

The fix: open the PDF in Google Docs, then File, Download, Markdown. Drop the .md instead. For screenshots of code, paste the code as plain text.

The stat: 5 PDFs in one session is 15,000 tokens before message one. Same content as .md files is often under 5,000 combined.

2. keep build artifacts out of the scan

The pain: Claude Code walks your file tree on session start. Build output and dependencies like node_modules/, .next/, dist/, and vendored libraries are thousands of tokens of pure noise.

The fix: Claude Code does not read a .claudeignore file (that one does nothing, despite what a lot of blog posts say). It does respect your .gitignore, so make sure build artifacts and dependencies are gitignored. For anything you want fully invisible that is not in .gitignore, add a permissions.deny block to .claude/settings.json.

node_modules/
.next/
dist/
build/
*.log
.env
vendor/

The stat: a typical Next.js repo that leaves build output un-ignored burns 10-20k tokens on first scan. Gitignored, that noise drops to near zero.

3. use /compact before context runs hot

The pain: most people blow through 200k of context because they never compact. The agent starts forgetting what you discussed an hour ago.

The fix: when you hit 60-70% context usage (Claude Code shows the bar at the bottom of the terminal), run /compact. It summarizes the conversation in-place, freeing budget without losing the through-line.

The stat: a 4-hour coding session without /compact often loses 30-40% of relevant context to history. Regular /compact keeps you at 90%+ usable budget.

4. tell the agent to grep before reading

The pain: you ask Claude to "find where we handle auth" and it reads 15 files front-to-back looking for it. Each file read burns hundreds to thousands of tokens. Most of those files were irrelevant.

The fix: tell it to search first, read second. "Grep for authenticateUser across the repo, then read only the files that match." One grep costs almost nothing. A targeted file read after that costs a fraction of the blind scan.

The stat: a blind "find and read" pass across a medium repo can burn 30-50k tokens. A grep-then-read pass on the same task typically lands under 5k. That's a 6-10x reduction on every investigation.

5. spawn a subagent for investigation

The pain: you ask Claude to investigate something ("why is this test failing?" or "what's the data flow for this feature?") and it reads file after file in your main conversation. Every file it reads stays in your context window permanently. By the time it finds the answer, you've burned 40-60k tokens of context on files you'll never reference again.

The fix: tell Claude to spawn a subagent. "Use a subagent to investigate why testCheckout is failing. Report back with the root cause and the file + line number." The subagent runs in its own context window. It can read 50 files, grep the whole repo, trace the call chain. When it's done, only the summary comes back to your main conversation. All that investigation context gets thrown away instead of clogging your window.

The stat: a typical investigation reads 10-20 files at 2-5k tokens each. That's 20-100k tokens burned in your main context. With a subagent, you get the answer in 200-500 tokens. That's a 50-60x reduction on the context cost of any investigation task.

← all 52 guides

Done nicnonac.com 56.6k