Skip to main content
skill CX Codex

optimize · localixai — Claude Code skill: what it does, how to install

optimize is a Claude Code skill that analyzes token usage metrics and proposes configuration changes to cut context waste. It runs when tuning session consumption and context limits.

MIT ★ 171 updated 2026-11-17

Install into Claude Code · Plugin marketplace All methods and platforms ↓
/plugin marketplace add localixai/tokendoctor
/plugin install tokendoctor@tokendoctor
Open on GitHub

What optimize does

The skill gathers session context, rate limits, and audit findings through mcp__tokendoctor__metrics and tokendoctor-sessions. It verifies setting details against official docs on code.claude.com and presents up to five changes ranked by potential savings. Each proposal includes metrics evidence, trade-offs, and whether it applies immediately or next session.

Applying options relies on config_set for live values or set_setting with configuration backups. It can lower autoCompactWindow for earlier compaction or enable tokendoctor.slide to replace tool outputs with pointers. It depends on tokendoctor MCP tools and never touches hooks or permissions outside its settings list.

What it helps with

  • identify context categories consuming the most tokens
  • tune the context compaction threshold via autoCompactWindow
  • activate tokendoctor.slide to preserve tool history without summaries
  • apply verified configuration changes to Claude Code

Example prompts for the agent

  • Check token metrics from the last 30 days and propose settings
  • Tune context usage with focus on autoCompactWindow
  • Optimize token consumption and review compaction settings

How to install optimize

1Plugin marketplace

/plugin marketplace add localixai/tokendoctor
/plugin install tokendoctor@tokendoctor

This installs the whole tokendoctor plugin with all its skills

2Skills CLI (Vercel)

npx skills add localixai/tokendoctor --skill optimize -a claude-code

3Manually: put the files in place

~/.claude/skills/optimize/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/optimize/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about optimize

How to install optimize in Claude Code?

In Claude Code, run /plugin marketplace add localixai/tokendoctor, followed by /plugin install tokendoctor@tokendoctor.

What does optimize do?

It audits token usage metrics, checks Claude Code documentation for valid settings, and proposes up to five changes to minimize context consumption after your approval.

What is required to run optimize?

It requires the tokendoctor MCP tools (metrics, settings, config_list, config_set, set_setting) and CLI utilities tokendoctor-sessions and tokendoctor-audit.

Source text

SKILL.md · MIT
---
name: optimize
description: Look at token metrics, propose setting changes that cut waste, and apply the ones the person approves.
disable-model-invocation: true
allowed-tools: mcp__tokendoctor__metrics, mcp__tokendoctor__settings, mcp__tokendoctor__config_list, Bash(tokendoctor-sessions *), Bash(tokendoctor-audit *), WebFetch(domain:code.claude.com)
argument-hint: [focus]
---

Tune this Claude Code setup for token use. Focus on `$ARGUMENTS` if given.

Before recommending a setting you are not sure of, read its page in Claude Code's current docs:
every page is Markdown at `https://code.claude.com/docs/en/<page>.md` (index:
`https://code.claude.com/docs/llms.txt`; settings in `settings-reference.md`, variables in
`env-vars.md`, costs in `costs.md`, caching in `prompt-caching.md`). The release changes often, so
prefer that to memory or a mirror.

The tokendoctor tools wait behind ToolSearch: load `mcp__tokendoctor__metrics`,
`mcp__tokendoctor__settings`, `mcp__tokendoctor__config_list`, `mcp__tokendoctor__config_set` and
`mcp__tokendoctor__set_setting` in one ToolSearch call first.

1. **Measure.** Call `metrics` (session context, rate limits, cost, the largest context categories,
   daily totals, audit findings). For the longer view run `tokendoctor-sessions --json --days 30`.
2. **See what can change.** Call `settings` (every setting tokendoctor may change, set or not, with
   its current value and whether a change applies live) and `config_list` (the /config rows).
