Sakura Lang

CLI reference

Every sakura command, its flags, exit codes and environment variables, with each surface's stability level.

One sakura binary is the whole toolchain. This page lists what the current compiler accepts; sakura <command> --help prints the same flags for the binary you have. Commands that take [PATHS] accept files or directories and, with none, use src/ when it exists, otherwise the current directory.

Commands

CommandWhat it does
sakura check [PATHS]Parse, resolve names, check types, effects and exhaustiveness. Generates no code and accepts typed holes.
sakura fix [PATHS]Apply compiler fixes: the machine_applicable ones, or exactly the ids given. Never applies contract_change or authority_change fixes.
sakura build [PATHS]Check, then generate code. Holes are rejected with V2050.
sakura run [PATH] [-- ARGS]Build and run main. Arguments after -- go to the program.
sakura test [PATHS]Run test and property blocks under deterministic handlers with the network denied.
sakura verify [PATHS]Prove contract, overflow and division obligations with Z3. See Verify contracts.
sakura fmt [PATHS]Rewrite files in the one canonical format. There are no style options.
sakura audit [PATHS]List trust, totality, refinement and external sites. See Trust audit.
sakura doc [SYMBOL]Offline symbol documentation and type-pattern search. See Offline API search.
sakura explain CODEThe rationale, causes and repairs for a diagnostic code, offline.
sakura promptPrint the language guide for agents that matches this compiler.
sakura new KIND NAMECreate a project in a new directory.
sakura initMake the current directory a project, keeping existing files.
sakura setupPrint, and with --apply write, this project's agent files.
sakura lspThe language server on stdin/stdout. See Editor setup.
sakura mcp serveThe compiler as an MCP server on stdin/stdout. See MCP server.

There is no package command: packages are not part of 1.0, and a manifest that declares [dependencies] is refused with V8005. There is no --release flag; contract checks are removed only where sakura verify proved them.

Flags

check and fix

FlagMeaning
--jsonEmit JSON Lines on stdout. For fix, the diagnostics after fixing.
--frozen-specs SYMBOLS|allRefuse changes to the named symbols' signatures, effect rows, contracts and tests, or to permissions, compared with Git. Each change is V8020.
--since REVThe Git revision --frozen-specs compares with. Default HEAD.
fix --previewList every fix with its id, impact and whether it would apply. Writes nothing.
fix --apply IDSApply exactly these comma-separated fix ids (f:…).

build, run and test

FlagCommandsMeaning
--target js|wasmbuild, run, testThe backend. Default js. wasm writes main.wasm with its Node host.
--out-dir DIRbuild, run, testWhere the build goes. Default target/sakura/<target>.
--jsonbuild, testJSON Lines. test writes one test record per test, then a summary.
--manifestbuildAlso write target/sakura/manifest.json. See Build manifest.
--emit js|lirbuildWrite the JS modules, or the WASM backend's LIR as text.
--layout tagged|nichebuildHow Option is laid out in LIR. niche is not implemented and is refused.
--dump direct|core|ownedbuildPrint a compiler fact instead of writing code.
--seed NtestSeed for Random.seeded and property generators. Default 0.
--filter TEXTtestRun only tests whose name contains the text.
--update-snapshotstestWrite snapshot files instead of comparing them.
--recordtestLet cassettes forward misses to the network and append them. See Cassettes.
--contractstestAlso run a generated property for every contracted pub fn.
--stdtestRun the embedded standard library's own tests.

--target native exists only in a compiler built from source with the Cargo native feature. Release binaries are built without it. See Backends.

verify

FlagMeaning
--jsonobligation records, then a summary.
--target js|wasmThe integer profile obligations are checked on: js (±(2^53−1)) or wasm (i64).
--rlimit NZ3's resource limit per query. Default: [verify] rlimit in sakura.toml, else 10,000,000.
--solver PATHThe Z3 binary. Default z3 on PATH; it must be the pinned version, 5.3.1.

Other commands

Command and flagMeaning
fmt --checkChange nothing; list unformatted files and exit 1 if there are any.
audit --jsonaudit records, then a summary.
doc --search PATTERNSearch by type pattern, for example "fn(List<A>) -> Int".
doc --jsonOne symbol_query record.
prompt --budget NDrop whole sections from the end to fit about N tokens (4 bytes per token).
new KIND NAME --setup CLIENTKinds cli, lib, agent, api. Then run setup --apply for the client.
init --kind KINDThe same kinds. Default cli.
setup --client CLIENTclaude, codex, cursor or all (the default).
setup --applyWrite the files instead of printing them. Nothing outside the project is touched.
mcp serve --root DIRThe workspace. Default: the nearest directory upward that holds sakura.toml.

sakura new writes sakura.toml with an empty [permissions] table, sakura.lock, src/main.sak with one test, .gitignore, .gitattributes, and AGENTS.md and CLAUDE.md for coding agents. sakura setup writes the sakura skill, the client's MCP entry (merged into an existing configuration), Cursor's rule, and AGENTS.md and CLAUDE.md when they are absent.

Exit codes

CodeMeaning
0Success.
1Diagnostics with errors, a disproved obligation, formatting differences under fmt --check, or main ended with an uncaught typed failure.
2A usage, setup or I/O failure: a wrong flag, a missing file, Node or the solver not found. The message is text on stderr, even with --json.
3Test failures.
70A runtime defect. One JSON defect record goes to stderr.
75Refused at startup: main declares an effect that [permissions] grants no authority for.

sakura run exits with the program's own status, so a program can return other values.

Environment

VariableMeaning
SAKURA_CACHE_DIRWhere std's analysis is cached, one file per compiler build, under <dir>/sakuralang/std. Default $XDG_CACHE_HOME or ~/.cache on Unix, %LOCALAPPDATA% on Windows.
SAKURA_NO_CACHEAny nonempty value other than 0 turns that cache off.
SAKURA_NODEThe Node executable run and test use. Default node on PATH.
SAKURA_MAX_COPY_BYTESThe JS and WASM hosts' copy budget, decimal digits from 1 to 2^53−1. Default 256 MiB.
SAKURA_TRACEWhere the effect trace is written.

The cache files have no format promise: delete them at any time, and a missing or damaged file only costs the analysis it would have saved. run and test need Node 26; check, build, fmt, doc and explain do not. verify needs Z3 5.3.1, installed separately.

Stability

The commands, flags, exit codes and environment variables on this page are proposed as stable from v0.2.0 under draft RFC 0001, with these exceptions: build --emit, --layout and --dump are experimental or internal, and --target native is experimental. Until RFC 0001 is accepted, the preview carries no compatibility promise. Help text and human-readable output are never a contract; the --json records are.

Edit on GitHub

Last updated

On this page