
•15 min
Dev, AI
10 Ways to Cut Your Token Bill by 5x (Copilot, Claude Code, Cursor)
Opus at $25/M tokens, Haiku at $5. 10 practical levers to reduce your consumption by 60 to 90% across all AI agents.
Lire l'article→

Click to enlarge
/compact. Thanks to what I had configured before writing my first prompt./cost command that shows real-time consumption for the current session:Total cost: $0.87 Total duration (API): 8m 42.3s
node_modules/ to understand a lib. Read package-lock.json (300,000 lines) to check a version. Explore .next/ because it's looking for a config file. Scan dist/ to understand the build output.CLAUDE.md is a Markdown file placed at the root of your project that Claude Code loads automatically at the start of every session. It acts as persistent memory: code conventions, architecture, commands, files to ignore.CLAUDE.md file at the project root is the most underrated thing in Claude Code. It's loaded automatically every session. Mine is about a hundred lines and contains everything Claude needs to know about the project: the stack, code conventions, Docker commands, folder architecture.## Code conventions - Backend: snake_case files, camelCase variables, PascalCase classes - Frontend: PascalCase components, camelCase functions - Indentation: 4 spaces (2 for JSON) - Commits: feat:, fix:, refactor:, test:, docs:
.claude/rules/, you can place Markdown files that are loaded automatically in every session and every agent. Unlike CLAUDE.md which describes the project, these files enforce behaviors — rules Claude must follow at all times, no matter what..claude/rules/, you can place Markdown files that are loaded automatically in every session and every agent. My token-economy.md contains the token economy rules Claude must respect permanently:# Token economy — mandatory rules ## File exploration - Grep/Glob before Read: always target before opening a file. - Never read: node_modules/, .next/, dist/, *.lock, DerivedData/ - Stop exploring as soon as you've found what you need. ## Context and responses - Short answers. No recap of what was just done. - Don't re-read a file already read in the same session. - No introductory prose ("I'm now going to...", "Sure!").
Grep, finds the file in one query, and reads only that one. The "no recap" rule also saves a lot: by default, Claude loves summarizing everything it just did before moving on. It's reassuring, but it costs tokens for nothing.PreToolUse hook is a script (bash or JSON) that Claude Code runs automatically before every tool call. It can block the action, modify it, or let it through — without you needing to intervene.PreToolUse hook that blocks any read inside build folders:{ "hooks": { "PreToolUse": [ { "matcher": "Read", "hooks": [ { "type": "command", "if": "Read(node_modules/*)", "command": "echo 'node_modules read blocked' >&2 && exit 2" } ] } ] } }
node_modules/? Blocked. It doesn't waste 2,000 tokens reading React's source code to understand a type. It uses the official docs or the exported type, full stop.@file injects a file's content directly into the prompt context, without Claude needing to explore or search for it.@file to inject a file into the prompt context. It's the ultimate shortcut: instead of letting Claude explore to find the right file, you hand it over directly.@src/components/Landing/Hero.tsx refactor the useEffect to avoid the re-render
.claude/agents/, each agent definition file exposes a permission field listing the tools it can access: read, write, bash, grep, glob, task...write. A writing agent doesn't need bash. The rule: give each agent the minimum viable set of tools for its task.# .claude/agents/search.md permission: read: allow grep: allow glob: allow # write: no. bash: no. task: no.
.claude/skills/, that context is only injected when the agent explicitly needs it. Over a workflow of 10 agentic calls, the difference is significant: you only pay for context when it actually serves a purpose.blog-writer.md skill contains 200 lines of writing guidelines. Without Skills, those 200 lines are in the context of every call. With them, they're only loaded when an agent is writing an article — not when it's doing a Tavily search or a code analysis..claude/commands/ is an ultra-structured prompt with constraints already set, files already referenced, scope already defined. Versus a vague prompt typed by hand that will trigger 2-3 rounds of exploration before the agent understands what you want.# .claude/commands/article-blog.md Write an article following the blog-writer skill. Read only: Blog-livate/content/Livate/Article de blog/en/[last article].mdx Do not explore the rest of the folder.
/article-blog and "write me a blog article": the first starts with the right context and constraints already in place. The second explores, asks questions, reads files to understand the format. A few thousand tokens of difference, multiplied by every invocation.model field in each agent. Haiku costs 25 times less than Opus for equivalent results on scan, grep, summary, or classification tasks. Reserve Sonnet and Opus for agents that actually do complex generation or architectural analysis.# Tavily search agent → Haiku is more than enough model: claude-haiku # Technical implementation agent → Sonnet or Opus model: claude-sonnet
token-economy.md, base hooks, and targeted prompt examples. The idea is a public GitHub repo you can clone and adapt to your project in 10 minutes./compact is reactive: it summarizes context once the window is full. Proactive rules (CLAUDE.md, hooks, rules files) prevent context from growing in the first place. One repairs, the other prevents.PreToolUse bash hook that filters a path executes in a few milliseconds. The token savings are incomparably larger than the added latency./compact every 30 minutes. That's what I was doing. And it's what most devs do when they complain about their Claude Code bill. But /compact is just painkillers for your context. It relieves, it doesn't treat the cause.
Opus at $25/M tokens, Haiku at $5. 10 practical levers to reduce your consumption by 60 to 90% across all AI agents.

Forbes named it today. 92% of devs use AI coding tools daily, 46% of new code is AI-generated — and 97% of vibe-coded apps never make it to production.
Agentic loop, hierarchical subagents, MCP protocol: a technical deep dive into code agent architecture and lessons learned after 8 months of solo dev with Claude Code.
Got a take on this article?
Create a free account in 10 seconds to comment, like, and get the next articles straight to your inbox.
Don't have an account yet?