Skill detail
token-efficiency
Token optimization best practices for cost-effective Claude Code usage: efficient file reading, quiet output modes, grep over reads, bash over file reads, and model selection guidance. Directly targets reducing token usage.
Inspect before use
Read the source instructions and check the requirements before you install this skill.
SKILL.md
The saved excerpt is a snapshot from when this skill was listed. The external source remains the complete and most current version.
--- name: token-efficiency description: Token optimization best practices for cost-effective Claude Code usage. Automatically applies efficient file reading, command execution, and output handling strategies. Includes model selection guidance (Opus for learning, Sonnet for development/debugging). Prefers bash commands over reading files. version: 1.5.0 allowed-tools: Read, Grep, Glob, Bash --- # Token Efficiency Expert This skill provides token optimization strategies for cost-effective Claude Code usage across all projects. These guidelines help minimize token consumption while maintaining high-quality assistance. ## Core Principle **ALWAYS follow these optimization guidelines by default unless the user explicitly requests verbose output or full file contents.** Default assumption: **Users prefer efficient, cost-effective assistance.** --- ## Model Selection Strategy **Use the right model for the task to optimize cost and performance:** ### Opus - For Learning and Deep Understanding **Use Opus when:** - Learning new codebases - Understanding architecture, code structure, design patterns - Broad exploration - Identifying key files, understanding repository organization - Deep analysis - Analyzing complex algorithms, performance optimization - Reading and understanding - When you need to comprehend existing code before making changes - Very complex debugging - Only when Sonnet can't solve it or issue is architectural ### Sonnet - For Regular Development Tasks (DEFAULT) **Use Sonnet (default) for:** - Writing code, editing and fixing, debugging, testing, documentation, deployment, general questions **Typical session pattern:** 1. **Start with Opus** - Spend 10-15 minutes understanding the codebase (one-time investment) 2. **Switch to Sonnet** - Use for ALL implementation, debugging, and routine work 3. **Return to Opus** - Only when explicitly needed for deep architectural understanding **Savings: ~50% token cost vs all-Opus usage.** --- ## Skills and Token Efficiency **Myth:** Having many skills in `.claude/skills/` increases token usage. **Reality:** Skills use **progressive disclosure** - Claude sees only skill descriptions at session start (~155 tokens for 4 skills). Full skill content loaded only when activated. **It's safe to symlink multiple skills to a project.** Token waste comes from reading large files unnecessarily, not from having skills available. --- ## Token Optimization Rules (Quick Reference) ### 1. Use Quiet/Minimal Output Modes Use `--quiet`, `-q`, `--silent` flags by default. Only use verbose when user explicitly asks. ### 2. NEVER Read Entire Log Files Always filter before reading: `tail -100`, `grep -i "error"`, specific time ranges. ### 3. Check Lightweight Sources First Check `git status --short`, `package.json`, `requirements.txt` before reading large files. ### 4. Use Grep Instead of Reading Files Search for specific content with Grep tool instead of reading entire files. ### 5. Read Files with Limits Use offset and limit parameters. Check file size with `wc -l` first. ### 6. Use Bash Commands Instead of Reading Files **CRITICAL OPTIMIZATION** for pure transformations and inspection. Reading files costs tokens; bash commands don't. | Operation | Wasteful | Efficient | |-----------|----------|-----------| | Copy file | Read + Write | `cp source dest` | | Replace text | Read + Edit | `sed -i '' 's/old/new/g' file` | | Append | Read + Write | `echo "text" >> file` | | Delete lines | Read + Write | `sed -i '' '/pattern/d' file` | | Merge files | Read + Read + Write | `cat file1 file2 > combined` | | Count lines | Read file | `wc -l file` | | Check content | Read file | `grep -q "term" file` | | Inspect JSON | Read + parse mentally | `python3 -c "import json; ..."` or `jq` | **When to break this rule — prefer Read + Edit instead:** - **Code edits** (`.py`, `.js`, `.xml`, `.ga`, `.tsx`, etc.) where the user benefits from seeing a reviewable diff. The cost of reading a small fileRead the full source on GitHub (opens external page)