πͺ¨ 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.
Install Β· The Trick Β· How It Saves Tokens Β· Why Caveman Β· Features Β· SDK

π₯ 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
| Tool | Fresh tokens | Pass rate |
|---|---|---|
| πͺ¨ caveman | βββββββββββββ 524k | 14 / 25 |
| codex | ββββββββββββββββββββββββ 1,010k | 15 / 25 |
1.93Γ fewer tokens than Codex CLI on identical tasks. Same
gpt-5.5model. Samexhighreasoning. 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 sink | Layer | What happens | Cut |
|---|---|---|---|
| Model reply | Caveman Mode | Terse technical fragments β no filler, no hedging. Levels lite Β· full Β· ultra. | prompt + reply |
| Tool output | Tool Budgets | Per-tool line caps (bash 80 Β· read 300 Β· grep 120), ANSI strip, blank-line collapse, semantic JSON/XML extraction. | β67% to β94% |
| Read Dedup | Files fingerprinted per session β re-reads return a stub, not the bytes. | β99% on repeats | |
| RTK | Optional 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%
| Metric | Value |
|---|---|
| Tokens saved (10 fixtures) | ~72,400 of 337K chars |
| System-prompt overhead | 120β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β
| Capability | Caveman | Claude Code | Codex | Aider | opencode |
|---|---|---|---|---|---|
| 4-layer token compression | β | β | β | repo map only | β |
| 20+ provider OAuth | β | Anthropic | ChatGPT | API keys | β |
| Autonomous goal loop | β | β | β | β | β |
| Autopilot β no permission prompts | β | β | β | β | β |
| Repo map (PageRank, Aider-style) | β | β | β | β | β |
| Architect / editor model split | β | β | β | β | β |
| Session branching + shadow-git checkpoints | β | β | fork only | git only | β |
| Persistent semantic memory (cavemem) | β | MEMORY.md | β | β | β |
| MIT open source | β | closed | Apache-2.0 | Apache-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 components | Caveman 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).