3. **Propose.** Pick at most five changes, largest saving first. For each give: the setting, the
   current and new value, the evidence from step 1 in one sentence, the trade-off, and whether it
   applies now or at the next session. Costs are dollars at API list prices, which on a plan are not
   what the plan's limits count: speak in shares first. Do not propose a change the numbers do not support.
   **The window.** `autoCompactWindow` sets where Claude Code compacts (for example 400000 on a 1M
   model). Propose a smaller one when much of the cost is spent with a large context (the
   `late-compaction` finding, a high `compactAt`): every request re-reads the whole context, so a
   smaller window is a direct saving, at the price of compacting more often.
   **The slide.** `tokendoctor.slide: true` makes those compactions elide old tool outputs into
   short pointers instead of summarizing: no summary pause, and every prompt, answer and decision stays
   word for word. It is not a saving: measured on 60-file runs it costs the same as a summary (within
   2% on Haiku 5.5 and Sonnet 5.5), and a recall test found no detail the summary lost. Offer it only
   as a separate choice, to someone who says summaries lose what they need, and say that a model may
   now and then read an elided file again. If the audit has `slide-blocked-by-guard`, the slide will
   not run on this login until `tokendoctor-org-install` is run (one `sudo` command): say so before
   turning it on.
   **How tools are used.** The `usage` part of `tokendoctor-sessions --json` shows which tools fill
   the context, Bash calls that only printed a file, the files read most and how large subagent runs
   grow. Judge from it yourself. `bashOutputMaxChars` caps one Bash output; with the slide on, a
   file printed through Bash that was read or changed again later is the first thing dropped. What a setting cannot fix (how subagents are briefed and sized, what they report back),
   propose as a few lines for the project's memory or CLAUDE.md and show them; the person writes
   them, or asks you to. Leave
   `tokendoctor.slideTo` at its default (25) unless the person asks: a higher one slides more often,
   and every slide re-sends the context once.
4. **Ask.** Use AskUserQuestion (multiSelect) to let the person pick which changes to apply.
5. **Apply** each picked change with `config_set` (a /config row, live) or `set_setting` (a settings
   file, with a backup). Each call asks the person again; a refusal is final for that change.
6. **Report** what changed, what needs a new session (`model`, `effortLevel` and every `env.*`
   value), and suggest running `tokendoctor-sessions --by day` in a few days to compare. Say that
   `/tokendoctor` shows these settings and `/tokendoctor <name> <value>` changes one with no model call.

Never change hooks, permissions or anything outside the `settings` list. Never write files with
other tools.

© rsaryev · MIT · localixai/tokendoctor

Similar skills

All skills for Agent setup: memory, context, orchestration →

optimize by other authors comes first.

optimize marketcalls optimize generates Python parameter grid search scripts for VectorBT strategies, plots Plotly heatmaps, and benchmarks returns against NIFTY. CX Codex +1 2,500installs optimize aladicf optimize — a skill that tracks down why an interface feels slow: load time, janky animations, heavy images, bloated bundles. It kicks in when you say something lags. CX Codex +1 608installs please-optimize-my-claude thedoublejay please-optimize-my-claude walks your whole CLAUDE.md hierarchy, flags duplicates and misplaced rules, and shows token cost per file. ★ 16repo stars learn-codebase thedotmack learn-codebase — a skill for Claude Code, Codex, Cursor and other AI coding platforms that reads every source file in the project from start to finish. Runs when the user asks to learn, read or prime the codebase. CX Codex +1 5,800installs ctx-stats mksglu ctx-stats — a Claude Code skill that reports how much context context-mode saved. It runs a single tool and prints the result with aligned columns. CX Codex +1 1,900installs caveman Shawnchee caveman enables an ultra-terse mode that strips pleasantries, narrations, and filler words to save context tokens on every request. CX Codex +1 1,100installs context-optimization muratcankoylan context-optimization extends useful context capacity through observation masking, KV-cache reuse, compaction, and task partitioning across sub-agents. CX Codex +1 532installs context-compressor oimiragieo context-compressor compresses large text files, chat histories, and RAG payloads before sending to the model while preserving evidence for correct answers. Reduces token spend when context balloons. CX Codex +1 274installs

From the same set6

Project sponsors

Companies that keep this analytics open