token-optimizer
Skill0 starsChanged 3 months agoMITView on GitHub
Cut wasted tokens on every Claude interaction. Use this skill whenever the user mentions tokens, cost, billing, usage, context size, model choice, restarting a chat, or running into limits — and also proactively any time the conversation shows signs of token waste: long context, repeated reference material, vague prompts that will need clarification, full-file rewrites when a diff would do, deep-thinking on a lookup question, or many sequential web searches. Apply this skill across claude.ai, the Anthropic API, and Claude Code; the levers differ by surface and the skill flags which apply where.
24 other projects use a version of this.
Adopted by
Most recently taken up by
- blinkboxhq/Blinkboxtheir own version, first seen Nov 8, 2026
- ZhouYinLong-lab/Dog-Skillstheir own version, first seen Nov 8, 2026
- Tejas9406/vibe-coding-ostheir own version, first seen Nov 1, 2026
- vikneshwaran16032005-alt/claude-skillstheir own version, first seen Oct 23, 2026
- Anmolop97/Agent-Skillstheir own version, first seen Oct 20, 2026
- tingyulu/MyR2D2their own version, first seen Oct 16, 2026
Used with
Projects with it also use mcp-builder, webapp-testing and 1 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
MicrosoftSkillmcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK).
Also in 4 projects that use this
JetBrainsSkillwebapp-testing
Toolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing browser screenshots, and viewing browser logs.
Also in 3 projects that use this
SentrySkillskill-creator
Create new agent skills following the Agent Skills specification. Use when asked to "create a skill", "add a new skill", "write a skill", "make a skill", "build a skill", or scaffold a new skill with SKILL.md. Guides through requirements, writing, registration, and verification.
Also in 5 projects that use this
Other versions24 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 24
- alexgreensh/token-optimizer★ 2.9ksame name
- nitinjain999/platform-skills★ 71same name
- georgekhananaev/claude-skills-vault★ 28same name
- aayushostwal/nexus★ 19same name
- tingyulu/MyR2D2★ 19same name
- thesaifalitai/claude-setup★ 9same name
- GPire/claude-skills-swarm★ 8same name
- ZhouYinLong-lab/Dog-Skills★ 7same name
- samibajwaisking/Token-Optimizer-Skill★ 6same name
- amunozdev/token-optimizer★ 4same name
14 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository2 other files it gives its agents.
- aristotle-deconstructorSkill
- session-handoffSkill
The file
We split this skill into the rules it gives an agent
8 rules. 0 are common, 8 are distinctive, and 0 are very specific to this project.
0
Common
Most of the 18 edited versions we read keep these.
8
Distinctive
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 18
When advice is surface-specific, name the surface.
- Distinctive: line 27
Default to concise. No preamble, no recap of the user's question, no closing pleasantries.
- Distinctive: line 34
Do not re-quote large pasted material back to the user.
- Distinctive: line 43
Search the web only when needed.
- Distinctive: line 58
Don't trigger: if the user is mid-task and the prior context is still load-bearing.
- Distinctive: line 143
No if traffic is sparse or prompts are highly varied — caching writes will cost more than reads save.
- Distinctive: line 156
When advice requires the user to act in the UI, say so explicitly and tell them where to go (Settings, Projects, the model picker, the …
- Distinctive: line 162
Keep coaching prompts short, plain, and actionable.
“Common” is measured: kept by at least 6 in 10 of the 18 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Token Optimizer
A two-part skill: behavioral defaults Claude follows silently, and coaching prompts Claude raises with the user at the right moment. The goal is fewer tokens for the same outcome.
Surface check (do this first)
Token-saving levers vary by where the user runs Claude. Identify the surface before acting:
- claude.ai (web/desktop/mobile) — No caching, no batch API. Levers: model choice, output length, context hygiene, Projects, restart timing, feature toggles, Research mode.
- Anthropic API — All claude.ai levers plus prompt caching, batch processing, max_tokens control, extended thinking budget.
- Claude Code — All API levers plus subagents,
/effort,/model,opusplanalias, auto-compaction awareness,ccusage.
When advice is surface-specific, name the surface.
Part 1: Behavioral defaults (what Claude does silently)
Apply these without announcing them unless the user asks.
Output discipline
- Default to concise. No preamble, no recap of the user's question, no closing pleasantries. Bills as output tokens at roughly 5x input on most models — trimming output beats trimming input.
- For edits to existing artifacts/files, produce a diff or patch, never a full rewrite. Quote only the lines that change plus minimal anchor lines.
- Skip "Here's what I'll do" framing. Just do it.
- Match length to the question. A one-sentence question gets a one-paragraph answer unless depth is requested.
Input discipline
- Front-load constraints in turn 1. If the user's request is ambiguous in a way that will force a clarifying turn, ask one focused question instead of guessing — a wrong guess re-bills the entire context on the correction turn.
- Do not re-quote large pasted material back to the user. Reference it.
- Strip irrelevant context when summarizing tool results back to the user.
Reasoning discipline
- For lookups, definitions, and mechanical transformations, keep thinking minimal.
- Reserve heavier reasoning for genuine analysis, planning, debugging, and design.
- On the API or Claude Code, recommend lowering extended thinking budget when the task doesn't justify it.
Tool discipline
- Search the web only when needed. Batch related questions into one search query rather than three sequential ones.
- For tasks that would require 15+ searches, recommend Research mode instead of grinding through fetches.
- In Claude Code, push verbose work (log scans, test runs, greps) into subagents so only summaries return.
Part 2: Coaching triggers (when to prompt the user)
Surface these directly to the user at the moment they apply. Keep each prompt to one or two sentences.
Restart suggestion
Trigger: Conversation has crossed a natural breakpoint and context is heavy — long pasted material early on, many tool results accumulated, or a finished task with the user starting something unrelated.
Say: "We're carrying a lot of context from earlier work. A new chat would re-bill everything from scratch each turn, so a fresh chat for [the new task] will be cheaper and probably sharper. Want to start one?"
Don't trigger if the user is mid-task and the prior context is still load-bearing.
Model downgrade
Trigger: User is on Opus or Sonnet for a task that Haiku would handle — short rewrites, formatting, simple extraction, basic Q&A, transcription cleanup, straightforward summarization.
Say: "Haiku will handle this fine at a fraction of the cost. Worth switching for this one?"
Model upgrade (yes, sometimes upgrading saves money)
Trigger: User is grinding on the same problem across many turns with a smaller model, hitting wrong answers, asking for retries, or expanding clarifications.
Say: "We've gone several rounds on this. A stronger model will likely one-shot it and use fewer total tokens than the back-and-forth. Worth trying?"
Move to Projects / pin context
Trigger: User pastes the same reference document, style guide, or brief across multiple chats, or references "the doc I sent before" from prior chats.
Say: "If you'll keep referencing this material, putting it in a Project means you stop paying input tokens for it on every new chat."
Preprocess before upload
Trigger: User uploads a large PDF, scanned image, or high-resolution screenshot for a task that only needs the text.
Say: "Extracting the text first and pasting that instead of the [PDF/image] cuts input tokens by [rough estimate]. Want to do that?"
Research mode
Trigger: User asks a question that will plainly require many searches and synthesis across sources — competitive landscapes, multi-source fact-checking, market scans, deep technical comparisons.
Say: "This is a Research-mode kind of question. One pass there will cost less than us iterating through searches here."
Tighten the spec
Trigger: User's prompt is vague enough that Claude's first answer will likely miss, forcing a redo.
Say: "Quick check before I run: [the one specific question]. Otherwise I'll guess and we'll burn a turn correcting it."
Disable features they aren't using
Trigger: User is doing pure text work with web search, code execution, or extended thinking enabled.
Say: "You're not using [feature] for this. Turning it off in Settings drops the system-prompt overhead on every turn."
Part 3: API and Claude Code levers (surface-specific advice)
Surface these when the user asks about API costs, mentions production usage, or describes a programmatic workflow.
Prompt caching (API + Claude Code)
- Recommend when the user has a stable prefix (system prompt, tool definitions, large reference doc) reused across many requests within a 5-minute or 1-hour window.
- Order: tools → system → messages, with
cache_controlon the last static block. - Cache reads cost 10% of standard input. Writes cost 1.25x (5-min TTL) or 2x (1-hour TTL).
- Break-even: one read at 5-min, two reads at 1-hour. Below that, caching costs more than it saves.
- Tell the user to log
cache_read_input_tokensvscache_creation_input_tokensand target a hit rate above 60%.
Batch processing (API)
- Recommend for any non-urgent bulk job: evaluations, content generation pipelines, document processing, overnight runs.
- 50% discount, up to 24-hour latency.
- Stack with prompt caching using the 1-hour TTL — most batches finish inside that window.
Claude Code specifics
- Recommend
opusplanfor users who plan with Opus and code with Sonnet — automated mid-session switch. - Recommend
/effortreduction orMAX_THINKING_TOKENS=8000for routine work. - Recommend
ccusageto anyone optimizing without baseline data. "Profile before you optimize." - Flag that auto-compaction itself costs tokens; restarting at logical breakpoints avoids surprise compaction bills.
- Recommend subagents for verbose work (running tests, fetching docs, scanning logs) — keeps the main context clean.
Extended output (API, batch only)
- For book-length drafts or massive structured extraction, mention the
output-300k-2026-03-24beta header on batch.
Decision rules
Should I suggest a restart?
Yes if all of:
- Current task is finished or the user pivots topics
- Context contains material the next task won't need
- The user hasn't already declined a restart this session
Should I suggest a smaller model?
Yes if the task fits a Haiku-class workload: short transformations, lookups, simple summaries, formatting, basic extraction. No if the task involves multi-step reasoning, code architecture, nuanced writing, or complex analysis.
Should I suggest caching?
Yes if the user describes:
- A production app with repeated system prompts
- A RAG-style workflow with stable reference docs
- An agent loop with stable tool definitions
- Any pattern where the same 1,024+ tokens appear in many requests within 5 minutes
No if traffic is sparse or prompts are highly varied — caching writes will cost more than reads save.
Should I suggest batch?
Yes if the workload is non-urgent and bulk. No if responses are user-facing in real time.
What this skill does not do
- Cannot edit Settings, Projects, or memory on the user's behalf.
- Cannot retroactively shrink the current chat's context.
- Cannot see token counts directly in claude.ai — recommendations are based on conversation signals (length of pasted material, number of turns, type of work), not measured usage.
When advice requires the user to act in the UI, say so explicitly and tell them where to go (Settings, Projects, the model picker, the feature toggle).
Tone
Keep coaching prompts short, plain, and actionable. No hedging, no apology, no explaining the entire pricing model unless asked. The user wants the lever, not the lecture.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

