Token Optimization Skill
This skill governs how Claude Code consumes tokens across every session. It is a behavioral skill — it changes how you operate, not what you build. Every tool call, file read, and response you generate has a token cost. This skill ensures you minimize waste without sacrificing quality.
Goal: Reduce monthly Claude Code/API spend by 30-60% through disciplined token-aware behavior.
1. Token Cost Model
Pricing Reference (2026)
| Model |
Input |
Output |
Cache Write |
Cache Read |
Thinking |
| Opus 4.6 |
$15/MTok |
$75/MTok |
$18.75/MTok |
$1.50/MTok |
$75/MTok (as output) |
| Sonnet 4.6 |
$3/MTok |
$15/MTok |
$3.75/MTok |
$0.30/MTok |
$15/MTok (as output) |
| Haiku 4.5 |
$1/MTok |
$5/MTok |
$1.25/MTok |
$0.10/MTok |
$5/MTok (as output) |
Sonnet is 5x cheaper on input and output than Opus. Haiku is 15x cheaper than Opus on input.
Cache reads are 90% cheaper than fresh input across all models.
What Consumes Tokens
| Source |
Loaded When |
Cost Impact |
| System prompt |
Every message |
Fixed per-turn cost |
| CLAUDE.md (global + project) |
Every message |
Fixed per-turn cost — keep lean |
| Skill files |
When skill is invoked/active |
Variable — large skills = large cost |
| Conversation history |
Every message (grows over time) |
Compounds — longest sessions cost most |
| Tool definitions (MCP servers) |
Session start (deferred by default) |
Per-tool metadata overhead |
| File reads (Read tool) |
Each invocation |
Scales with file size — biggest lever |
| Search results (Grep/Glob) |
Each invocation |
Scales with match count |
| Extended thinking |
Each response |
Default 31,999 tokens — often wasted |
| Subagent context |
Per-agent (isolated 200K window) |
Parallel cost — use deliberately |
The Hidden Costs
- CLAUDE.md bloat: Loaded into every single message. A 500-line CLAUDE.md costs tokens on every turn. Keep it under 200 lines.
- Extended thinking default: 31,999 thinking tokens per response, billed as output tokens at the model's output rate. For Opus, that's up to $2.40 per response in thinking alone.
- Unused MCP servers: Tool definitions consume tokens even when never called. Disable servers you don't need.
- Conversation drift: After 20+ turns, accumulated history becomes the dominant token cost. Clear between tasks.
2. Model Selection Strategy
Decision Framework
| Task Type |
Recommended Model |
Why |
| Simple edits, typo fixes, file renames |
Haiku |
15x cheaper than Opus, fast, sufficient quality |
| Standard coding (features, bug fixes, refactoring) |
Sonnet |
5x cheaper than Opus, comparable coding quality |
| Complex architecture, multi-file refactors |
Sonnet (default) or Opus (if struggling) |
Start cheaper, escalate if needed |
| Security audits, threat modeling |
Opus |
Requires deep reasoning and nuance |
| Subagents (tests, search, exploration) |
Sonnet or Haiku |
Isolated context — no need for Opus reasoning |
| Research, web fetching, summarization |
Sonnet |
Good comprehension at lower cost |
| Code review, PR review |
Sonnet |
Pattern matching, not deep reasoning |
Rules
- Default to Sonnet for 80%+ of tasks. It handles standard coding, debugging, and file operations at 1/5 the cost of Opus.
- Use Haiku for subagents unless the subtask requires complex reasoning. Exploration agents, test runners, and search agents work well on Haiku.
- Escalate to Opus only when Sonnet produces inadequate results — complex architectural decisions, multi-step reasoning chains, or nuanced security analysis.
- Never use Opus for simple file reads, searches, or formatting tasks.
Proactive Behavior
When you detect a task is simple (single file edit, straightforward question, formatting):
- Suggest the user switch: "This is a straightforward edit —
/model sonnet or /effort low would save tokens here."
- For subagent spawning, always specify
model: "sonnet" or model: "haiku" unless the task genuinely requires Opus-level reasoning.
3. File Reading Efficiency
File reads are the single largest controllable token cost in most sessions. A 500-line file costs ~2,000-4,000 tokens per read. Reading it 3 times in a session = 6,000-12,000 wasted tokens.
Rules
- Use
offset and limit parameters when you know the target area. If the user says "fix line 42," read lines 35-55, not the entire file.
- Grep first, Read second. Use Grep to locate the exact lines, then Read only those lines with offset/limit.
- Never re-read a file already in context unless it has been modified since the last read. The content is already in your conversation history.
- Read the minimum viable context. For a function fix, read the function + 5 lines of surrounding context. Not the whole file.
- Use Glob for file discovery, not Read. Don't read files to figure out what's in them — use Glob patterns and Grep searches.
Anti-Patterns
| Anti-Pattern |
Token Cost |
Better Approach |
Savings |
| Read entire 500-line file for a 5-line fix |
~3,000 tokens |
Read with offset/limit (20 lines) |
~2,800 tokens (93%) |
| Read the same file 3 times in one session |
~9,000 tokens |
Read once, reference from context |
~6,000 tokens (67%) |
| Read 10 files to find one function |
~30,000 tokens |
Grep for function name, Read 1 file |
~28,000 tokens (93%) |
| Read a file to check if it exists |
~3,000 tokens |
Use Glob or ls |
~2,990 tokens (99%) |
Proactive Behavior
Before every Read tool call, ask yourself:
- Is this file already in my context? → Don't re-read.
- Do I know the exact lines I need? → Use offset/limit.
- Could I find what I need with Grep instead? → Grep first.
- Am I reading to discover or to act? → If discover, use Glob/Grep.
4. Context Management
Token cost compounds over conversation length. Turn 1 sends ~5K tokens of context. Turn 20 might send ~50K+ tokens. Long sessions are exponentially more expensive.
Rules
- Recommend
/clear between unrelated tasks. If the user switches topics (e.g., from debugging to documentation), suggest clearing context.
- Use
/compact proactively when context is growing large and the conversation can be summarized without losing critical state.
- One task per session is the most token-efficient pattern. Encourage focused sessions over kitchen-sink conversations.
- Front-load specificity. A precise first prompt saves 5-10 rounds of clarification. "Fix the null check in auth.ts line 42" costs far less than "something's broken in auth."
When to Suggest /clear
- User has completed a task and is starting something unrelated
- Context has grown past ~30 turns
- User says "now let's work on something else" or similar
- Previous task involved large file reads that are no longer relevant
When to Suggest /compact
- Mid-task but context is getting large (20+ turns)
- Lots of file reads and search results accumulated
- The user is still working on the same task but early exploration is no longer needed
Anti-Patterns
- Marathon sessions: 50+ turn conversations where early context is dead weight
- Topic hopping: Switching between 3 unrelated tasks without clearing
- Exploratory spirals: Reading 20 files "to understand the codebase" when 3 would suffice
5. Thinking Budget Control
Extended thinking is billed as output tokens — the most expensive token category. The default budget of 31,999 tokens per response means every single response could cost up to $2.40 on Opus, even for trivial tasks.
Effort-to-Task Mapping
| Task Complexity |
Recommended Effort |
Thinking Budget |
Opus Cost/Response |
| Simple edit, formatting, file read |
/effort low |
~4,000 tokens |
~$0.30 |
| Standard feature, bug fix |
Default |
~16,000 tokens |
~$1.20 |
| Complex architecture, debugging |
/effort high |
~32,000 tokens |
~$2.40 |
| Security audit, multi-step reasoning |
/effort high |
~32,000 tokens |
~$2.40 |
Rules
- Match effort to task complexity. Simple tasks don't need deep reasoning chains.
- Suggest
/effort low for: file reads, simple edits, formatting, explanations of existing code, running commands.
- Reserve full thinking budget for: debugging complex issues, architectural decisions, security reviews, multi-file refactors.
- On Sonnet/Haiku, thinking is cheaper but still not free. Apply the same discipline.
Proactive Behavior
When a user asks a simple question or requests a minor edit:
- Use minimal internal reasoning. Don't overthink trivial tasks.
- If you notice you're generating long thinking chains for simple tasks, that's a signal to suggest
/effort low.
6. Subagent Efficiency
Subagents are powerful for context isolation — keeping verbose output (tests, logs, large searches) out of the main conversation. But each agent has its own context window and token consumption.
When to Use Subagents
| Scenario |
Use Subagent? |
Why |
| Running tests and checking output |
Yes |
Test output is verbose; isolate it |
| Searching across many files |
Yes (Explore type) |
Search results stay in subagent context |
| Reading and analyzing logs |
Yes |
Log content is huge; only summary returns |
| Single Grep + Read |
No |
Direct tool call is cheaper than agent overhead |
| Simple file edit |
No |
Agent spawn overhead exceeds the task cost |
| Parallel independent research |
Yes (2-3 max) |
Genuine parallelism saves wall-clock time |
Rules
- Specify
model: "sonnet" or model: "haiku" for subagents. Never default to Opus for subagent work unless the subtask requires it.
- Maximum 3 subagents in parallel. More than 3 creates diminishing returns and multiplied token costs.
- 1 agent for focused tasks. Don't spawn 3 agents when 1 will do.
- Give subagents focused prompts. Vague prompts cause agents to explore broadly, consuming more tokens.
- Use subagents to protect main context. The primary value is keeping verbose tool output out of the main conversation.
Anti-Patterns
- Agent for a Grep: Spawning an Explore agent to find one function when a direct Grep call takes 1 second
- Opus subagents: Using the most expensive model for search and test-running tasks
- Agent sprawl: Launching 5+ agents for a task that could be done sequentially in 3 tool calls
- Vague agent prompts: "Look into the auth system" instead of "Find where JWT tokens are validated in src/auth/"
7. Prompt & Response Efficiency
For Claude's Own Output
- Be concise. Lead with the answer, not the reasoning. Skip filler words and preamble.
- Use structured formats. Tables and lists compress information better than prose paragraphs.
- Don't repeat what's known. If the user asked you to edit a file, don't echo back the entire file contents in your response.
- Don't over-explain. If the edit is self-evident, a one-line summary suffices. Don't write a paragraph explaining a typo fix.
- Don't add unsolicited suggestions. Stick to what was asked. "While I was in there, I also noticed..." costs tokens for unrequested work.
Guiding User Prompts
When users provide vague prompts, the cost of interpretation is high (multiple searches, file reads, clarification rounds). Encourage specificity:
| Vague Prompt (Expensive) |
Specific Prompt (Cheap) |
| "Fix the bug" |
"Fix the null reference in auth.ts:42" |
| "Improve this codebase" |
"Add input validation to the login endpoint" |
| "Help with tests" |
"The test in user.test.ts:15 is failing with timeout" |
| "Something's wrong with the API" |
"POST /api/users returns 500 when email is empty" |
Response Length Guidelines
| Context |
Target Response Length |
| Simple edit confirmation |
1-2 sentences |
| Bug fix explanation |
3-5 sentences |
| Architecture recommendation |
1-2 paragraphs + diagram/table |
| Code review |
Bullet points per finding |
| Multi-file implementation |
Status per file, no echoing code back |
8. CLAUDE.md & Skill Optimization
CLAUDE.md is loaded into every single message in every session. It's the most persistent token cost in your entire setup.
Rules
- Keep CLAUDE.md under 200 lines. Every line costs tokens on every turn.
- Move specialized content into skills. Skills are loaded on-demand; CLAUDE.md is always-on.
- Use one-line skill references in CLAUDE.md, not full descriptions. The skill file has the details.
- Audit quarterly. Remove outdated entries, consolidate redundant instructions, trim verbose descriptions.
- Use scoping statements in skills. "For X, see skill Y" prevents duplication across skills.
Current CLAUDE.md Assessment
The current global CLAUDE.md lists 10 always-active skills with multi-line descriptions for each. This is loaded on every turn. Consider:
- Reducing skill descriptions to one line each
- Removing the "When Working on Any Project" section if it duplicates skill content
- Moving the flag format definitions into a skill or removing them if skills handle flagging
Skill Loading Costs
| Skill Size |
Approx Tokens |
Impact |
| Small (< 300 lines) |
~2,000-3,000 |
Low |
| Medium (300-600 lines) |
~4,000-8,000 |
Moderate |
| Large (600-1000 lines) |
~8,000-15,000 |
High — ensure it's needed |
If a skill is only relevant 10% of the time, it shouldn't be always-active. Move it to on-demand invocation.
9. Caching & Batch Strategies (API Users)
For teams using the Claude API directly (not just Claude Code CLI):
Prompt Caching
| Strategy |
Cost |
Savings vs Fresh Input |
| Fresh input (no cache) |
Base rate |
— |
| Cache write |
1.25x base rate |
Investment for future reads |
| Cache read (5-min TTL) |
0.1x base rate |
90% savings |
| Cache read (1-hour TTL) |
0.1x base rate (2x write cost) |
90% savings |
Implementation:
- Add
cache_control: {"type": "ephemeral"} to the last static content block
- Cache system prompts, large reference documents, RAG knowledge bases
- Minimum cacheable size: 2,048 tokens (Sonnet), 4,096 tokens (Opus/Haiku)
- Cache TTL: 5 minutes default, refreshed on each hit
Best candidates for caching:
- System instructions that don't change between requests
- Large documents passed as context (policies, codebases, specs)
- Tool definitions for MCP servers
- Few-shot examples in prompts
Batch API
- 50% discount on both input and output tokens
- Requests processed asynchronously within 24 hours
- Ideal for: bulk code analysis, batch document processing, non-urgent migrations
- Not suitable for: interactive sessions, real-time responses
10. Quick Reference Card
The 5-Second Decision
Is this task simple? (edit, format, read, explain)
→ /effort low + Sonnet
Is this task standard? (feature, bug fix, refactor)
→ Default effort + Sonnet
Is this task complex? (architecture, security, debugging)
→ Full effort + Opus (if Sonnet struggles)
Top 5 Token-Saving Habits
- Read targeted lines, not whole files — use offset/limit after Grep
- Clear between tasks —
/clear resets context cost to zero
- Use Sonnet by default — 5x cheaper, handles 80%+ of work
- Reduce thinking on simple tasks —
/effort low cuts thinking tokens 75%
- Delegate verbose work to subagents — isolate tests/logs from main context
Cost Per Common Operation (Opus)
| Operation |
Approx Token Cost |
Approx $ Cost |
| Read 500-line file |
~3,000 input |
$0.045 |
| Read 20 lines (targeted) |
~200 input |
$0.003 |
| Full thinking response |
~32,000 output |
$2.40 |
| Low effort response |
~4,000 output |
$0.30 |
| Subagent (Sonnet, small task) |
~5,000 total |
$0.05 |
| Subagent (Opus, large task) |
~50,000 total |
$4.50 |
| 30-turn conversation (accumulated) |
~100,000 input |
$1.50 |
Anti-Patterns (One-Line Each)
- Reading entire files when you need 10 lines
- Re-reading files already in context
- Using Opus for subagents that just run Grep
- 50-turn sessions without clearing
- Spawning 5 agents when 1 direct tool call works
- Full thinking budget for "fix this typo"
- CLAUDE.md over 200 lines with inline skill content
- Vague prompts that trigger broad codebase exploration
- Echoing file contents back in responses after editing
- Adding unsolicited code improvements beyond what was asked
Proactive Behavior Summary
When this skill is active, Claude Code should:
- Before every Read call: Check if the file is already in context. Use offset/limit when possible.
- Before spawning subagents: Verify the task can't be done with a direct tool call. Set model to Sonnet/Haiku.
- At conversation turn 15+: Suggest
/compact if the conversation has accumulated stale context.
- When task switches: Suggest
/clear if the user moves to an unrelated task.
- For simple tasks: Use minimal reasoning. Don't over-think trivial operations.
- In responses: Be concise. Don't echo code, don't over-explain, don't add unsolicited suggestions.
- When the user's prompt is vague: Ask for specificity before launching broad exploration. One clarifying question saves 10 expensive tool calls.
1---2name: token-optimization3description: Reduces token consumption and API costs by guiding efficient file reading, model selection, context management, prompt patterns, and subagent usage. Always active — shapes how Claude Code operates across all sessions.4license: MIT5---67# Token Optimization Skill89This skill governs how Claude Code consumes tokens across every session. It is a behavioral skill — it changes how you operate, not what you build. Every tool call, file read, and response you generate has a token cost. This skill ensures you minimize waste without sacrificing quality.1011**Goal:** Reduce monthly Claude Code/API spend by 30-60% through disciplined token-aware behavior.1213---1415## 1. Token Cost Model1617### Pricing Reference (2026)1819| Model | Input | Output | Cache Write | Cache Read | Thinking |20|-------|-------|--------|-------------|------------|----------|21| **Opus 4.6** | $15/MTok | $75/MTok | $18.75/MTok | $1.50/MTok | $75/MTok (as output) |22| **Sonnet 4.6** | $3/MTok | $15/MTok | $3.75/MTok | $0.30/MTok | $15/MTok (as output) |23| **Haiku 4.5** | $1/MTok | $5/MTok | $1.25/MTok | $0.10/MTok | $5/MTok (as output) |2425> Sonnet is **5x cheaper** on input and output than Opus. Haiku is **15x cheaper** than Opus on input.26> Cache reads are **90% cheaper** than fresh input across all models.2728### What Consumes Tokens2930| Source | Loaded When | Cost Impact |31|--------|-------------|-------------|32| System prompt | Every message | Fixed per-turn cost |33| CLAUDE.md (global + project) | Every message | Fixed per-turn cost — **keep lean** |34| Skill files | When skill is invoked/active | Variable — large skills = large cost |35| Conversation history | Every message (grows over time) | Compounds — longest sessions cost most |36| Tool definitions (MCP servers) | Session start (deferred by default) | Per-tool metadata overhead |37| File reads (Read tool) | Each invocation | Scales with file size — **biggest lever** |38| Search results (Grep/Glob) | Each invocation | Scales with match count |39| Extended thinking | Each response | Default 31,999 tokens — often wasted |40| Subagent context | Per-agent (isolated 200K window) | Parallel cost — use deliberately |4142### The Hidden Costs43441. **CLAUDE.md bloat**: Loaded into every single message. A 500-line CLAUDE.md costs tokens on every turn. Keep it under 200 lines.452. **Extended thinking default**: 31,999 thinking tokens per response, billed as output tokens at the model's output rate. For Opus, that's up to **$2.40 per response** in thinking alone.463. **Unused MCP servers**: Tool definitions consume tokens even when never called. Disable servers you don't need.474. **Conversation drift**: After 20+ turns, accumulated history becomes the dominant token cost. Clear between tasks.4849---5051## 2. Model Selection Strategy5253### Decision Framework5455| Task Type | Recommended Model | Why |56|-----------|-------------------|-----|57| Simple edits, typo fixes, file renames | **Haiku** | 15x cheaper than Opus, fast, sufficient quality |58| Standard coding (features, bug fixes, refactoring) | **Sonnet** | 5x cheaper than Opus, comparable coding quality |59| Complex architecture, multi-file refactors | **Sonnet** (default) or **Opus** (if struggling) | Start cheaper, escalate if needed |60| Security audits, threat modeling | **Opus** | Requires deep reasoning and nuance |61| Subagents (tests, search, exploration) | **Sonnet** or **Haiku** | Isolated context — no need for Opus reasoning |62| Research, web fetching, summarization | **Sonnet** | Good comprehension at lower cost |63| Code review, PR review | **Sonnet** | Pattern matching, not deep reasoning |6465### Rules66671. **Default to Sonnet** for 80%+ of tasks. It handles standard coding, debugging, and file operations at 1/5 the cost of Opus.682. **Use Haiku for subagents** unless the subtask requires complex reasoning. Exploration agents, test runners, and search agents work well on Haiku.693. **Escalate to Opus only when Sonnet produces inadequate results** — complex architectural decisions, multi-step reasoning chains, or nuanced security analysis.704. **Never use Opus for simple file reads, searches, or formatting tasks.**7172### Proactive Behavior7374When you detect a task is simple (single file edit, straightforward question, formatting):75- Suggest the user switch: "This is a straightforward edit — `/model sonnet` or `/effort low` would save tokens here."76- For subagent spawning, always specify `model: "sonnet"` or `model: "haiku"` unless the task genuinely requires Opus-level reasoning.7778---7980## 3. File Reading Efficiency8182File reads are the **single largest controllable token cost** in most sessions. A 500-line file costs ~2,000-4,000 tokens per read. Reading it 3 times in a session = 6,000-12,000 wasted tokens.8384### Rules85861. **Use `offset` and `limit` parameters** when you know the target area. If the user says "fix line 42," read lines 35-55, not the entire file.872. **Grep first, Read second.** Use Grep to locate the exact lines, then Read only those lines with offset/limit.883. **Never re-read a file already in context** unless it has been modified since the last read. The content is already in your conversation history.894. **Read the minimum viable context.** For a function fix, read the function + 5 lines of surrounding context. Not the whole file.905. **Use Glob for file discovery, not Read.** Don't read files to figure out what's in them — use Glob patterns and Grep searches.9192### Anti-Patterns9394| Anti-Pattern | Token Cost | Better Approach | Savings |95|-------------|-----------|-----------------|---------|96| Read entire 500-line file for a 5-line fix | ~3,000 tokens | Read with offset/limit (20 lines) | ~2,800 tokens (93%) |97| Read the same file 3 times in one session | ~9,000 tokens | Read once, reference from context | ~6,000 tokens (67%) |98| Read 10 files to find one function | ~30,000 tokens | Grep for function name, Read 1 file | ~28,000 tokens (93%) |99| Read a file to check if it exists | ~3,000 tokens | Use Glob or `ls` | ~2,990 tokens (99%) |100101### Proactive Behavior102103Before every Read tool call, ask yourself:1041. Is this file already in my context? → Don't re-read.1052. Do I know the exact lines I need? → Use offset/limit.1063. Could I find what I need with Grep instead? → Grep first.1074. Am I reading to discover or to act? → If discover, use Glob/Grep.108109---110111## 4. Context Management112113Token cost compounds over conversation length. Turn 1 sends ~5K tokens of context. Turn 20 might send ~50K+ tokens. Long sessions are exponentially more expensive.114115### Rules1161171. **Recommend `/clear` between unrelated tasks.** If the user switches topics (e.g., from debugging to documentation), suggest clearing context.1182. **Use `/compact` proactively** when context is growing large and the conversation can be summarized without losing critical state.1193. **One task per session** is the most token-efficient pattern. Encourage focused sessions over kitchen-sink conversations.1204. **Front-load specificity.** A precise first prompt saves 5-10 rounds of clarification. "Fix the null check in auth.ts line 42" costs far less than "something's broken in auth."121122### When to Suggest `/clear`123124- User has completed a task and is starting something unrelated125- Context has grown past ~30 turns126- User says "now let's work on something else" or similar127- Previous task involved large file reads that are no longer relevant128129### When to Suggest `/compact`130131- Mid-task but context is getting large (20+ turns)132- Lots of file reads and search results accumulated133- The user is still working on the same task but early exploration is no longer needed134135### Anti-Patterns136137- **Marathon sessions**: 50+ turn conversations where early context is dead weight138- **Topic hopping**: Switching between 3 unrelated tasks without clearing139- **Exploratory spirals**: Reading 20 files "to understand the codebase" when 3 would suffice140141---142143## 5. Thinking Budget Control144145Extended thinking is billed as **output tokens** — the most expensive token category. The default budget of 31,999 tokens per response means every single response could cost up to $2.40 on Opus, even for trivial tasks.146147### Effort-to-Task Mapping148149| Task Complexity | Recommended Effort | Thinking Budget | Opus Cost/Response |150|----------------|--------------------|-----------------|--------------------|151| Simple edit, formatting, file read | `/effort low` | ~4,000 tokens | ~$0.30 |152| Standard feature, bug fix | Default | ~16,000 tokens | ~$1.20 |153| Complex architecture, debugging | `/effort high` | ~32,000 tokens | ~$2.40 |154| Security audit, multi-step reasoning | `/effort high` | ~32,000 tokens | ~$2.40 |155156### Rules1571581. **Match effort to task complexity.** Simple tasks don't need deep reasoning chains.1592. **Suggest `/effort low`** for: file reads, simple edits, formatting, explanations of existing code, running commands.1603. **Reserve full thinking budget** for: debugging complex issues, architectural decisions, security reviews, multi-file refactors.1614. **On Sonnet/Haiku, thinking is cheaper** but still not free. Apply the same discipline.162163### Proactive Behavior164165When a user asks a simple question or requests a minor edit:166- Use minimal internal reasoning. Don't overthink trivial tasks.167- If you notice you're generating long thinking chains for simple tasks, that's a signal to suggest `/effort low`.168169---170171## 6. Subagent Efficiency172173Subagents are powerful for **context isolation** — keeping verbose output (tests, logs, large searches) out of the main conversation. But each agent has its own context window and token consumption.174175### When to Use Subagents176177| Scenario | Use Subagent? | Why |178|----------|---------------|-----|179| Running tests and checking output | **Yes** | Test output is verbose; isolate it |180| Searching across many files | **Yes** (Explore type) | Search results stay in subagent context |181| Reading and analyzing logs | **Yes** | Log content is huge; only summary returns |182| Single Grep + Read | **No** | Direct tool call is cheaper than agent overhead |183| Simple file edit | **No** | Agent spawn overhead exceeds the task cost |184| Parallel independent research | **Yes** (2-3 max) | Genuine parallelism saves wall-clock time |185186### Rules1871881. **Specify `model: "sonnet"` or `model: "haiku"` for subagents.** Never default to Opus for subagent work unless the subtask requires it.1892. **Maximum 3 subagents in parallel.** More than 3 creates diminishing returns and multiplied token costs.1903. **1 agent for focused tasks.** Don't spawn 3 agents when 1 will do.1914. **Give subagents focused prompts.** Vague prompts cause agents to explore broadly, consuming more tokens.1925. **Use subagents to protect main context.** The primary value is keeping verbose tool output out of the main conversation.193194### Anti-Patterns195196- **Agent for a Grep**: Spawning an Explore agent to find one function when a direct Grep call takes 1 second197- **Opus subagents**: Using the most expensive model for search and test-running tasks198- **Agent sprawl**: Launching 5+ agents for a task that could be done sequentially in 3 tool calls199- **Vague agent prompts**: "Look into the auth system" instead of "Find where JWT tokens are validated in src/auth/"200201---202203## 7. Prompt & Response Efficiency204205### For Claude's Own Output2062071. **Be concise.** Lead with the answer, not the reasoning. Skip filler words and preamble.2082. **Use structured formats.** Tables and lists compress information better than prose paragraphs.2093. **Don't repeat what's known.** If the user asked you to edit a file, don't echo back the entire file contents in your response.2104. **Don't over-explain.** If the edit is self-evident, a one-line summary suffices. Don't write a paragraph explaining a typo fix.2115. **Don't add unsolicited suggestions.** Stick to what was asked. "While I was in there, I also noticed..." costs tokens for unrequested work.212213### Guiding User Prompts214215When users provide vague prompts, the cost of interpretation is high (multiple searches, file reads, clarification rounds). Encourage specificity:216217| Vague Prompt (Expensive) | Specific Prompt (Cheap) |218|--------------------------|------------------------|219| "Fix the bug" | "Fix the null reference in auth.ts:42" |220| "Improve this codebase" | "Add input validation to the login endpoint" |221| "Help with tests" | "The test in user.test.ts:15 is failing with timeout" |222| "Something's wrong with the API" | "POST /api/users returns 500 when email is empty" |223224### Response Length Guidelines225226| Context | Target Response Length |227|---------|----------------------|228| Simple edit confirmation | 1-2 sentences |229| Bug fix explanation | 3-5 sentences |230| Architecture recommendation | 1-2 paragraphs + diagram/table |231| Code review | Bullet points per finding |232| Multi-file implementation | Status per file, no echoing code back |233234---235236## 8. CLAUDE.md & Skill Optimization237238CLAUDE.md is loaded into **every single message** in every session. It's the most persistent token cost in your entire setup.239240### Rules2412421. **Keep CLAUDE.md under 200 lines.** Every line costs tokens on every turn.2432. **Move specialized content into skills.** Skills are loaded on-demand; CLAUDE.md is always-on.2443. **Use one-line skill references** in CLAUDE.md, not full descriptions. The skill file has the details.2454. **Audit quarterly.** Remove outdated entries, consolidate redundant instructions, trim verbose descriptions.2465. **Use scoping statements in skills.** "For X, see skill Y" prevents duplication across skills.247248### Current CLAUDE.md Assessment249250The current global CLAUDE.md lists 10 always-active skills with multi-line descriptions for each. This is loaded on every turn. Consider:251- Reducing skill descriptions to one line each252- Removing the "When Working on Any Project" section if it duplicates skill content253- Moving the flag format definitions into a skill or removing them if skills handle flagging254255### Skill Loading Costs256257| Skill Size | Approx Tokens | Impact |258|-----------|---------------|--------|259| Small (< 300 lines) | ~2,000-3,000 | Low |260| Medium (300-600 lines) | ~4,000-8,000 | Moderate |261| Large (600-1000 lines) | ~8,000-15,000 | High — ensure it's needed |262263If a skill is only relevant 10% of the time, it shouldn't be always-active. Move it to on-demand invocation.264265---266267## 9. Caching & Batch Strategies (API Users)268269For teams using the Claude API directly (not just Claude Code CLI):270271### Prompt Caching272273| Strategy | Cost | Savings vs Fresh Input |274|----------|------|----------------------|275| Fresh input (no cache) | Base rate | — |276| Cache write | 1.25x base rate | Investment for future reads |277| Cache read (5-min TTL) | **0.1x base rate** | **90% savings** |278| Cache read (1-hour TTL) | **0.1x base rate** (2x write cost) | **90% savings** |279280**Implementation:**281- Add `cache_control: {"type": "ephemeral"}` to the last static content block282- Cache system prompts, large reference documents, RAG knowledge bases283- Minimum cacheable size: 2,048 tokens (Sonnet), 4,096 tokens (Opus/Haiku)284- Cache TTL: 5 minutes default, refreshed on each hit285286**Best candidates for caching:**287- System instructions that don't change between requests288- Large documents passed as context (policies, codebases, specs)289- Tool definitions for MCP servers290- Few-shot examples in prompts291292### Batch API293294- **50% discount** on both input and output tokens295- Requests processed asynchronously within 24 hours296- Ideal for: bulk code analysis, batch document processing, non-urgent migrations297- Not suitable for: interactive sessions, real-time responses298299---300301## 10. Quick Reference Card302303### The 5-Second Decision304305```306Is this task simple? (edit, format, read, explain)307 → /effort low + Sonnet308 309Is this task standard? (feature, bug fix, refactor)310 → Default effort + Sonnet311 312Is this task complex? (architecture, security, debugging)313 → Full effort + Opus (if Sonnet struggles)314```315316### Top 5 Token-Saving Habits3173181. **Read targeted lines, not whole files** — use offset/limit after Grep3192. **Clear between tasks** — `/clear` resets context cost to zero3203. **Use Sonnet by default** — 5x cheaper, handles 80%+ of work3214. **Reduce thinking on simple tasks** — `/effort low` cuts thinking tokens 75%3225. **Delegate verbose work to subagents** — isolate tests/logs from main context323324### Cost Per Common Operation (Opus)325326| Operation | Approx Token Cost | Approx $ Cost |327|-----------|-------------------|---------------|328| Read 500-line file | ~3,000 input | $0.045 |329| Read 20 lines (targeted) | ~200 input | $0.003 |330| Full thinking response | ~32,000 output | $2.40 |331| Low effort response | ~4,000 output | $0.30 |332| Subagent (Sonnet, small task) | ~5,000 total | $0.05 |333| Subagent (Opus, large task) | ~50,000 total | $4.50 |334| 30-turn conversation (accumulated) | ~100,000 input | $1.50 |335336### Anti-Patterns (One-Line Each)337338- Reading entire files when you need 10 lines339- Re-reading files already in context340- Using Opus for subagents that just run Grep341- 50-turn sessions without clearing342- Spawning 5 agents when 1 direct tool call works343- Full thinking budget for "fix this typo"344- CLAUDE.md over 200 lines with inline skill content345- Vague prompts that trigger broad codebase exploration346- Echoing file contents back in responses after editing347- Adding unsolicited code improvements beyond what was asked348349---350351## Proactive Behavior Summary352353When this skill is active, Claude Code should:3543551. **Before every Read call**: Check if the file is already in context. Use offset/limit when possible.3562. **Before spawning subagents**: Verify the task can't be done with a direct tool call. Set model to Sonnet/Haiku.3573. **At conversation turn 15+**: Suggest `/compact` if the conversation has accumulated stale context.3584. **When task switches**: Suggest `/clear` if the user moves to an unrelated task.3595. **For simple tasks**: Use minimal reasoning. Don't over-think trivial operations.3606. **In responses**: Be concise. Don't echo code, don't over-explain, don't add unsolicited suggestions.3617. **When the user's prompt is vague**: Ask for specificity before launching broad exploration. One clarifying question saves 10 expensive tool calls.