# Token Optimizer

> 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.

- Skill: `chadjardine/token-optimizer` (Agent Skill)
- Install (CLI): `npx skillmds@latest add chadjardine/token-optimizer`
- Raw SKILL.md: https://api.skillmd.com/api/skills/chadjardine/token-optimizer/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: AI & ML
- Author: chadjardine (https://skillmd.com/u/chadjardine)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/chadjardine/token-optimizer

---


# 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`, `opusplan` alias, 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_control` on 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_tokens` vs `cache_creation_input_tokens` and 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 `opusplan` for users who plan with Opus and code with Sonnet — automated mid-session switch.
- Recommend `/effort` reduction or `MAX_THINKING_TOKENS=8000` for routine work.
- Recommend `ccusage` to 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-24` beta 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.

