Cost Optimization
Claude Code isn't free. But with the right strategies, the ROI is massive. This module teaches you to maximize value and control expenses.
Pricing Model
Claude Code charges by tokens:
| Type | Cost (Approximate) |
|---|---|
| Input tokens | $3 / 1M tokens |
| Output tokens | $15 / 1M tokens |
Pro Tip: Output tokens cost 5x more than input tokens. This matters for strategy.
View Your Current Usage
/costShows:
- Tokens used in session
- Estimated cost
- Breakdown by type (input/output)
/contextShows:
- Percentage of context used
- Tokens in current context
Optimization Strategies
1. Clear Context Regularly
Every message you send accumulates in context. After finishing a feature:
/clearThis resets context and reduces cost of subsequent messages.
Rule: /clear between different features. Always.
2. Use /compact Instead of Accumulating
If you need to keep some context but reduce tokens:
/compactClaude summarizes history instead of keeping everything. You lose detail but save tokens.
3. CLAUDE.md > Repeating Instructions
Expensive: Writing the same instructions in every message.
Use strict TypeScript, functional components in React,
and Tailwind for styles. Make sure to...
[50 tokens every time]
Cheap: Put it in CLAUDE.md once.
Claude reads CLAUDE.md automatically. No need to repeat.
4. Concise Prompts
Expensive:
Could you please create a React component that displays
a list of users? I need it to be responsive and have
pagination. Oh, and also a search bar.
The styling should follow what we already have in the project.
Thanks!
Cheap:
Create UserList component:
- User list
- Responsive
- Pagination
- Search bar
- Same style as project
Same result, 40% fewer tokens.
5. Plan Mode for Big Features
Plan Mode gives you a plan before executing. If the plan isn't what you wanted, you change it BEFORE Claude writes code.
Without Plan Mode: Claude generates 500 lines of misfocused code → wasted tokens.
With Plan Mode: Adjust the plan first → correct code the first time.
6. Sub-Agents for Parallel Tasks
Sub-agents have separate context. If a task doesn't need all the main chat context, send it to a sub-agent.
Main context: 100k tokens of project. Sub-agent: Only relevant files (20k tokens).
7. Ignore Unnecessary Files
In your CLAUDE.md, specify which files to ignore:
## Files to Ignore
- node_modules/
- dist/
- .git/
- *.log
- *.lockClaude won't read them, saving input tokens.
Cost Comparison by Workflow
| Workflow | Estimated Cost/Hour | Description |
|---|---|---|
| Exploration | $1-2 | Questions, debugging |
| Medium feature | $3-5 | 1 feature with tests |
| Large refactor | $5-10 | Many files |
| Intensive development | $10-20 | Coding all day |
Context: A mid-level developer costs $50-100/hour. If Claude saves you 50% of time, ROI is 10x+.
Claude Code Plans
| Plan | Cost/Month | Includes | Best For |
|---|---|---|---|
| Free tier | $0 | Limited | Trying it out |
| Pro | $20 | Generous tokens | Daily use |
| Team | $30/user | Collaboration | Teams |
Pro Tip: The Pro plan pays for itself if you use Claude Code more than 2-3 hours per week.
Metrics for Tracking
Keep track of:
- Cost per feature: How much did you spend on each feature?
- Time saved: How long would it have taken without Claude?
- ROI: Time saved × your rate vs Claude cost
Example Calculation
Feature: Authentication system
- Time without Claude: 8 hours
- Time with Claude: 2 hours
- Claude cost: $8
- My rate: $80/hour
- Time saved: 6 hours = $480 of value
- ROI: $480 / $8 = 60x
Mistakes That Cost Me Money
Mistake 1: Not Using /clear
The error: I worked 4 hours in the same chat. Context grew to 150k tokens. Each message cost triple.
The cost: ~$15 extra unnecessarily.
The lesson: /clear every 30-45 minutes of active work.
Mistake 2: Letting Claude Talk Too Much
The error: Claude generated long explanations I didn't ask for. Output tokens = expensive.
The cost: 2x what was needed in outputs.
The solution: Add to CLAUDE.md: "Be concise. Only code and essential comments."
Mistake 3: Context Bloated by Large Files
The error: A 10k line file was in context. Claude read it with every message.
The cost: Inflated input tokens.
The solution: Reorganize code into smaller files. Specify which files to ignore.
Optimization Checklist
- CLAUDE.md configured with clear rules
- Unnecessary files in ignore list
-
/clearevery 30-45 min of work - Concise prompts (no long explanations)
- Plan Mode for features > 1 hour
- Sub-agents for isolated tasks
- Tracking cost per feature
How Much Should I Spend?
| Profile | Expected Spend/Month |
|---|---|
| Hobby developer | $5-20 |
| Active freelancer | $30-60 |
| Full-time developer | $50-100 |
| Team of 5 | $150-300 |
If you're spending much more than this, review your workflow. If you're spending much less, you're probably not leveraging Claude Code to its fullest.
Challenge: Try This
This week:
- Run
/costat the end of each session - Note the cost of 3 different features
- Calculate ROI of at least 1 feature
- Implement 2 optimizations from this lesson
Estimated time: During your normal work
Next Step
Now that you know how to optimize costs, you have all the tools to use Claude Code in production. The last module is your 7-day action plan.