Caveman for coding agents

Your harness. Any model.Half the bill.

Keep Claude Code, Codex or OpenCode. Caveman trims what every turn reads and writes, and hands each task to the cheapest model that gets it right.

GitHub 108k

$npx @caveman-ai/cli

Fig 0DESK COMPUTER
ILLUSTRATIVE SESSIONClaude Code v2.1.4 · Opus 5>
TYPE ON IT · CLICK IT TO SWITCHclaude code · 0 chars
+30 more

01 Starred by engineers at

108kOpen source
GitHub stars#1 on Hacker News and GitHub Trending
65%Output
Less readable output≈ −10% total on long-horizon coding tasks
33.2%Input
Fewer input tokens6 tasks, 18 of 18 answers right
0.46×Adaptive
The cost per taskSWE-Interact + SWE-Together, vs always-Opus, same solve rate

02 How it works

Three ways every turn gets cheaper.

Fig 1.1SCANNER
originalcavemanPASS src/cart.spec.tsPASS src/auth.spec.tsFAIL src/checkout.spec.ts× pays with saved cardTimeout 5000ms exceededat checkout.spec.ts:42PASS src/search.spec.tsTests 1 failed, 41 passed{ "id": 4182,"status": "error","items": [ 212 more ],"meta": { "page": 1,"next": null },"error": "rate_limited","retry_after": 30,"trace": "a9f3c1e0" }diff --git a/src/pay.ts@@ -40,6 +40,7 @@const total = sum(cart)- await charge(total)+ await charge(total, {+ idempotencyKey })return receipt}1 failedcheckout.spec.ts:42timeout at #paystatus errorrate_limitedretry in 30ssrc/pay.ts +2 -1charge() takes anidempotencyKey
HOVER TO SCRUBtest.log · 18,240 → 201 tok
  1. Fig 1.1SCANNER
    originalcavemanPASS src/cart.spec.tsPASS src/auth.spec.tsFAIL src/checkout.spec.ts× pays with saved cardTimeout 5000ms exceededat checkout.spec.ts:42PASS src/search.spec.tsTests 1 failed, 41 passed{ "id": 4182,"status": "error","items": [ 212 more ],"meta": { "page": 1,"next": null },"error": "rate_limited","retry_after": 30,"trace": "a9f3c1e0" }diff --git a/src/pay.ts@@ -40,6 +40,7 @@const total = sum(cart)- await charge(total)+ await charge(total, {+ idempotencyKey })return receipt}1 failedcheckout.spec.ts:42timeout at #paystatus errorrate_limitedretry in 30ssrc/pay.ts +2 -1charge() takes anidempotencyKey
    HOVER TO SCRUBtest.log · 18,240 → 201 tok

    Reads less.

    Logs, test output, JSON and diffs shrink before the model reads them. The original stays on disk if it asks.

    33.2% fewer input tokenswhole sessions, 18 of 18 answers right

  2. Fig 1.2SHREDDER
    cavemanGreat question! The reasonyour React component isre-rendering is likelybecause you're creating anew object reference oneach render cycle. I'drecommend using useMemo tomemoize the object.Connection pooling is atechnique where yourapplication keeps a set ofopen database connectionsthat can be reused acrossrequests, so you don't payfor a new handshake everytime you query.It looks like TypeScript iscomplaining about apossible null value here,because user might beundefined at this point.You'll want to add a guardbefore accessing itsproperties.New object refeach render.Wrap in useMemo.Pool reuse openDB connections.Skip handshake.Null in union.Add if (!user)return;
    HOVER TO FEED FASTERwords 30 → 8

    Says less.

    Answers drop the filler. Code, commands and errors come back byte for byte.

    65% less readable output≈ −10% of total tokens on long-horizon coding tasks

  3. Fig 1.3GATE
    Haiku 4.5Sonnet 5Haiku 4.5Opus 5Haiku 4.5Sonnet 5caveman
    HOVER TO SLOW TIMErate 1.00×

    Picks the model.

    Adaptive model selection gives every turn the cheapest model and effort that gets it right. Hard work still gets the frontier one.

    0.46× the cost per taskSWE-Interact + SWE-Together, 85 paired tasks vs always-Opus, same solve rate

03 Open source

It started as a joke that made agents talk like cavemen. Then it went to #1 on Hacker News and #1 on GitHub Trending.

  • 108,463 stars
  • 904 points on Hacker News
  • 30+ agents
  • MIT licensed

04 Adaptive model selection

The first router that isn't a benchmark trick.Every model, right where you are.

It picks the model and the effort for every turn from what your agent is actually doing, then checks whether the work passed. Built by engineers who run coding agents all day.

Fig 3.1ADAPTIVE SELECTION
Claude CodeCodexOpenCodeOpus 5Haiku 4.5 · est. $0.004GPT-5DeepSeek V4 ProSonnet 5Gemini 3.7 FlashKimi K2Qwen
pairings and prices illustrative
HOVER A HARNESS OR MODELClaude Code → caveman → Haiku 4.5
A typical routerCaveman
Trained once on a leaderboard, then frozen.Learns from outcomes: tests that pass, tests that fail, retries, work you abandon.
Scores one prompt in isolation.Reads the live session: the task, the agent type, the context and cache it carries, the turn it is on.
Picks a model.Picks the model and the reasoning effort, every turn.
Proven on single-turn tests like MT Bench and MMLU.Measured on SWE-Interact and SWE-Together, 85 agentic coding tasks: 0.46× the cost of always-Opus, same solve rate.
A black box on your bill.Every decision on the record: what it read, each candidate, why each lost. One line in your terminal.
Breaks the run when it's down.Fails silent. No key, slow, or a bad reply: the task runs exactly as asked. One command turns it off.

