Sprag
v3.42 on npm as sprag-cli · claude-token-saver still updates

A quality ratchet for your coding agent

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

MIT · one install · works with your existing Claude Code setup

~/projects/app live
$ 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

Real output. Nothing here is a mockup of a feature that does not ship.

59.1%benchmark accuracy · beats every single model in the pool
95.8%fewer tokens per document read through doc2md
18.6%measured per-message cost cut, before vs after the harness
0runtime dependencies · one npm install
How it works

It learns from the sessions you already ran

Sprag installs once, reads the sessions you already run, and does not ask you to change how you prompt.

01

A repeat becomes a rule

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)
02

Safe work goes to a sub-agent

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
03

Cost trouble shows up early

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
Routing

Stop paying flagship prices for work a cheaper tier already proved it can do

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.

TierShareGoes thereWhy it is safe
haiku52% lookups · status checks · test and lint runshaiku-runner sub-agent Exit codes and diffs make a wrong answer obvious0% error over 41 delegated runs
sonnet33% 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 agent15% diagnosis · design · security · anything irreversiblenever delegated Nothing catches a wrong call here except younever delegated, however routine it looks

How a tier gets picked — the criteria every rule shares

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.

01 Where the answer lives

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.

02 Whether a mistake surfaces

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.

03 Tool orchestration

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.

04 Batching

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.

05 Who writes, who decides

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.

06 Escalation

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.

Features

Everything ships in one install, working from day one

$ sprag harness promote + rule 2026-09-13: npm 401 check NPM_TOKEN first ✓ loads at the start of every session

Ratchet rules

Repeated 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.05

Model fitting

Log-driven delegation rules with measured error rates and reported savings, written to ratchet-model.md.

🅷 5/5 ▰▰▰▰▰ ratchet · evidence · plan-verify structured · safe-path

Harness score

Five 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/$100

Token telemetry

Cache 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 it

doc2md

pptx, xlsx, pdf, docx and fig converted on demand, so a document costs a read instead of a context bomb.

보여집니다 (이중 피동) 보입니다 blocked at write time, by hook

Style gates

Write-time prose lint enforced by hook. Shipping today for Korean technical writing: double passives, translationese, cohesion.

FAQ

Questions people ask first

Is this the same tool as claude-token-saver?

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.

Does it call an LLM or need an API key?

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.

Will it change how I prompt?

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.

Where do the savings numbers come from?

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.

Install it once. Every session after gets safer and cheaper.

$ npm i -g sprag-cli Star on GitHub