Right Size
Picks the model and effort for each prompt, and keeps your cache warm in long chats.
claude plugin validate to auditGuide →Writes files, executes local shell processes, or programmatically drives Claude.
Statically scanned from hooks & source. Learn how to audit
⚖️ right-size
The right model and the right effort for every prompt. Automatically.
Easy questions stop burning Opus at max effort. Hard problems still get the heavy hitter.
sonnet · medium
That's the whole interface.
✨ What it does
Before each turn, a quick Haiku call reads your prompt and picks a model and an effort level. A cache guard then checks whether switching models is worth it: in a big chat with a hot cache, it keeps the current model and changes effort only. The result applies to every model request in that turn, and one status line under the prompt tells you what ran.
No panels. No bars. No settings screens.
🔀 How it works
flowchart LR
A[Your prompt] --> B{Haiku judge}
B --> G{Cache guard}
G -->|"small chat or cold cache"| S[Switch to the pick]
G -->|"big chat, hot cache"| K[Keep the model,<br/>change effort]
S & K --> F[Status line shows<br/>what actually ran]
| You type | right-size picks |
|---|---|
"rename x to y in this file" | 🟢 haiku |
| "fix the failing test" | 🟡 sonnet · medium |
| "redesign the auth flow" | 🔴 opus · high |
📏 Rules
| 💬 Short replies keep the last pick | "ok", "go", "yes" and friends skip the judge call. |
| ⌨️ Slash commands pass through | Commands and hidden prompts are never judged. |
| 🤖 Subagents are left alone | Only your main conversation is routed. |
| 🛟 Safe fallback | If the judge fails or rambles, your session's own model and effort run, and the status line says so. |
| 🧊 Cache guard | In a big chat whose cache is still hot, the model stays put and only effort changes. See below. |
🔍 Trust, but verify
The status line comes from the API's own usage data, not from what the mod asked for. If the engine didn't honor the request, you'll know:
sonnet · medium (ran claude-opus-5-5)
[!NOTE]
/modelkeeps showing your session's model. right-size changes each request, not that setting. And asking Claude "which model are you?" won't tell you either: the system prompt names the session's model.
📦 Install
In Claude Code, at the prompt of a terminal session:
/plugin install right-size --marketplace RyunPey/right-size
Answer y to add the marketplace, then pick a scope (user is the first choice and applies to all your sessions). The mod is active right away, no restart needed.
From a shell:
claude plugin install right-size --marketplace RyunPey/right-size
In the desktop app, where /plugin doesn't run: click + next to the prompt box, then Plugins, Add marketplace with RyunPey/right-size, then Add plugin. A mod installed from a terminal at the user scope also loads in the desktop app's local sessions.
🧑💻 Working on right-size itself
Install from your local clone instead. Claude Code then reads the mod straight from the folder:
claude plugin marketplace add <path to your clone>
claude plugin install right-size@right-size --scope user
Edits take effect after /reload-plugins, with no reinstall.
🎛️ Tuning
Settings
Three settings in the plugin's config menu (/config):
| Setting | Default | What it controls |
|---|---|---|
mode | model-and-effort | Whether right-size picks the model as well as the effort. See below. |
cacheTtlMinutes | 60 | How long a model's cache counts as hot after its last request. 60 suits Claude Code subscriptions; set 5 if your account uses the API's default cache. |
smallContextTokens | 40000 | Below this context size, switching models is always allowed. |
Mode
| Value | What it does |
|---|---|
model-and-effort (default) | Picks model and effort per prompt; the cache guard decides when a switch is worth it. |
effort-only | Keeps your session's model on every turn and changes only the effort. The prompt cache is never lost. |
Change it from any surface, the desktop app included, with /right-size-mode effort-only or /right-size-mode model-and-effort. With no value, /right-size-mode shows the current mode. A change counts from the next turn.
Constants
Everything else lives in hooks/register.ts:
| Constant | What it controls |
|---|---|
SYSTEM | The judge's instructions. Edit it to change how eagerly it picks bigger models. |
IDS | Which model id each pick maps to. |
FOLLOW_UP | The pattern for replies that skip the judge. |
CACHE_TTL_MINUTES, SMALL_CONTEXT_TOKENS | The defaults for the two settings above. |
🧊 The cache guard
Each model keeps its own prompt cache. Switching models means the new one re-reads the whole chat at full price, which in a long chat costs more than the cheaper model saves.
So before each turn, right-size checks two things:
| Chat size | Current model's cache | Result |
|---|---|---|
| small | any | 🔀 switch to the pick |
| big | cold | 🔀 switch to the pick: re-reading is due anyway |
| big | hot | 📌 stay on the current model, change effort only |
The model is decided once per turn, so tool calls inside a turn never switch. When the guard holds, the status line says so:
opus · low (kept: cache hot)
Chat size comes from the session's live context figures. Before the first reply of a session (or right after compaction), the size is unknown and counts as small. /clear and compaction also forget which model's cache was hot, since neither cache holds the new chat; /clear forgets the last pick too, so a short reply after it is judged afresh.
💸 Costs
Each prompt makes one small Haiku call (low effort, 16 output tokens max, 5-second limit). The cache guard keeps model switches to the moments where they're cheap.
🛠️ Development
claude plugin validate .
claude plugin test .
The tests cover the pick, the cache guard (hot, cold, small chat, /clear, compaction), the settings, follow-ups, pass-through prompts and the judge-failure fallbacks with mocked events. They don't exercise a live session.
📊 Benchmark
bench/ runs real headless sessions, with right-size on (loaded from this folder) and off (your baseline, Opus · high by default), and compares cost, time and correctness. It needs Python 3.10+ and spends real money: about $4 for the default run.
python bench/bench.py selftest # every check accepts a known-good answer
python bench/bench.py run --max-cost 8 # all cases, 2 reps, both arms
python bench/bench.py run --tag sneaky --reps 3 # just a subset
python bench/bench.py report bench/results/<file>.jsonl
Each session gets a unique line in its system prompt, so sessions never share a prompt cache and one arm can't run cheaper because the other just sent the same prompt. Pass --shared-cache to turn that off for a cheaper, rougher run.
Every answer is checked automatically: code runs against tests, and other answers are matched against known results. The report shows which model answered each turn, the pick and effort from the status line, whether routing landed under, at or over the expected tier, and what the cache guard did in the multi-turn cases. Cases live in bench/cases.py. The judge's own Haiku call isn't in the reported cost; it's roughly $0.0003 a prompt.
Cases tagged followup have a second turn that only makes sense after the first ("now the same thing the other way round"), so they test whether the judge reads the conversation.
A case's tier is the smallest model expected to answer it. To check that a case still earns its tier, run it with right-size off on a smaller model:
python bench/bench.py run --arms off --baseline-model haiku --baseline-effort low --tag opus
[!NOTE] Most cases labelled Opus are passed by Sonnet and Haiku too. So far only
rangesum(and the same task as the first turn offollowup-max) has failed below Opus, on Sonnet · medium about half the time, so correctness shows little about when routing down hurts. More cases that only Opus solves would sharpen that.
Details
- Author
- @RyunPey
- Sub-category
- Context & Memory
- License
- MIT
- Added
- 1 months ago
- Last synced
- today
Weekly Mods Digest
Top new Claude Code mods and install commands, once a week. No fluff, unsubscribe anytime.
