My first full month using Claude Code on a Kotlin Multiplatform project cost me $340. My second month? $127. Same project. Same velocity. Same output quality. The difference was understanding where tokens actually go — and stopping the bleeding at the source.

This isn’t about using Claude Code less. It’s about using it smarter. Here are the strategies that made the difference, with real numbers from my workflow.


The Hidden Cost: Context Window Bloat

The biggest cost driver isn’t how many prompts you send. It’s how much context you carry in each one. Every message in a Claude Code session includes the full conversation history. By message 30 in a session, you’re sending 30 previous exchanges plus your new prompt — and paying for every token.

I tracked my sessions for a week. The pattern was clear:

Session LengthAvg Cost Per PromptTotal Session Cost
1-10 messages$0.08$0.50
11-25 messages$0.35$6.50
26-50 messages$0.90$28.00
50+ messages$1.80$72.00+

The cost per prompt increases exponentially because context accumulates. A 50-message session doesn’t cost 5x a 10-message session — it costs 50x or more.


Strategy 1: The 15-Message Rule

Now I start a new session every 15 messages. No exceptions. Before I reset, I write a quick summary of what I’ve accomplished and what’s next. Then I start fresh with a focused prompt.

Before: One marathon session (47 messages) → $34
After: Three focused sessions (15+15+12) → $9

The /compact command helps too — it compresses your context when things get long. But starting fresh is even better because you get to re-frame the problem with only the relevant context.

The workflow:

  1. Work for ~15 messages
  2. Hit /cost to check your spend
  3. If the context is getting heavy, note your progress
  4. Start a new session with a focused prompt that includes only what’s needed

Strategy 2: Stop Dumping Entire Files

This was my worst habit. I’d say “look at this file” and paste 500 lines. Claude Code would dutifully read it all, burning tokens on imports, boilerplate, and code that had nothing to do with my question.

Before:

"Read src/shared/data/repository/UserRepository.kt and fix the caching bug"

This sends the entire 400-line file into context. Claude reads it, but 350 lines are irrelevant.

After:

"In src/shared/data/repository/UserRepository.kt, the getCachedUser()
function (around line 45-60) returns stale data when the cache TTL expires.
The issue is in the timestamp comparison. Fix the cache invalidation logic."

This tells Claude exactly where to look. It reads the file but focuses on the relevant section. The response is faster, cheaper, and more accurate.

Savings: ~40% reduction in input tokens per file-editing task.


Strategy 3: Use One-Shot Mode for Simple Tasks

Interactive mode is great for exploration and multi-step work. But for simple, well-defined tasks, one-shot mode (claude -p) is dramatically cheaper.

Interactive mode for a simple task:

Terminal window
# Opens session, loads context, you type prompt, get response
# Minimum cost: ~$0.15 even for "add a log statement"
claude
> "Add a debug log in processPayment() before the API call"

One-shot mode:

Terminal window
# Direct prompt, no session overhead
claude -p "Add console.log('Processing payment:', amount) before
the fetch call in src/api/payments.ts:42"
# Cost: ~$0.03

I now use one-shot mode for:

  • Adding log statements
  • Simple find-and-replace operations
  • Generating boilerplate (interfaces, data classes)
  • Quick explanations (“what does this regex do”)

Rule of thumb: If you can describe the task in one sentence and don’t need back-and-forth, use -p.


Strategy 4: CLAUDE.md as a Cost Weapon

A well-written CLAUDE.md file reduces costs in a way most people don’t realize. When Claude Code understands your project structure, conventions, and patterns upfront, it asks fewer clarifying questions and makes fewer wrong guesses.

Without CLAUDE.md:

Prompt: "Add a new API endpoint for user preferences"
Claude: *reads 12 files to understand your project structure*
Claude: *asks 3 follow-up questions about your patterns*
Claude: *generates code using wrong conventions*
You: "No, we use repository pattern, not direct DB calls"
Claude: *regenerates everything*
Total: 8 messages, $4.20

With CLAUDE.md:

Prompt: "Add a new API endpoint for user preferences"
Claude: *reads CLAUDE.md, knows your patterns*
Claude: *generates correct code on first try*
Total: 2 messages, $0.45

Key things to include in CLAUDE.md for cost savings:

  • Project structure and architecture patterns
  • Naming conventions
  • File organization rules
  • Common patterns (error handling, logging, testing)
  • Dependencies and their usage patterns

The 30 minutes you spend writing CLAUDE.md pays for itself in the first week.


Instead of making one change per prompt, batch related changes together. Each prompt has a base cost (the context window), so fewer prompts = lower total cost.

Expensive approach (5 separate prompts):

1. "Add email field to User model"
2. "Update UserRepository to handle email"
3. "Add email validation to CreateUserUseCase"
4. "Update the API endpoint to accept email"
5. "Add email to the response DTO"

Cost: ~$3.50 (5 prompts with growing context)

Cheaper approach (1 prompt):

"Add an email field to the user system:
1. Add email: String to the User data class
2. Update UserRepository.createUser() to persist email
3. Add email validation in CreateUserUseCase (standard email regex)
4. Update POST /users endpoint to accept and return email
5. Update UserResponse DTO to include email
Follow our existing patterns in CLAUDE.md."

Cost: ~$0.90 (1 prompt, comprehensive output)

Savings: 75% cost reduction for the same work.


Strategy 6: The Cost Dashboard Habit

Run /cost regularly. I check it every 5 messages. This simple habit creates awareness that naturally changes your behavior.

When you see “$2.40 spent on this session,” you start thinking:

  • “Do I really need Claude to read that whole file?”
  • “Can I describe this more precisely?”
  • “Should I start a new session?”

I also track daily costs in a simple spreadsheet. The trend data helps me spot when I’m slipping back into expensive habits.


My Monthly Breakdown (Before vs. After)

CategoryBeforeAfterSavings
Long sessions (50+ messages)$180$0100%
Medium sessions (15-30 messages)$95$5245%
Simple tasks (interactive mode)$45$1273%
Exploration / reading code$20$1810%
Total$340$12763%

The biggest win was eliminating marathon sessions entirely. The second was using one-shot mode for simple tasks.


What NOT to Optimize

Cost optimization has diminishing returns. Don’t sacrifice productivity for pennies:

  • Don’t avoid Claude Code for tasks where it saves you hours. A $2 prompt that saves you 30 minutes of debugging is a bargain.
  • Don’t write worse prompts to save tokens. A vague prompt that needs 3 follow-ups costs more than a detailed prompt that works on the first try.
  • Don’t skip reading files when you need context. The cost of Claude reading a file is tiny compared to the cost of it generating wrong code.

The goal is eliminating waste, not eliminating usage.


Key Takeaways

  1. Start new sessions every ~15 messages. Context accumulation is the #1 cost driver.
  2. Point to specific lines, not entire files. Reduce input tokens by 40%.
  3. Use claude -p for simple tasks. 5x cheaper than interactive mode.
  4. Invest in CLAUDE.md. Pays for itself within a week.
  5. Batch related changes. One comprehensive prompt beats five small ones.
  6. Check /cost every 5 messages. Awareness changes behavior.

The tools are the same. The AI is the same. The difference is how deliberately you use them.


These numbers are from my personal usage on a Kotlin Multiplatform project. Your costs will vary based on your plan, project size, and usage patterns. The percentages and strategies apply regardless of the specific numbers.

Want to master Claude Code from foundation to full-auto workflows? The Claude Code Mastery course covers cost optimization and 15 more phases. Phases 1-3 are free.