frugal

A personal fork of ThomasLangbroek/frugal, customised for my own use. Upstream is MIT-licensed; see LICENSE.
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 → sonnet worker → opus 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 jjacobl1/frugalclaude
/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 | Sonnet |
| extract, classify, summarise one source | extractor | Sonnet |
| mechanical edits from a complete spec | mechanic | Opus |
| implement one scoped task from an approved plan | builder | Opus |
| design, debugging, ambiguity, risk | main loop | whatever you run |
| beyond the main loop's tier, or isolated deep reviews | sage | Fable |
This fork runs one tier above upstream's defaults (upstream: Haiku scouts, Sonnet builders). That trades saving for first-pass reliability — see Tier choice.
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, escalation flag) to ~/.claude/frugal/metrics.jsonl. Run:
/frugal:router-stats
to get cost per tier, escalation rate, 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); update them when Anthropic pricing changes. 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: