token-optimizer

token-optimizer is a skill for Claude Code, Codex from arturseo-geo/claude-code-skills. It costs 152 tokens per session (4,214 once invoked), scanned A, original, MIT.

A guide for reducing the number of tokens used by Claude Code, where tokens are the text units that affect model usage and cost.

In plain words
What is it for?
Use it to tune model selection, thinking limits, automatic conversation compaction, subagent models, prompt caching, and project instruction files.
Why use it?
It identifies common sources of wasted usage, such as long instructions, unused tools, excessive thinking, growing conversation history, and expensive model choices.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one. Also seen: reads .claude/ paths; mentions CLAUDE.md; mentions subagents.

Good fit Use it to tune model selection, thinking limits, automatic conversation compaction, subagent models, prompt caching, and project instruction files.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/arturseo-geo/claude-code-skills/token-optimizer
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add arturseo-geo/claude-code-skills --skill token-optimizer
Clone the repo
git clone --depth 1 https://github.com/arturseo-geo/claude-code-skills

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for token-optimizer

README.md
[![agentmods](https://agentmods.dev/badge/skills/arturseo-geo/claude-code-skills/token-optimizer/github.svg)](https://agentmods.dev/skills/arturseo-geo/claude-code-skills/token-optimizer)
Your own site
<a href="https://agentmods.dev/skills/arturseo-geo/claude-code-skills/token-optimizer"><img src="https://agentmods.dev/badge/skills/arturseo-geo/claude-code-skills/token-optimizer/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for token-optimizer

Your own site · 80×15
<a href="https://agentmods.dev/skills/arturseo-geo/claude-code-skills/token-optimizer"><img src="https://agentmods.dev/badge/skills/arturseo-geo/claude-code-skills/token-optimizer.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 152 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 4,214 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00152 $0.04214
Opus 5 $0.00076 $0.02107
Sonnet 5 $0.00030 $0.00843
Haiku 4.5 $0.00015 $0.00421

Measured 9d ago against content hash c4a0f2a5c846, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-08, from the pricing page.

Security

Grade A, and why

token-optimizer scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 9d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/token-optimizer/SKILL.md · 452 lines

How it starts

The opening of the file, as written. The whole thing — 452 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Token Optimizer Skill

The Token Cost Breakdown

Understanding where tokens actually go in a typical Claude Code session:

Source Typical tokens Controllable?
System tools (built-in) ~16.8k No — Fixed
System prompt ~2.7k No — Fixed
MCP tool descriptions 200-500 per tool Yes — Disable unused
CLAUDE.md / memory files 1k-20k+ Yes — Trim aggressively
Agent persona files 200-1k each Yes — Use functional roles
Skill descriptions ~100 per skill Yes — Keep library lean
Extended thinking (hidden) Up to 31,999/request Yes — Cap with env var
Prompt caching overhead 25% write premium Yes — Maximise cache hits
Subagent model choice 5-15x cost difference Yes — Route to Haiku
Conversation history Grows until compaction Yes — Compact strategically

Settings — The High-Impact Tuning Knobs

Add to .claude/settings.json:

{
  "model": "sonnet",
  "env": {
    "MAX_THINKING_TOKENS": "10000",
    "CLAUDE_AUTOCOMPACT_PCT_OVERRIDE": "70",
    "CLAUDE_CODE_SUBAGENT_MODEL": "haiku"
  }
}

MAX_THINKING_TOKENS

Extended thinking reserves up to 31,999 tokens per request for internal reasoning.

  • Default: 31,999 (very expensive for simple tasks)
  • 10000: ~70% cost reduction on thinking, sufficient for most coding tasks
  • 0: disables extended thinking entirely (use for trivial/repetitive tasks)
  • 20000: good balance for complex architecture work
  • See references/thinking-tokens.md for detailed tuning guidance

CLAUDE_CODE_SUBAGENT_MODEL

Subagents (spawned via the Task tool) default to the same model as the main session.

  • Set to haiku for cheap parallel work: file reading, grep, simple transforms
  • Subagents doing complex reasoning? Override per-task to sonnet
  • Never route subagents to Opus — the reasoning overhead is wasted on narrow tasks
  • Typical savings: 60-80% reduction on subagent costs

CLAUDE_AUTOCOMPACT_PCT_OVERRIDE

Controls when auto-compaction fires (default ~83.5% = 167k tokens used).

  • 70: compacts earlier, more frequently, less data lost per event
  • 50: very aggressive — good for extremely long sessions
  • Lower = more compaction events but each loses less precision

Read the full file on GitHub · 452 lines

Files

What ships with it

5 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 9d ago First seen · 452 lines · 152 tokens per session scan A c4a0f2a5c846

Subscribe to this mod's changes

token-optimizer is a skill published in the GitHub repository arturseo-geo/claude-code-skills (11 stars, last pushed 5mo ago), licensed MIT. It adds 152 tokens to every session and 4,214 once invoked, about $0.0008 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

session-wrap

Use when wrapping up a session before ending. 4 parallel subagents detect doc updates, repeated patterns, learning points, and follow-ups, then a verifier deduplicates and presents choices. Triggers on /session-wrap, session wrap, session cleanup, end of session.

sangrokjung/claude-forge · 58 tokens

skill-factory

A workflow that examines completed session work and turns reusable patterns into Claude Code skills.

sangrokjung/claude-forge · 122 tokens

relay

Session relay — compresses what's been done so far (writes a one-liner for /compact) and generates a "next task" prompt (a baton) for the user to hand off. Use on requests like "relay / hand off / next session / continue after compact / baton / handoff / clean up context and continue next task." Does not run /compact…

sangrokjung/claude-forge · 97 tokens

strategic-compact

Suggests manual context compaction at logical intervals to preserve context through task phases rather than arbitrary auto-compaction.

sangrokjung/claude-forge · 27 tokens

rotation-check

Standard-Gerüst für rotierende Pipeline-Checks: Pro Lauf genau ein Ziel aus einer Menge (Projekte, Ordner, Repos) wählen — bevorzugt das am längsten ungeprüfte —, den Check durchführen, Ergebnis in einer Check-Registry und einem Verlaufslog festhalten. Nutze diesen Skill, wenn ein wiederkehrender Check über viele…

ellmos-ai/skills · 148 tokens

progress-channel

One visible channel for every long-running process — local sweeps, backgrounded commands, and work handed to external systems (a CI run, a media-server queue, a long download). The server that serves the live progress page IS the tracker — a stdlib Python daemon holding live jobs in memory, auto-spawned by the first…

alexmond/alexmskills · 149 tokens