ClaudeCodeMod

All shelves / Mods / Usage

token-optimizer

By alexgreensh

token-optimizer is a Claude Code usage mod by alexgreensh.

Draws a status bar above the prompt in the desktop app: session quality, context fill, a cache countdown, and the 5-hour and weekly limits, with buttons to clean up, start fresh, or keep the cache warm.

Draws

Install

The marketplace name is alexgreensh-token-optimizer.

In Claude Code
/plugin marketplace add alexgreensh/token-optimizer
/plugin install token-optimizer@alexgreensh-token-optimizer
Open the repo

It runs inside the Claude Code process. The side panel is only what the author's README names. Read the repo before you install, or run claude plugin validate on the plugin folder.

Version
5.13.46
Repo stars
2573
Last change
2026-10-15

What it can reach

  • Draws in the session
  • Reads usage or context figures
  • Runs a command when you press
  • Calls another program on this machine

Claude Code 2.1.287 or newer. The bar draws in the Claude desktop app; the author says the terminal keeps its existing status line and VS Code is not supported. Keep warm is a one-click refresh that uses a small amount of usage, never automatic. TOKEN_OPTIMIZER_STATUS_BAR=0 hides the bar.

The bar ships inside the larger Token Optimizer plugin, which also adds skills, hooks, and a per-session database under ~/.claude/token-optimizer/.

Demo

From the author's repo.

What it hooks into

  • session.startWhen a session starts
  • classic.SessionStartA Claude Code event
  • prompt.submitWhen you send a prompt
  • classic.UserPromptSubmitA Claude Code event
  • classic.StopA Claude Code event
  • turn.startWhen Claude starts a turn
  • turn.stepAt each step of a turn
  • tool.callAround a tool call, where it can hold one
  • agent.spawnWhen a subagent starts
  • classic.PermissionRequestA Claude Code event
  • session.compactWhen the context is compacted
  • turn.completeWhen a turn ends
  • ui.renderDraws into the sessionAbovePrompt

Read from the on() calls in its hook modules. Open its source under Files to check what each one does.

