The 80/20 of AI Token Costs
I was spending more on AI tokens than I expected before I looked at where the money was going.
Turns out, most of my token usage came from a few workflows. And most of that was waste.
The Problem Nobody Tracks
Most developers using AI assistants have no idea how much they spend. The cost is abstracted away. You pay a subscription or hit an API and don’t think about individual tokens.
But tokens add up. Fast.
A typical coding session might use:
- 50K tokens reading file context
- 30K tokens in conversation back-and-forth
- 20K tokens in tool outputs (git status, ls, grep results)
- 10K tokens in actual useful response
That’s 110K tokens for maybe 10K tokens of value. A 10:1 ratio of overhead to output.
Where the Waste Lives
After tracking my usage for a month, I found three main sources of waste:
1. Redundant context loading
Every time I started a new conversation, the AI would re-read files it had just read. The same 500-line file getting loaded over and over. Same README. Same config files.
2. Verbose tool outputs
Commands like git status with many files, or ls -la on large directories, dump thousands of tokens into the context. Most of that information isn’t relevant to the current task.
3. Conversational padding
”Sure! I’d be happy to help you with that. Let me take a look at the code and see what’s going on here…” That’s 30 tokens of nothing before the actual answer starts.
The Fixes
For redundant context:
- Use session persistence when available. Keep the same conversation going instead of starting fresh.
- Be explicit about what context the AI already has. “You’ve already read the auth module” saves a re-read.
- Structure work in focused sessions. One task per conversation, not everything jumbled together.
For verbose tool outputs:
- Filter outputs before they hit the context. A
git statusthat shows only changed files instead of the full tree. - Use targeted commands.
grep -l patternto find files, thenhead -20 fileinstead of reading the whole thing. - Proxy tools through filters that strip irrelevant information.
For conversational padding:
- Configure terse output modes if your AI assistant supports them. Direct answers, no pleasantries.
- Prompt for specific formats. “Answer in one sentence” or “Just the command, no explanation.”
- Use system prompts that discourage filler.
Measuring Your Usage
You can’t optimize what you don’t measure. Here’s how to start:
If using an API directly:
Log every request and response with token counts. Most SDKs expose this in the response metadata.
const response = await anthropic.messages.create({...});
console.log({
input_tokens: response.usage.input_tokens,
output_tokens: response.usage.output_tokens,
});
If using Claude Code or similar tools:
Check the session summary after working. Look for patterns in what consumes the most tokens.
Track over time:
A single day doesn’t tell you much. Track for a week. Identify which workflows are expensive and why.
The Pareto Principle in Action
When I analyzed my usage, I found:
- 3 specific workflows accounted for 70% of my token spend
- 2 of those workflows could be optimized without changing how I work
- The third needed a different approach entirely
The fixes:
-
Code review workflow: I was loading entire files when I only needed the diff. Switched to loading just the changed lines. 60% reduction in that workflow.
-
Debugging workflow: I was letting the AI read every file it wanted to explore. Added a confirmation step for large files. 40% reduction.
-
Documentation workflow: I was asking the AI to write docs by reading the whole codebase. Changed to an incremental approach: outline first, then fill in sections. 80% reduction, better quality output.
Token-Aware Workflows
Once you’re aware of token costs, you start designing workflows differently:
Incremental over comprehensive. Don’t ask the AI to understand everything at once. Build understanding in stages.
Targeted reads over broad exploration. Point the AI at specific files instead of “look at the codebase.”
Structured outputs over freeform. JSON responses with specific fields are more efficient than prose explanations.
Caching where possible. If you’ll ask the same question again, save the answer locally.
The ROI Calculation
Let’s say you spend $150/month on AI tokens. You implement the optimizations above and cut that to $50/month.
That’s $100/month saved. $1,200/year.
But the real gain isn’t the money. It’s context window space. When you’re not wasting tokens on overhead, you can fit more useful information in each session. The AI has more room to reason about your actual problem.
Fewer tokens spent on noise means more tokens available for signal.
Getting Started
-
Measure first. Spend a week tracking where your tokens go before optimizing.
-
Target the top offenders. The Pareto principle applies. A few workflows drive most of the cost.
-
Automate the fixes. Manual vigilance doesn’t scale. Build the optimizations into your tooling. Tools like RTK can automatically filter verbose command outputs, cutting 60-80% of token waste without changing how you work.
-
Re-measure. Verify the fixes worked. Sometimes “optimizations” just shift the cost elsewhere.
Token efficiency isn’t about being cheap. It’s about being intentional with the most constrained resource in AI-assisted development: context window space.