compile-code
A compiler for AI coding tasks.
Pre-resolves the mechanical work — who calls this, what changed recently, what breaks if I touch it, where the bug-site code is — before your coding agent's first model token, then verifies the change after it edits. Your agent spends its turns thinking, not grepping.
Works with Claude Code · one command · zero config · local compiler and verifier · zero model calls
A thin CLI over the roam-code engine (installed automatically) · 22 canonical intent procedures in Roam 13.10 · 28 languages · zero model calls
your prompt
│
▼
┌───────────────────────┐ deterministic · <0.5 s · zero model calls
│ COMPILE │ callers · git log · blast radius · bug-site source
└───────────────────────┘
│ facts injected before the agent's first token
▼
┌───────────────────────┐
│ YOUR AGENT │ edits with the facts already in context
└───────────────────────┘
│ after it edits
▼
┌───────────────────────┐ scoped review over exactly the changed lines
│ VERIFY │ returns a fix-or-suppress list before it stops
└───────────────────────┘
Install and use in 60 seconds
The 0.3.0 release candidate is dependency-gated, and that gate is open:
roam-code 13.10.0 is available on PyPI, so the tested >=13.10.0,<15
packaging interval resolves. The installer fails instead of silently
substituting an older kernel. That upper bound is a resolver preference — the
newest kernel major a receipt-v3 transaction has been run against — not a
runtime refusal: the CLI enforces the floor and lets the envelope-schema major
decide compatibility.
compile-code is not on PyPI yet. The existing v0.2.2 tag has an unpublished
draft; it does not contain the current source. Until 0.3.0 is published,
install main and record the installed commit when qualifying a workflow:
python -m pip install "compile-code @ git+https://github.com/Cranot/compile-code.git"
cd your-repo
compile claude # index + wire + launch Claude Code, all-in-one
Once the release ships, the pinned forms below resolve. Until then they fail
by design rather than installing something untested:
python -m pip install "compile-code==0.3.0" # owner-gated PyPI release
python -m pip install "compile-code @ git+https://github.com/Cranot/compile-code.git@v0.3.0"
Every path resolves the compile CLI and its roam-code engine together. The
packaging interval makes the command auditable and keeps an untested future
major out of what the 0.3.0 candidate resolves by default. It is not
a runtime refusal: a newer kernel already on your PATH is verified against the
envelope contract rather than rejected on its version number.
That's it. In the default fully wired mode, each prompt is compiled when the
local optimizer succeeds; optimizer failures pass the original prompt through
unchanged. Every edited turn then remains subject to scoped, fail-closed
verification. The explicit --no-verify and --allow-unwired modes relax that
guarantee as their names indicate.
Prefer your native workflow? Wire once, then keep typing claude like always:
compile init
compile wire claude # persistent; `compile unwire claude` removes the hooks
Requirements: Python 3.10+, a git repository, and Claude Code for the wired
flow (compile run works standalone). The indexer reads 28 languages.
For a one-off navigation prompt, preflight the facts before your agent starts
with broad grep/read setup:
compile run "who calls handleSave?"
That prints the compiled answer envelope up front: callers, file:line citations,
and the answer contract the agent can use instead of re-deriving the basics.
Why
Coding agents burn most of their turns and tokens gathering context:
grepping for the symbol, reading the file, running git log, re-deriving
the call graph. All of that is deterministic — a compiler can do it in
well under a second from a local index, with zero model calls, and hand
the agent the answers up front.
Results
All numbers are head-to-head A/B runs — the identical prompt and repo, with
and without the compiled envelope — on a 300+ KLOC production Python
codebase, June 2026. Medians over repeated runs; negative cells published
alongside the wins.
Headline (Claude Fable 5, 41-cell A/B, n=2/cell — controlled benchmark, June 2026, roam v13.4):
| Metric |
vanilla |
compiled |
delta |
| Agent turns (nav/comprehension, median) |
6 |
1 |
−83% |
| Input tokens (median/task) |
271K |
53K |
−80% |
| Cost (median/task) |
$1.30 |
$0.48 |
−63% |
| Wall time |
— |
— |
−50% |
| Compile overhead per prompt |
— |
p50 92 ms |
— |
A second run on Claude Opus showed the same direction at smaller magnitude
(−33% turns overall on that run; the best single cell reached −88%, but no
aggregate supports more than −33%). Other model tiers (Sonnet, Haiku,
non-Claude agents) have not been
measured on this A/B — the deltas above are measured on the frontier tier and
should not be assumed to transfer. On a ground-truth bug bench (a failing test
must transition to passing — not LLM-judged), the compiled arm fixed 10/10,
as did vanilla, at −13% cost. Read that honestly: 10/10 vs 10/10 does not
establish quality parity — at n=10 the 95% interval on the true resolve rate
runs [72%, 100%], and a compiled arm that had genuinely dropped to 90% would
still have shown 10/10 about a third of the time. It means no quality
difference was detected at a sample size with little power to detect one.
Full benchmark breakdown — per-task gallery (incl. the published losses), the bug bench, and routing stats
Per-task gallery (same bench, median per cell)
| Task |
turns |
input tokens |
cost |
"where is open_db defined?" |
3 → 1 |
156K → 51K |
$0.67 → $0.28 |
"which files depend on cli.py?" |
6 → 1 |
252K → 51K |
$1.15 → $0.30 |
"where is the ROAM_GREP_ENGINE env var configured?" |
9 → 1 |
497K → 53K |
$1.40 → $0.31 |
| "what are the layers of this codebase?" |
5 → 1 |
271K → 50K |
$1.42 → $0.41 |
"what changed in cli.py recently?" |
4 → 2 |
186K → 104K |
$0.62 → $0.40 |
| "explain the compiler module's architecture" |
13 → 6 |
618K → 240K |
$1.85 → $1.01 |
| "trace how a command becomes an MCP tool" |
12 → 8 |
464K → 303K |
$1.25 → $1.01 |
| security-hook comprehension (hard, multi-file) |
6 → 2 |
267K → 117K |
$1.15 → $0.56 |
| "what are the biggest cycles in this codebase?" (re-measured 06-11) |
6 → 1 |
— |
$0.65 → $0.07 |
| "where is the CLI entry point?" (trivial, re-measured Jun 11) |
1 → 1 |
48K → 50K |
$0.21 → $0.22 |
| "write a pytest for X" (generation, re-measured Jun 11) |
5 → 7 |
275K → 396K |
$0.61 → $0.45 |
The last two rows were the honest losses — published as losses, then fixed.
Generation-shaped prompts now get a ~0.6 KB lean envelope (or none), and the
trivial entry-point prompt routes to a pre-answered envelope. Re-measured at
n=3 medians on the same model: generation flipped to a −26% cost / −18% wall
win (expensive output tokens −29%, across more-but-cheaper turns), and the
trivial cell is a tie within noise. The big wins remain comprehension,
navigation, debugging, and review-shaped work.
Bug-fixing (ground-truth graded)
20-cell bench: planted bugs with real tracebacks, graded by a
failing-test-transitions-to-passing oracle — not LLM-judged.
- 10/10 fixed in both arms — but this is NOT a parity result. n=10 gives a 95%
interval of [72%, 100%] on the true resolve rate; a real drop to 90% would still
show 10/10 roughly a third of the time. Pooling all three graded bug benches we
have run (28 instances): compiled 23/28 (82%, CI [64%, 92%]) vs vanilla
22/28 (79%, CI [61%, 90%]) — the intervals overlap almost entirely.
No quality difference has been detected; the data cannot rule out a meaningful
difference in either direction. If quality parity matters to your decision, say
so and we will run a bench large enough to actually test it.
- Compiled arm cost $5.55 vs $6.41 total (−13%) — the envelope ships the
bug-site source slice (±12 lines around the cited
path:line), so the
typical fix landed within 2 turns instead of a grep-and-read walk.
Routing, measured on a frozen corpus
Replayed against 723 real prompts captured from live agent sessions
(re-measured on the June 11 2026 kernel):
- 57% of envelopes ship pre-executed answers (L1 probes) — the caller
list, the git history, the env-var location, the blast radius — so the
agent's first token can be the answer. A further ~33% ship structured
facts (relevant context, not the literal answer), and the rest are
freeform tasks that get a skeleton-plus-search envelope instead. (The
engine repo ships a regression guard for this rate —
tests/test_l1_rate_floor.py
replays a deterministic 60-prompt subsample of the corpus and fails
below a 45% L1 floor; it recorded 56.7% at introduction and skips on
public CI, where the private corpus and index are absent. An earlier
"91%" wording here counted the facts envelopes as answers, which they
are not.)
- Compile latency: p50 0.45 s cold on the replay harness, p50 92 ms
in live sessions (warm cache). Zero model calls, fully local.
- Last published dogfood check: 2026-07-11 on roam 13.7.1. The dogfood
harness re-measures the envelope on live codebases — that published rolling
cold-compile median = 410 ms (a separate live-traffic population, not
the 0.45 s replay-harness figure above). The headline A/B table is the
June-2026 controlled benchmark.
The numbers move with the kernel
compile-code 0.3.0 requires roam-code >= 13.10.0 and picks up compatible
kernel releases — so the published losses above are not static marketing:
each one was attacked in a kernel release and re-measured. The trivial-prompt cell
(+80% cost on v13.4) is a tie on v13.6; the generation cell (+17%) flipped
to a −26% win; the cycles cell went from +56% to −89% ($0.65 → $0.07).
The full version-keyed eval history, with raw cells and methodology, lives
in the roam-code README
and its benchmarks directory — this page keeps only the current,
reproducible numbers.
See one
A real envelope, compiled from this repo (compile run "who calls _require_index?", trimmed):
VERDICT: l1_probe_envelope for structural_callers
procedure: structural_callers
classifier_conf: 0.85
named_paths: ['src/compile_code/cli.py', 'tests/test_cli.py']
PREFETCHED ANSWERS (do not re-run the tools that produced these):
callers: (2 items)
- {'name': '_ensure_indexed_for_launch', 'location': 'src/compile_code/cli.py:1262',
'edge': 'call', 'call_line': 'if _require_index():',
'call_location': 'src/compile_code/cli.py:1271'}
- {'name': 'doctor', 'location': 'src/compile_code/cli.py:9689', 'edge': 'call',
'call_line': 'indexed = _require_index()',
'call_location': 'src/compile_code/cli.py:9699'}
callers_definition: Callers of `_require_index`. Each entry includes
`call_line` — the actual calling source line — so you do NOT need to
re-grep the symbol.
The agent receives this before its first token. The answer to "who calls
_require_index?" is already in its context, with file:line citations and an
answer contract — no grep, no file reads, no tool-call round-trips.
What gets injected
The compiler classifies your prompt into one of 22 canonical intent procedures
(deterministic regex + a local code graph — no model calls) and pre-executes
the matching probes:
- "who calls
handleSave?" → the caller list, with file:line
- "what changed in api.py last week?" → the git log, already filtered
- "fix the bug in cli.py:45" → the source around line 45, gutter-numbered
- "what breaks if I refactor X?" → blast radius + affected tests
- "where is the entry point?" → the
[project.scripts] console script
- "compare X vs Y", "top 5 most-imported files", "why is the CLI slow?"
→ the comparison, the ranking, the hot path — already computed
- unknown/freeform → file skeleton + targeted search, budget-capped
- generation-shaped ("write a test for X") → lean envelope or nothing —
measured as a loss, so the compiler stays out of the way
Everything arrives as a compact envelope (typically ~10 KB) with an answer contract,
so the agent answers from facts instead of re-deriving them. If a file you
named carries known open findings (complexity, N+1 shapes), the envelope
says so — the agent fixes debt opportunistically instead of re-deriving it.
After the agent edits
The other half of the loop: when your agent finishes editing, a scoped
review runs over exactly the lines it changed — and comes back as a
fix-or-suppress list the agent resolves before it stops. You see clean
turns; the agent quietly cleans up after itself.
What it catches, in practice:
- a function name that breaks your codebase's own convention (learned
from your production code, not a style guide — test fixtures never vote)
- an import that resolves to nothing — not your code, not the standard
library (Python stdlib / Node builtins), not anything declared in
pyproject or package.json. That is the signature of a hallucinated
dependency, and it FAILs the check with did-you-mean candidates when a
near-miss exists