The priciest modelis sometimes the cheapest.

A cheap model that loops for fourteen turns costs more than a frontier one that finishes in three. The router prices the whole task.

Fig 3.2TURN LEDGER
passes $0.19cheap model · 14 turns$0.42illustrativefrontier · 3 turns$0.19
HOVER TO SCRUBturn 14 · $0.42 vs $0.19

05 Blocks

Pre-release

Why many scriptwhen few do trick.

skills.sh for code mode. Agent write same script every session, throw it away, write it again. Blocks keep it in your repo, check it every PR, hand it back.

Claude Code · Codex · Cursor Apache-2.0

Fig 5.1394 → 1
json-peek--path <path>1 block394×
← One week · one rock →
Normal agentwrites a script
python3 - <<'EOF'
import json
ops=json.load(open('cloud/agent-surface/generated/operations.json'))
print(type(ops), (list(ops.keys())[:5] if isinstance(ops,dict) else len(ops)))
items = ops['operations'] if isinstance(ops,dict) and 'operations' in ops else ops
print(json.dumps(items[0] if isinstance(items,list) else list(items.items())[0], indent=1)[:800])
EOF
101 tokens
Blocks agentruns a block
$ caveman-blocks run json-peek --path cloud/agent-surface/generated/operations.json
{"kind": "object", "keys": ["schema_version", "contract_sha256",
 "operations", "exclusions", "operations[].id", … 15 more],
 "rows": 1, "sample": {"schema_version": 1, …}, "truncated": true}
21 tokens

Same question. 101 token become 21.Every session after, still 21.

A real script from a Claude Code transcript, rerun on the same 1.4 MB file (251,893 tokens). Token counts: tiktoken o200k.

394×Scan
One script, rewritten in a week32 sessions, one developer, counted by scan
up to9.57%Purdue
Of every task's cost spent rewriting scriptsPurdue, arXiv, Sep 2026
397 →76This repo
Tokens for one Go test run| tail -20 vs test-summary, 326 tests
  1. 01 init
    $ npx caveman-blocks init

    Eight rules and a one-line-per-block index go into AGENTS.md.

  2. 02 hint
    › Blocks: json-peek covers this.

    A heredoc a block covers gets one line back. A new one becomes a candidate. Nothing is denied or rewritten.

  3. 03 verify
    $ caveman-blocks verify ✓ stamped

    Every block runs its own example. CI re-checks on every PR. A broken block drops out of the index.

Blocks against what agents type now

tokens, tiktoken o200k
TaskRaw outputAgents nowBlock
go test -v ./...326 tests10,561397| tail -2076test-summary
1.4 MB JSONone file251,893236their own heredoc227json-peek
366-line Go filefind definitions3,111250grep -n "^func |^type "489grep-defsloses

grep-defs loses to a bare grep. It labels every definition with file, kind, name and line.

06 Savings

Put a dollar on it.Your team. Your spend.

Fig 6.1Estimate
Layers3 of 4 on

Estimate · saved per month

$8,699 saved per month, $104,394 a year. Bill $12,500 becomes $3,801.−69.6%

$104,394 a year · bill $12,500 → $3,801

Hover a columnReads less −$3,320 · Says less −$918 · Picks the model −$4,461
How we count

Each layer has its own basis, below. Here the layers are multiplied, one after another. They were not measured together.

Reads less 33.2%
Fewer input tokens. Whole sessions, 6 tasks, 18 of 18 answers right.
Says less ≈10%
65% fewer readable output tokens on a 10-prompt benchmark. Readable output is a small part of a long coding task, so the calculator counts ≈10% of total tokens on long-horizon coding tasks, our own estimate.
Picks the model 0.46×
The cost per task, with adaptive model selection. Measured on SWE-Interact and SWE-Together: 85 paired agentic coding tasks, routed Claude Code vs always-Opus 5.5 at max effort, same solve rate. Interim run, list-price estimates.
Keeps the script up to 9.57%
Of task cost. Purdue's published ceiling for the share spent rewriting scripts. Blocks is pre-release.

Assumes 80% of agent spend is input tokens and 20% is output. If your team already runs models cheaper than Opus at max effort, routing saves less.

$12,500 × (0.8 × 0.668 + 0.2) × 0.9 × 0.46 = $3,801

The new Caveman

Get the full optimization stack.

Reads less. Says less. Picks the model. Keeps the script. One install, in the agent you already run.

30+YOUR AGENT01020304
  • 01Reads less−33%inputwhole sessions
  • 02Says less−65%readable output≈ −10% total on long coding tasks
  • 03Picks the model0.46×cost per taskSWE-Interact + SWE-Together
  • 04Keeps the scriptPre-release

$npx @caveman-ai/cli

Free · MIT · Claude Code, Codex, OpenCode and 30+ more