Hooks 16

  • PreToolUse · Readfor b in bash /bin/bash /usr/bin/bash /usr/local/bin/bash /opt/homebrew/bin/bash; do command -v "$b" >/dev/null 2>&1 || continue; L="${CLAUDE_PLUGIN_ROOT}/hooks/python-launcher.sh"; [ -r "$L" ] || exit 0; exec "$b" "$L" "${CLAUDE_PLUGIN_ROOT}/hooks/run.py" skills/token-optimizer/scripts/read_cache.py --quiet; done; exit 0
  • PreToolUse · Bashfor b in bash /bin/bash /usr/bin/bash /usr/local/bin/bash /opt/homebrew/bin/bash; do command -v "$b" >/dev/null 2>&1 || continue; L="${CLAUDE_PLUGIN_ROOT}/hooks/python-launcher.sh"; [ -r "$L" ] || exit 0; exec "$b" "$L" "${CLAUDE_PLUGIN_ROOT}/hooks/run.py" skills/token-optimizer/scripts/bash_hook.py --quiet; done; exit 0
  • PreToolUse · Agent|Taskfor b in bash /bin/bash /usr/bin/bash /usr/local/bin/bash /opt/homebrew/bin/bash; do command -v "$b" >/dev/null 2>&1 || continue; L="${CLAUDE_PLUGIN_ROOT}/hooks/python-launcher.sh"; [ -r "$L" ] || exit 0; exec "$b" "$L" "${CLAUDE_PLUGIN_ROOT}/hooks/run.py" skills/token-optimizer/scripts/measure.py checkpoint-trigger --milestone pre-fanout --quiet; done; exit 0
  • PreToolUse · mcp__.*for b in bash /bin/bash /usr/bin/bash /usr/local/bin/bash /opt/homebrew/bin/bash; do command -v "$b" >/dev/null 2>&1 || continue; L="${CLAUDE_PLUGIN_ROOT}/hooks/python-launcher.sh"; [ -r "$L" ] || exit 0; exec "$b" "$L" "${CLAUDE_PLUGIN_ROOT}/hooks/run.py" skills/token-optimizer/scripts/refetch_guard.py --quiet; done; exit 0
  • PreCompactfor b in bash /bin/bash /usr/bin/bash /usr/local/bin/bash /opt/homebrew/bin/bash; do command -v "$b" >/dev/null 2>&1 || continue; L="${CLAUDE_PLUGIN_ROOT}/hooks/python-launcher.sh"; [ -r "$L" ] || exit 0; exec "$b" "$L" "${CLAUDE_PLUGIN_ROOT}/hooks/run.py" skills/token-optimizer/scripts/measure.py dynamic-compact-instructions --quiet; done; exit 0
  • PreCompactfor b in bash /bin/bash /usr/bin/bash /usr/local/bin/bash /opt/homebrew/bin/bash; do command -v "$b" >/dev/null 2>&1 || continue; L="${CLAUDE_PLUGIN_ROOT}/hooks/python-launcher.sh"; [ -r "$L" ] || exit 0; exec "$b" "$L" "${CLAUDE_PLUGIN_ROOT}/hooks/run.py" skills/token-optimizer/scripts/measure.py compact-capture --trigger auto --quiet; done; exit 0
  • PreCompactfor b in bash /bin/bash /usr/bin/bash /usr/local/bin/bash /opt/homebrew/bin/bash; do command -v "$b" >/dev/null 2>&1 || continue; L="${CLAUDE_PLUGIN_ROOT}/hooks/python-launcher.sh"; [ -r "$L" ] || exit 0; exec "$b" "$L" "${CLAUDE_PLUGIN_ROOT}/hooks/run.py" skills/token-optimizer/scripts/read_cache.py --clear --quiet; done; exit 0
  • SessionStartfor b in bash /bin/bash /usr/bin/bash /usr/local/bin/bash /opt/homebrew/bin/bash; do command -v "$b" >/dev/null 2>&1 || continue; L="${CLAUDE_PLUGIN_ROOT}/hooks/python-launcher.sh"; [ -r "$L" ] || exit 0; exec "$b" "$L" "${CLAUDE_PLUGIN_ROOT}/hooks/run.py" hooks/sessionstart_runner.py; done; exit 0
  • Stopfor b in bash /bin/bash /usr/bin/bash /usr/local/bin/bash /opt/homebrew/bin/bash; do command -v "$b" >/dev/null 2>&1 || continue; L="${CLAUDE_PLUGIN_ROOT}/hooks/python-launcher.sh"; [ -r "$L" ] || exit 0; exec "$b" "$L" "${CLAUDE_PLUGIN_ROOT}/hooks/run.py" hooks/stop_runner.py; done; exit 0
  • SessionEndfor b in bash /bin/bash /usr/bin/bash /usr/local/bin/bash /opt/homebrew/bin/bash; do command -v "$b" >/dev/null 2>&1 || continue; L="${CLAUDE_PLUGIN_ROOT}/hooks/python-launcher.sh"; [ -r "$L" ] || exit 0; exec "$b" "$L" "${CLAUDE_PLUGIN_ROOT}/hooks/run.py" hooks/stop_runner.py; done; exit 0
  • StopFailurefor b in bash /bin/bash /usr/bin/bash /usr/local/bin/bash /opt/homebrew/bin/bash; do command -v "$b" >/dev/null 2>&1 || continue; L="${CLAUDE_PLUGIN_ROOT}/hooks/python-launcher.sh"; [ -r "$L" ] || exit 0; exec "$b" "$L" "${CLAUDE_PLUGIN_ROOT}/hooks/run.py" skills/token-optimizer/scripts/measure.py compact-capture --trigger stop-failure --quiet; done; exit 0
  • UserPromptSubmitfor b in bash /bin/bash /usr/bin/bash /usr/local/bin/bash /opt/homebrew/bin/bash; do command -v "$b" >/dev/null 2>&1 || continue; L="${CLAUDE_PLUGIN_ROOT}/hooks/python-launcher.sh"; [ -r "$L" ] || exit 0; exec "$b" "$L" "${CLAUDE_PLUGIN_ROOT}/hooks/run.py" hooks/userpromptsubmit_runner.py; done; exit 0
  • PostToolUse · Bash|PowerShell|Read|Glob|Grep|Agent|Edit|Write|MultiEdit|NotebookEdit|mcp__.*for b in bash /bin/bash /usr/bin/bash /usr/local/bin/bash /opt/homebrew/bin/bash; do command -v "$b" >/dev/null 2>&1 || continue; L="${CLAUDE_PLUGIN_ROOT}/hooks/python-launcher.sh"; [ -r "$L" ] || exit 0; exec "$b" "$L" "${CLAUDE_PLUGIN_ROOT}/hooks/run.py" hooks/posttooluse_runner.py; done; exit 0
  • PostToolUseFailure · Bash|PowerShellfor b in bash /bin/bash /usr/bin/bash /usr/local/bin/bash /opt/homebrew/bin/bash; do command -v "$b" >/dev/null 2>&1 || continue; L="${CLAUDE_PLUGIN_ROOT}/hooks/python-launcher.sh"; [ -r "$L" ] || exit 0; exec "$b" "$L" "${CLAUDE_PLUGIN_ROOT}/hooks/run.py" hooks/posttooluse_runner.py; done; exit 0
  • PostCompactfor b in bash /bin/bash /usr/bin/bash /usr/local/bin/bash /opt/homebrew/bin/bash; do command -v "$b" >/dev/null 2>&1 || continue; L="${CLAUDE_PLUGIN_ROOT}/hooks/python-launcher.sh"; [ -r "$L" ] || exit 0; exec "$b" "$L" "${CLAUDE_PLUGIN_ROOT}/hooks/run.py" skills/token-optimizer/scripts/measure.py quality-cache --force --quiet; done; exit 0
  • CwdChangedfor b in bash /bin/bash /usr/bin/bash /usr/local/bin/bash /opt/homebrew/bin/bash; do command -v "$b" >/dev/null 2>&1 || continue; L="${CLAUDE_PLUGIN_ROOT}/hooks/python-launcher.sh"; [ -r "$L" ] || exit 0; exec "$b" "$L" "${CLAUDE_PLUGIN_ROOT}/hooks/run.py" skills/token-optimizer/scripts/read_cache.py --clear --quiet; done; exit 0

