frugal

A cost-optimised agent router for Claude Code. Frugal teaches the main loop to send every sub-task to the cheapest execution strategy that can succeed, and to escalate only on verified failure:
deterministic tool → haiku worker → sonnet worker → main model → fable (escalation ceiling)
The expensive reasoning model plans and judges; commodity work (locating files, extracting data, mechanical edits) runs on cheap tiers. No framework, no runtime, no API keys: frugal is a plugin made of a routing skill, five agent definitions, and two small hooks. The harness does the rest.
Install
/plugin marketplace add ThomasLangbroek/frugal
/plugin install frugal@frugal-marketplace
How it works
The main model already reads every request, so it acts as the router at zero marginal cost. The routing skill gives it one decision table:
| Task | Agent | Model |
|---|
| locate, grep, map structure, find usages | scout | Haiku |
| extract, classify, summarise one source | extractor | Haiku |
| mechanical edits from a complete spec | mechanic | Sonnet |
| implement one scoped task from an approved plan | builder | Sonnet |
| design, debugging, ambiguity, risk | main loop | whatever you run |
| beyond the main loop's tier, or isolated deep reviews | sage | Fable |
Plus a tool-first rule: if grep, jq, git, terraform or any deterministic command solves the task, no model is called at all.
Escalation (verification first)
Workers do not self-grade their way up the ladder. Every worker ends with a fixed footer:
RESULT: <one line>
CHECKS-RUN: <commands run and outcomes, or "none">
UNCERTAINTIES: <or "none">
ESCALATE: yes|no - <reason>
The router then applies four rules:
- If a deterministic check exists (tests, compiler, schema validation,
terraform validate), run it. Pass = done. Fail = escalate one tier, maximum one retry, then the main loop takes over.
- No check available: the main model spot-reads the result. It receives it anyway, so judging it costs almost nothing.
- The worker's
ESCALATE: yes is advisory input, never the sole trigger. Self-reported confidence from a cheap model is poorly calibrated; observable failure is not.
- Never start at an expensive tier unless the decision table requires it.
sage (Fable) is reached only via high-risk table rows or after escalation exhausts, one attempt, final.
Metrics and the cost report
A SubagentStop hook logs one jsonl line per worker run (agent, model, token usage) to ~/.claude/frugal/metrics.jsonl. Run:
/frugal:router-stats
to get cost per tier and estimated savings versus running the same work on your session's actual main-loop model (recorded per run; older records without it are compared against the top tier). Prices live in scripts/stats.py (PRICES, plus CACHE_READ for models that discount cache reads below 0.1x input); update them when Anthropic pricing changes. python3 scripts/stats.py --days 30 limits the report to recent runs, and a long agent table folds agents with fewer than three runs into one other row per model. The per-session table also shows what the main loop itself spent and the delegated share of the session's bill, so you can see whether routing moves the real total and not only the worker slice. Model ids whose price was never checked are flagged as unverified in the report and at session start, because a new generation otherwise inherits its predecessor's rate silently; VERIFIED in scripts/stats.py is that list. The report also prints a delegation floor per agent: a spawn costs roughly the same whether the task is trivial or large, so the report divides your measured net cost per spawn by your main-loop input rate to say how much reading a delegation has to save before it pays for itself. Under that, do it inline. Learning is deliberately offline: read the report, edit the decision table.
Enforcement
Routing policy in a skill is advisory: the model follows it well, but a prompt cannot forcibly prevent anything. Frugal therefore enforces on four levels, three active out of the box and the fourth as soon as you set a budget: