Sprag is named after the sprag clutch: forward motion passes, backspin locks. Your agent keeps working — it just stops regressing. It reads the sessions you already ran and turns them into compounding gains — every repeated failure becomes a rule loaded at session start, work a cheaper tier has proven it can do is delegated there with a per-run savings ledger as the receipt, and cache or rate-limit trouble reaches your statusline while you can still act.
$ npm i -g sprag-cli
How it works
$ sprag harness check 🅷 harness 5/5 ✓ ratchet 47 rules loaded (12 project, 35 global) ✓ evidence last 20 completions carried proof ✓ plan-verify verify step present in 18/20 ✓ structured 4-line task frame in use ✓ safe-path 3 destructive commands confirmed ⚠ ratchet candidate — second occurrence detected session 203 · npm publish failed with E401 session 211 · npm publish failed with E401 promote it: $ sprag ratchet promote \ "npm publish E401 → check .npmrc NPM_TOKEN is exported" --global
$ sprag route-scan --days 30 scanned 214 sessions · 1,842 requests tier share tasks spent if all top haiku 52% ████████████░░░░░░░░░░░ 961 $3.84 $100.90 sonnet 33% ████████░░░░░░░░░░░░░░░ 608 $12.77 $63.84 main agent 15% ███░░░░░░░░░░░░░░░░░░░░ 273 $28.67 $28.67 ───────── saved over 30 days $147.33 # a delegation, as it happens $ claude "run the tests and tell me what broke" ↳ matched rule "run the tests" → haiku (41 runs, 0% error) ↳ spawned haiku-runner sub-agent ✓ returned in 8s · 2 failing specs · 1,240 tokens instead of 9,700 ↳ main agent reviewed the output and kept working
# your prompt, every turn 🅷 5/5 🧠 Cache hit 91% ⏳ Cache expires 4m 🚨 5H 94% 💰 Saved $12.40 what each one is telling you 🅷 5/5 all five harness principles held this session 🧠 Cache hit 91% prompt cache is working; 9% of input was re-sent ⏳ expires 4m the 5-minute TTL is about to drop your cache 🚨 5H 94% 94% of the 5-hour cap is gone; back up now 💰 Saved $12.40 what caching and routing kept off the bill $ sprag handoff ✓ wrote .sprag/handoff-2026-09-13.md — open a fresh session with it
$ sprag doc2md ~/decks/q3-review.pptx ✓ .sprag/q3-review.md 41 slides · 18 KB read the conversion instead of attaching the file attached .pptx ~96,000 tokens converted .md ~4,900 tokens also handles .xlsx .pdf .docx .fig
Real output. Nothing here is a mockup of a feature that does not ship.
Sprag installs once, reads the sessions you already run, and does not ask you to change how you prompt.
The first failure is just work. On the second, Sprag surfaces it as a candidate. You approve the scope, and the rule loads at the start of every session after that.
2026-08-01 · appending to .env → check the trailing newline first (tail -c1)
When a task matches one your history shows is safe, Sprag spawns a sub-agent on a cheaper tier to do it and hands the result back for review. Anything that fails quietly stays with the main agent.
"git status" → haiku-runner "build the app" → sonnet-worker "why is CI flaky?" → main agent
Cache hit rate, TTL expiry, context growth and both rate-limit windows are read every turn and printed in your statusline, while you can still act on them.
⚠ Cache miss · input spike 🚨 7D 92% · run handoff
Sprag does not swap your model. It reads what you have already run, finds the kinds of task that never went wrong on a cheaper tier, and spawns a sub-agent for exactly those. The sub-agent returns its output to the main agent, which reviews it before anything counts as done. Every rule carries the error rate it was measured at, and the work comes straight back to the main agent the moment a rule stops holding.
| Tier | Share | Goes there | Why it is safe |
|---|---|---|---|
| haiku | 52% | lookups · status checks · test and lint runshaiku-runner sub-agent | Exit codes and diffs make a wrong answer obvious0% error over 41 delegated runs |
| sonnet | 33% | builds · mid-size refactors · mechanical portssonnet-worker sub-agent | The build and the test suite verify the resultthe main model reviews the diff before it counts as done |
| main agent | 15% | diagnosis · design · security · anything irreversiblenever delegated | Nothing catches a wrong call here except younever delegated, however routine it looks |
These ship inside the generated ratchet-model.md, above the rules, so the agent applies them to every delegation. The percentages are measured, not assumed.
A lookup answered by the repo, a file, or command output is safe on haiku. A question answered from model knowledge is not — measured recall: 28% on the cheap tier vs 54% one tier up.
If the build, the tests, or an exit code will catch a wrong answer, the gate sets the quality floor and a cheap tier is safe. Work that fails silently — diagnosis, root-cause calls, security, design — never goes down a tier.
A flow that feeds one tool's output into the next call never goes to haiku, whatever the call count — the accuracy gap on chained tool work measured +63pp, the largest of any task type.
The dominant cost of a sub-agent is loading context, not generating. Tasks that read the same files ride in one agent; only tasks that read different ground get their own.
The main model fixes the design and writes a self-contained spec; a sonnet worker writes the bulk of the code. The main model reviews the diff and the test results before anything is reported done.
The same error twice, an answer splitting into candidates, or a sub-agent circling — each hands the work back: re-brief and retry, then one tier up, then the main model takes over.
Measured offline on LLMRouterBench (Findings of ACL 2026): 11,696 instances across 9 datasets. The tool-chain gap is from τ²-Bench, knowledge recall from SimpleQA-class sets. Method and holdout in docs/BENCHMARK.md.
$ sprag harness promote
+ rule 2026-09-13: npm 401 → check NPM_TOKEN first
✓ loads at the start of every sessionRepeated failures become one-line rules loaded every session. Candidates are detected from your logs; you choose project or global scope.
# ratchet-model.md
"run the tests" → haiku
×41 runs · 0% err · saved $3.05Log-driven delegation rules with measured error rates and reported savings, written to ratchet-model.md.
🅷 5/5 ▰▰▰▰▰
ratchet · evidence · plan-verify
structured · safe-pathFive operating principles checked live. Skip the verify step and 🅷 4/5 says so before you report done.
🧠 91% ⏳ 4m 🚨 5H 94%
cache ▰▰▰▰▰▰▰▰▰▱ · ctx 118k
💵 Sep $42 · 🔑 34% $34/$100Cache hit rate, TTL, context size, output spikes and both rate-limit windows, in the prompt every turn.
q3-review.pptx 30MB
540,429 tok → 22,610 tok
✓ −95.8% before the model reads itpptx, xlsx, pdf, docx and fig converted on demand, so a document costs a read instead of a context bomb.
✗ 보여집니다 (이중 피동)
✓ 보입니다
blocked at write time, by hookWrite-time prose lint enforced by hook. Shipping today for Korean technical writing: double passives, translationese, cohesion.
Yes. Sprag is the new name; the npm package is sprag-cli, and the claude-token-saver package keeps receiving the same releases so nothing breaks.
No. Everything is post-hoc analysis of the session logs Claude Code already writes on your machine. No extra model calls, no key, no telemetry leaves your computer.
No. It installs hooks and a statusline once, then works from what you already do. Rules, delegation, and warnings show up inside your normal sessions.
Each delegated run writes a ledger entry with the actual price difference. The tier criteria behind the routing are benchmarked on public data; the method is in docs/BENCHMARK.md.
$ npm i -g sprag-cli
Star on GitHub