Files

The author's README and source, 5 files. They load when you open them.

Facts

Author
alexgreensh
Category
Usage
Marketplace
alexgreensh-token-optimizer
Repo
alexgreensh/token-optimizer
Version
5.13.46
Repo stars
2573
Last change
2026-10-15
Language
Python
Files
1471

Same repo on other shelves

Skills

  1. 14926token-optimizeralexgreensh/token-optimizer626
  2. 19144token-dashboardalexgreensh/token-optimizer331

Other mods in Usage

context-inspectorYeonwooSungDraws what fills the context window and how much of it is waste: re-reads, near-duplicate output, and what compaction kept, with advice and its evidence.heatmaphamzaferDraws a GitHub-style grid of your Claude Code time in a pane, one square per day, with your streak, peak hours, and top projects.openrouter-balancehamzaferDraws your OpenRouter credit above the prompt: the balance with a gauge, today's spend, and the model the money mostly went to.winnowGhalebDweikatReplaces parts of a large Read, Bash, or Grep result a judge calls unneeded with a stub, a summary, and a key that brings the text back, then toasts.compact-adviserkunchenguidDraws a hint above the prompt to run /compact when Jev calls the session a finished checkpoint, and can run /compact itself if you opt in.fast-jev-compactiontamaratranShows a toast when /compact keeps the messages Jev still wants and drops the rest, instead of replacing the history with a summary.effortlessHeyCubitDraws a bar above the prompt with the reasoning effort it picked for this prompt, how full the chat is, and how long the prompt cache stays warm.headroom-snipheadroomlabs-aiDraws a band above the prompt showing Headroom cutting each request from its original token count to what was sent, with a /headroom log and a running total.leaksdavekissOpens a pane that ranks the avoidable spend in the last 7 days of transcripts, and draws a strip above the prompt when a leak is happening.context-dietdrkokorevReplaces a huge tool output with a short digest and the path of a file that still holds the full text, and /diet opens a panel of what it saved.agent-profilerYeonwooSungDraws where a session's time goes, model wait against tools and subagents, in a status line and a live pane, and can write the session out as an OTLP trace.claude-carbongwittebolleDraws the CO2 of each answer and a pane with a pixel molecule colored against your past sessions, plus this session's total under the prompt.
All 183 in Usage