Every agent turn spends tokens twice. The input it reads back is test logs, install spam and build noise. The output it writes is your code. Most tools trim one side and self-report the win. occam trims both, a deterministic engine on the input and an always-on rule on the output, with a real ledger and a reproducible benchmark behind every number.
- Input: 83% fewer tokens, 100% of the signal kept. Test, install and build noise gets compacted before the model reads it. Every line that matters lives through the trim, each failure, warning and summary. A failing run is never cut.
- Output: about half the tokens, same correctness. In an A/B on real tasks (same model, rule on vs off) the rule cut output by 49% at identical test results. The benchmark scores a careless one-liner 0.833, it fails a trap, against a right-sized solution at 1.000.
- 12/12 reliability gates green. Reproduce every number yourself:
node benchmark/in.mjsandnpm test.
Claude Code (recommended, wires both ends for you):
/plugin marketplace add borghei/occam
/plugin install occam@occam
Every other agent. Install the CLI once, then turn the rule on per agent:
npm i -g github:borghei/occam # gives you the `occam` command
occam init codex # Codex / OpenAI
occam init cursor # Cursor
occam init copilot # GitHub Copilot
occam init windsurf # Windsurf
occam init cline # Cline / Roo
occam init claude # Claude Code (rule only)The output rule is on right away. occam init also tells the agent to run noisy
commands through occam run, so the input side compacts too:
occam run npm testOn Codex, occam init codex goes further and wires a PreToolUse hook that does
the wrapping for you. Trust it once in Codex with /hooks.
Output, an always-on rule. One short paragraph, injected every turn, that makes
the agent write the right amount of code. Reach for stdlib or the native feature
first, collapse boilerplate, add nothing nobody asked for. But never cut
validation, error handling, security or accessibility. One source (RULES.md)
generates every agent's format, so the rule can't drift. scripts/generate.mjs --check guards it in CI.
Input, a deterministic engine. A pure compactor trims noisy output before the
model reads it. Strip ANSI, drop the PASS/✓ noise, dedupe repeats, truncate
while keeping head and tail. It knows a test run from an npm install, and on a
non-zero exit it hands back the full output untouched. On Claude Code this runs on
every command automatically (the plugin's PostToolUse hook). Codex gets a
PreToolUse hook from occam init codex that rewrites noisy commands to occam run. Other hosts can't rewrite output or commands from a hook, so the installed
rule tells the agent to use occam run <cmd> itself. Same engine, same trim.
After install you also get /occam:review to shrink what you just wrote, plus
/occam:audit, /occam:debt and occam gain for your running total.
- Failures pass through whole. Debugging never loses the trace.
- Exit codes preserved. Your
&&,||and CI gates still behave. - Idempotent, labeled and lazy. It never double-trims, tags every result and skips the trim when it wouldn't save tokens.
npm test # 12/12 reliability gates
node benchmark/in.mjs # input: tokens removed + signal retained (colorized)
node benchmark/chart.mjs # regenerate the chart above from those live numbers
cd benchmark && node score.mjs tasks/csv-sum examples/csv-sum.naive.mjs examples/usage.naive.json
node score.mjs tasks/csv-sum examples/csv-sum.rightsized.mjs examples/usage.rightsized.jsonThe naive answer is shorter and cheaper, yet it scores lower, 0.833 vs 1.000, because it breaks on a quoted comma. Less code is good. Wrong code isn't. Correctness counts for half the score, so you can't win by cutting corners.
MIT © borghei. Issues and PRs welcome.
Edit RULES.md, never the generated files, then run node scripts/generate.mjs.