On this page
Compile time
The compiler turns .prime source files into runtime-ready artifacts on
disk. It runs only at build time; the runtime never re-parses source.
The compile pipeline

* L2 is opt-in (gated by ANTHROPIC_API_KEY or DEEPSEEK_API_KEY).
L1 — schema (mandatory)
Validates required fields, ref existence, decorator constraints, kind-specific schemas. Pure structural — no LLM call. Runs in milliseconds per atom.
L3 — cross-atom (mandatory)
Walks the resolved edge graph; flags cycles in requires, surfaces
contradicts pairs, validates kind compatibility on
validates-with and extends. Also pure — runs over the
in-memory graph after L1.
L2 — semantic (opt-in)
Calls a small LLM (DeepSeek by default, ~$0.0001/atom) to catch semantic drift —
e.g. a rule whose severity says low but whose remediation
describes a critical blocker. Gated by API key; absent the key, the compiler emits
a notice and skips L2.
Chunker — kind-aware projection
Walks the AST per atom and emits summary.md / core.md /
full.md. The split rules are kind-specific (see
Projection).
Emitters
Two artifacts produced per build:
- One directory per atom at
compiled/<prefix>/<short-id>/containingatom.yaml(metadata),graph.yaml(resolved edges), andchunks/{summary,core,full}.md. - One global index at
compiled/_index.xml— the always-loaded surface; one<cluster>per domain;<atom>entries with summary inline + edges as children.
Idempotence + caching
Compiling the same sources twice produces byte-identical output. L2 results are
cached by content-hash in .l2-cache.json so re-compilations don't
re-pay LLM cost for unchanged atoms.
CLI surface
# Compile one file (smoke test).
prime compile path/to/atom.prime
# Compile a whole sources tree to compiled/.
bun scripts/build-atom-dirs.ts \
--src primes/sources \
--out primes/compiled
# Compile + run L2 + show all errors.
prime compile primes/sources/*.prime --deep --strict
# Validate without emitting.
prime check --registry See Parser & AST, Checkers, and Chunker for how each stage is built.