token-efficiency
Minimize token consumption when reading files and gathering context
Best use case
token-efficiency is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Minimize token consumption when reading files and gathering context
Teams using token-efficiency should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/token-efficiency/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How token-efficiency Compares
| Feature / Agent | token-efficiency | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Minimize token consumption when reading files and gathering context
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# Token Efficiency
**Load this skill at session start.** Token waste impacts cost and speed.
## OpenCode Read Protection
OpenCode requires reading a file before editing/writing it (for existing files). **Partial reads satisfy this requirement** - but you must read the section you intend to change.
**Why this matters:** The protection prevents overwriting content you haven't seen. If you read lines 1-50 but edit lines 200-250, you risk corrupting code you never reviewed.
```
# CORRECT - read the area you're changing
read({ filePath: "src/app.ts", offset: 200, limit: 50 })
edit({ filePath: "src/app.ts", oldString: "// line 220 content", newString: "..." })
# WRONG - reading unrelated section then editing elsewhere
read({ filePath: "src/app.ts", offset: 0, limit: 50 })
edit({ filePath: "src/app.ts", oldString: "// line 220 content", newString: "..." }) # Dangerous!
```
## File Reading Guidelines
### When Full Reads Are Acceptable
- Small files (<50 lines)
- Data files you need to analyze completely (JSON, CSV, config)
- Files where you need to understand the full structure
- New/unfamiliar codebases where you need context
### When to Use Partial Reads
- Large files (>100 lines) where you're editing a specific section
- Files you've already read in this session
- When grep/codegraph already told you the line numbers
### Tool Priority for Finding Code
1. `grep` → Find line numbers and file paths
2. `codegraphcontext` → Find symbol definitions and relationships
3. `glob` → Find file paths by pattern
4. `read` with `offset`/`limit` → Get targeted content
### Read Tool Usage
```
# Full read - fine for small files or when you need everything
read({ filePath: "config.json" })
# Partial read - preferred for large files
read({ filePath: "src/app.ts", offset: 100, limit: 50 })
```
## Edit vs Write Tool Selection
### Use `edit` when:
- Modifying existing code (most common case)
- You know the exact text to replace
- Changing a specific section of a large file
**Edit workflow:**
```
1. grep/codegraph → find location (line ~245)
2. read with offset/limit → get the lines around your target (read what you'll change)
3. edit({ filePath, oldString: "<exact match from step 2>", newString: "<replacement>" })
```
**Important:** Your `oldString` must come from what you actually read. Don't guess at content.
### Use `write` when:
- Creating new files (no prior read needed)
- Replacing entire small file content
- File is small AND you're changing most of it
### Token Comparison
| Scenario | edit approach | write approach |
|----------|---------------|----------------|
| Change 10 lines in 500-line file | Read ~50 lines | Read 500 lines |
| Change 100 lines in 500-line file | Read ~120 lines | Read 500 lines |
| Create new 50-line file | N/A | Write 50 lines (no read) |
| Rewrite small config (20 lines) | Either works | Either works |
## Common Patterns
**Editing a function you found with grep:**
```
grep "handleRequest" src/ → found at src/handler.ts:145
read({ filePath: "src/handler.ts", offset: 140, limit: 50 })
edit({ filePath: "src/handler.ts", oldString: "...", newString: "..." })
```
**Creating a new file:**
```
write({ filePath: "src/new-feature.ts", content: "..." })
# No prior read needed for new files
```
**Analyzing a data file:**
```
# Full read is appropriate here
read({ filePath: "data/config.json" })
```
## Anti-Patterns to Avoid
❌ Reading 500-line file to change 5 lines (use partial read)
❌ Using `write` to modify existing large files (use `edit`)
❌ Re-reading same file sections repeatedly (remember what you read)
❌ Reading full file "just in case" when grep already found the linesRelated Skills
compute-token-stats-rust-ultra
Ultra-fast token+cost computation for Codex + Claude SSE logs (Rust) plus Python anchor/fast comparisons; includes build+run+benchmark guide.
design-tokens
Apply design token patterns using Tailwind CSS 4 @theme directive: CSS variables, semantic naming, color systems, typography scales, spacing, dark mode. Use when designing UI systems, reviewing design consistency, or establishing brand guidelines. Integrates with frontend-design skill for aesthetic execution.
anthropic-token-refresh
Automatically refresh Anthropic Claude setup-token before expiration using browser automation. Use when: (1) Setting up auto token refresh for Claude Max/Pro subscription, (2) Token keeps expiring and causing OpenClaw to stop responding, (3) Want to maintain continuous Claude API access without manual intervention.
token-saver-75plus
Always-on token optimization + model routing protocol. Auto-classifies requests (T1-T4), routes execution to the cheapest capable model via sessions_spawn, and applies maximum output compression. Target: 75%+ token savings.
bgo
Automated Blender build-go workflow. Automatically builds, removes old version, installs, enables, and launches Blender with your extension/add-on. Use when you want to quickly test changes, execute complete build-to-launch cycle, or run custom packaging scripts with automatic Blender launch.
fireflies-automation
Automate Fireflies tasks via Rube MCP (Composio). Always search tools first for current schemas.
fireberry-automation
Automate Fireberry tasks via Rube MCP (Composio). Always search tools first for current schemas.
finmei-automation
Automate Finmei tasks via Rube MCP (Composio). Always search tools first for current schemas.
fingertip-automation
Automate Fingertip tasks via Rube MCP (Composio). Always search tools first for current schemas.
finerworks-automation
Automate Finerworks tasks via Rube MCP (Composio). Always search tools first for current schemas.
find-skill
Search for Agent Skills in local folders and on GitHub. Use when you need a capability you don't have—search before building.
finage-automation
Automate Finage tasks via Rube MCP (Composio). Always search tools first for current schemas.