ClaudeMod
ModsContext & MemoryWrites / Shell

Right Size

Picks the model and effort for each prompt, and keeps your cache warm in long chats.

Install
$claude plugin marketplace add RyunPey/right-size
$claude plugin install right-size@right-size
Run claude plugin validate to auditGuide →
Access & PermissionsWrites / Shell

Writes files, executes local shell processes, or programmatically drives Claude.

Draws UICalls AI models

Statically scanned from hooks & source. Learn how to audit

RyunPeyAdded 1 months ago

⚖️ 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.

Claude Code Judge UI

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 typeright-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 throughCommands and hidden prompts are never judged.
🤖 Subagents are left aloneOnly your main conversation is routed.
🛟 Safe fallbackIf the judge fails or rambles, your session's own model and effort run, and the status line says so.
🧊 Cache guardIn 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] /model keeps 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):

SettingDefaultWhat it controls
modemodel-and-effortWhether right-size picks the model as well as the effort. See below.
cacheTtlMinutes60How 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.
smallContextTokens40000Below this context size, switching models is always allowed.

Mode

ValueWhat it does
model-and-effort (default)Picks model and effort per prompt; the cache guard decides when a switch is worth it.
effort-onlyKeeps 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:

ConstantWhat it controls
SYSTEMThe judge's instructions. Edit it to change how eagerly it picks bigger models.
IDSWhich model id each pick maps to.
FOLLOW_UPThe pattern for replies that skip the judge.
CACHE_TTL_MINUTES, SMALL_CONTEXT_TOKENSThe 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 sizeCurrent model's cacheResult
smallany🔀 switch to the pick
bigcold🔀 switch to the pick: re-reading is due anyway
bighot📌 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 of followup-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.


MIT licensed, see LICENSE.
Built as a calmer take on effortless.

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.

More Mods

Claude Flightdeck
ModsSecurity

Claude Flightdeck

Live agent dashboard pane with context consumption, advisor timeline, permission verdicts, and subagent swimlanes.

Reads Files
by Sam Casella
GitHub
ModsInterface

Terminal Browser

Browse documentation, GitHub pull requests, and web pages in a split terminal pane directly beside your Claude Code conversation.

Network
by Zenbu Labs
GitHub
Agent Flow
ModsAutomation

Agent Flow

Interactive visual tree of the active session's subagents, background tasks, and teammates beside the transcript via /flow.

UI Only
by Charlie
GitHub

Command Palette

Search for a command to run...