blendbunjaku/optimaizr/tree/main/mods/optimaizr
optimaizr
一个 Claude Code 插件,在加载动画和提示栏中实时显示每轮成本及 5 小时计划用量,应用来自 `optimaizr live` 的模型/工作量切换,在对话缓存过期前倒计时,提供 `/optimaizr handoff` 笔记,并防止重试循环——全部在本地运行。
关于这个 mod
optimAIzr 将你的会话成本直接显示在 Claude Code 界面中:加载动画显示当前轮次的成本和窗口填充,提示符上方的条带显示计划窗口状态和重置时间,每个回答都会获得一行成本摘要。/optimaizr 打印会话支出和节省以及计划窗口,/optimaizr hud 渲染仪表和迷你图,/optimaizr handoff 让 Claude 写一个简短笔记,以便新对话无需重新阅读旧对话即可开始。它还会在缓存过期前倒计时并发出成本警告,并在两次相同失败后保持命令不变以打破重试循环。在 optimaizr live 中接受的切换(模型或工作量)从下一个请求开始应用于运行中的会话。安装:/plugin marketplace add blendbunjaku/optimaizr 然后 /plugin install optimaizr@optimaizr。需要 Claude Code 2.1.287+。除了通过你自己的会话发出的交接请求外,完全在本地运行。
安装
请先查看作者 README 确认 marketplace 和插件名称;命令可能随仓库结构改变。
claude plugin marketplace add blendbunjaku/optimaizr claude plugin install optimaizr@optimaizr
原文 / README
optimAIzr for Claude Code
A Claude Code mod from optimAIzr.
It puts what your session costs where you work, lets optimaizr live switch
the model or effort of the session you are in, and shows what each switch
saved.
/plugin marketplace add blendbunjaku/optimaizr
/plugin install optimaizr@optimaizr
Needs Claude Code 2.1.287 or later.
What it adds
- The spinner shows what the turn has cost so far and how full your 5-hour
window is:
Thinking · $0.18 · 61% of 5h… - The band above the prompt shows the window, how long it lasts at this
pace and when it resets:
61% of 5h · ~2h 25m left at this pace · resets 01:00 - Each answer gets one line:
optimaizr: this turn $0.18 · 4 requests · 5h 55% → 56% - What a switch saved: a switched turn's line leads with it, e.g.
saved $0.10 vs Opus 5.5 · this turn $0.10 on Sonnet 5.5 · …, and the band keeps a running total. It is the same tokens priced on both models. /optimaizrprints the session's spend, what it saved, both plan windows and any switch./optimaizr hudshows it as gauges and a sparkline.- Switches that pay: subagents switch at once; a long conversation waits until reloading it into the new model pays back, and the band says so.
- Before the cache expires: Claude Code caches the conversation for an
hour. Once it carries 50K tokens or more, the band counts down the last 15
minutes,
cache warm 10m more, then 300K is written again ($2.40), and one toast comes 5 minutes before. After it expires, the band says what the next message will cost. Past 200K, it says what each request re-reads. /optimaizr handoff: Claude writes a three-line note (done, next, the file to start from) while the cache is still warm, so it costs cents./clear, and the next conversation in that project starts from the note instead of re-reading the old one. A note is used once and expires after 12 hours.- A guard against retry loops: when the same command fails twice in a row with nothing changed, the next identical attempt is held once and Claude is asked to change something first.
- Switches. Press Y on a model swap in
optimaizr liveand running sessions in that project use the new model from their next request. A reasoning-effort finding lowers effort the same way. The first switched request leaves a note, and the band names the model. Harder task?/optimaizr offgoes back for this session,/optimaizr onresumes, andoptimaizr undo <rule>takes it back everywhere.
Options
| Option | Default | What it does |
| ------------ | ------- | --------------------------------------------- |
| turnLine | true | The line under each answer with what it cost. |
| retryGuard | true | Hold a command that failed twice unchanged. |
Privacy
It reads the usage figures Claude Code already shows you (cost, token counts,
context fill, plan windows) and the commands Claude runs, kept in memory for
the retry guard. It never reads your prompts or file contents and makes no
network calls of its own. It
reads ~/.optimaizr/overrides.json and writes one small file per session to
~/.optimaizr/mod/sessions, which is how optimaizr live knows it is running.
That file also carries Claude Code's own 5-hour and weekly meters, so
optimaizr profile and optimaizr live can show your real windows.
/optimaizr handoff is the one exception to "no text": only when you run it,
it asks Claude for a note through your own session and saves the reply to
~/.optimaizr/mod/handoffs, one file per project, which the next conversation
there reads once. Nothing leaves your machine besides that one request to Claude.
claude plugin validate on this folder lists every call it makes.
Develop
claude --plugin-dir mods/optimaizr # reloads on save
claude plugin validate mods/optimaizr
claude plugin test mods/optimaizr
The tests were last run on Claude Code 2.1.286, where mods still needed
CLAUDE_CODE_ENABLE_FUNCTION_HOOKS=1. From 2.1.287 they are on by default.

