Skip to main content

πŸͺ¨ Caveman Code

The terminal coding agent that talks like a caveman β€” and burns half the tokens doing it.

Same model. Same task. ~2Γ— fewer tokens than Codex. 20+ providers Β· plan mode Β· autopilot loop Β· MIT.

Starsnpm versionnpm downloadsMIT License

Install Β· The Trick Β· How It Saves Tokens Β· Why Caveman Β· Features Β· SDK

caveman install + first prompt β€” 30 seconds

πŸ”₯ The trick​

Big agent waffle. Waffle cost token. Caveman no waffle.

Asked β–Έ why does this component re-render on every keystroke?

Ordinary agent Β· ~290 tokensπŸͺ¨ Caveman Code Β· 31 tokens
Great question! A React component can re-render on every keystroke for several reasons. The most common cause is passing a fresh object or function reference as a prop on each render, which defeats React's referential-equality bail-out and forces the child to reconcile again … (three more paragraphs)New object ref each render. Inline prop = new ref = re-render. Wrap in useMemo.

Same answer. Same model. Caveman version costs ~9Γ— less to read back β€” and the agent reads its own context back on every single turn. The saving compounds across the whole session.

That is the entire product. Everything below is the coding agent it ships inside.


The proof​

25-task MicroBench Β· gpt-5.5 Β· xhigh reasoning Β· 2026-05-18

ToolFresh tokensPass rate
πŸͺ¨ cavemanβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–Œ 524k14 / 25
codexβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ 1,010k15 / 25

1.93Γ— fewer tokens than Codex CLI on identical tasks. Same gpt-5.5 model. Same xhigh reasoning. Pass rate within one task.

No marketing-deck baselines. Each tool spawned as a real child process. Each task verified by a task-specific verify.sh. Raw CSV + per-task logs published.

npx tsx research/evals/run-honest-bench.ts --tools caveman,codex # reproduce in one command

Raw CSV Β· Aggregate JSON Β· Methodology Β· 25 task prompts


How It Saves Tokens​

Four compression layers, always on β€” and they hit two separate token sinks: what the model says and what the shell returns.

Token sinkLayerWhat happensCut
Model replyCaveman ModeTerse technical fragments β€” no filler, no hedging. Levels lite Β· full Β· ultra.prompt + reply
Tool outputTool BudgetsPer-tool line caps (bash 80 Β· read 300 Β· grep 120), ANSI strip, blank-line collapse, semantic JSON/XML extraction.βˆ’67% to βˆ’94%
Read DedupFiles fingerprinted per session β€” re-reads return a stub, not the bytes.βˆ’99% on repeats
RTKOptional external Rust binary ("Rust Token Killer") β€” pipes bash output through rtk before it enters context.βˆ’60% to βˆ’90% (RTK's own bench)

Pays for itself after one tool call.

Benchmark β€” 10 real tool-output fixtures Β· βˆ’86% aggregate

git diff (901 lines) β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ -94%
npm ls (701 lines) β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ -92%
ls recursive (601 ln) β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ -90%
grep results (801 ln) β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ -89%
test output (501 ln) β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ -88%
XML/pom.xml (382 ln) β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ -79%
docker inspect (258) β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ -68%
ANSI colored (97 ln) β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ -50%
read file (429 lines) β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ -32%
build output (19 ln) β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ -18%
────────────────────────────────────────────────────
AGGREGATE β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ -86%
MetricValue
Tokens saved (10 fixtures)~72,400 of 337K chars
System-prompt overhead120–195 tokens (lite–ultra)
Net savings β€” 15-turn session+567K tokens (~$1.70, Sonnet)
Net savings β€” 30-turn session+1.13M tokens (~$6.92, Sonnet)
npm run bench:offline # compression analysis β€” free, <1s
npm run bench:replay # analyze your real sessions β€” free
npm run bench:live # A/B with live LLM calls β€” needs API key
Use `/caveman [lite|full|ultra|off]` in the TUI to adjust compression aggressiveness.

Why Caveman Code​

CapabilityCavemanClaude CodeCodexAideropencode
4-layer token compressionβœ…βŒβŒrepo map only❌
20+ provider OAuthβœ…AnthropicChatGPTAPI keysβœ…
Autonomous goal loopβœ…βŒβŒβŒβŒ
Autopilot β€” no permission promptsβœ…βŒβŒβœ…βŒ
Repo map (PageRank, Aider-style)βœ…βŒβŒβœ…βŒ
Architect / editor model splitβœ…βŒβŒβœ…βŒ
Session branching + shadow-git checkpointsβœ…βŒfork onlygit only❌
Persistent semantic memory (cavemem)βœ…MEMORY.md❌❌❌
MIT open sourceβœ…closedApache-2.0Apache-2.0βœ…

Full table including Crush: docs/comparison.md.


Acknowledgements​

Caveman Code is a heavy fork of pi-code by Mario Zechner. We track upstream and contribute fixes back where generally useful.

From pi-code (upstream)Caveman Code's own work
Agent runtime Β· MCP scaffolding Β· provider OAuth Β· repo map Β· slash-command parser Β· settings manager Β· skills loader Β· edit-format renderers Β· TUI componentsCaveman Mode (4-layer compression) Β· goal loop Β· plan mode Β· cavemem integration Β· /tree session branching Β· architect/editor split Β· honest-bench harness

Also indebted to Aider (repo map + edit-format-per-model), Claude Code (settings/commands/skills/agents/.mcp.json formats β€” adopted verbatim, then extended), Codex (cave-as-MCP-server), RTK (optional bash-output compression layer), and Biome (single-binary lint/format).

Missing credit? Open an issue β€” we'll fix it fast.


License​

MIT Β© Julius Brussee. Forked from pi-code (MIT Β© Mario Zechner).

Issues Β· Releases Β· Changelog Β· Docs

Caveman no waste token. Caveman ship.