Cheatsheet
The language and the command line of Semaprax 0.9.0 on one page. Each row links to the page that explains it.
The daily loop
Run these in your project directory.
semaprax fmt . # rewrite source to the one canonical form (--check only reports)
semaprax check . # parse, resolve, type-check, verify
semaprax test . # run the project's test functions
semaprax run . # run main and print its i64 result
semaprax build . --target web -o dist/web
fmt writes files; fmt --check does not. check never runs your code; run
and test do. For one file, semaprax fmt f.spx && semaprax run f.spx is the
whole loop. Add --json to check, run or test for one JSON object per
diagnostic.
Commands by task
Run semaprax help all for the full list, or see the
Command catalog.
| I want to | Command | Page |
|---|---|---|
| Start a project | semaprax new demo (--template library|service) | First project |
| Read a declaration’s meaning | doc <file>, query <project> --id <id>, context <input> <id> --depth 1 --max-bytes 4096, graph <file> | Explore |
| Find who calls what | query <project> --calls <id>, --called-by <id> | Explore |
| Look at a project visually | explore <manifest> --format html --output out.html | Explore |
| Change code by meaning | change preview, patch, impact, review | Shipping |
| Pin and compare an interface | lock . --write|--verify|--compare base.lock | Shipping |
| Build for a target | build . --target native|web|wasm|npm|oci | Targets |
| Check my toolchain or a download | doctor, version, release verify <dir> | Targets, Shipping |
| Reload code while editing | dev semaprax.toml --jsonl | Targets |
| Serve a project to an agent | service <project> [--mcp] | Shipping |
| Run an agent in a coding harness | harness setup, harness run, harness bridge | Harness |
| Run an agent or check its definition | agent inspect|run|replay | Agent programs |
| Get an error’s fix | help diagnostic SPX-T208 | Diagnostics |
| Look up a library function | help library compare | Standard library |
| See a language topic | help language topics, help language ownership | Essentials |
| Copy a declaration shape | help shapes record | Types |
The language at a glance
| Need | Spelling | Page |
|---|---|---|
| A file | module app.name; first, then declarations | Essentials |
| Stable identity | @id("app.name.fn") before every declaration | Essentials |
| Entry point | exactly fn main() -> i64 | Essentials |
| Result of a block | A tail expression, with no return and no trailing ; | Essentials |
| Bindings | let x = 1; immutable; let mut n = 0; then n = n + 1; | Essentials |
| Number types | i64 (default), i32, u8, usize, f64, f32; suffix 5i32, 3usize; operators never mix types | Types |
| Other scalars | bool, char ('a'), string (owned UTF-8), str (borrowed view) | Ownership |
| Conditional | if c { a } else { b }; always an expression, no else if | Essentials |
| Loop on a condition | while cond { ...; cond }; the last line is the continuation test | Loops |
| Loop over a vector | for item in values { ...; 0 } over an immutable Vec binding | Loops |
| Consume an iterator | for own item in it { ... }; match own on IterStep | Loops |
| Record | record P { @id("p.x") x: i64, }; build P { x: 1 }; update p with { x: 2 } | Types |
| Variant | cases Name, or Name { f: i64, }; build Shape::Dot {} | Types |
| Match | match v { Shape::Box { width: w } => w, _ => 0, }; guards n if n < 0; or-patterns -1 | -2 | Matching |
| Option and Result | Option<i64>::Some { value: 1 }; match Option::Some { value: v }; ? in a Result function | Matching |
| Class | class Dog : Animal { fn m(self: Dog) -> i64 { ... } }; call d.m(); super.m() | Classes |
| Generics | fn id<T>(v: T) -> T; call id<i64>(4) | Functions |
| Function values | fn(x: i64) -> i64 { x + 1 }; parameter f: fn(i64) -> i64 | Functions |
| Contracts | requires x >= 0 and ensures result >= 0 between signature and body | Contracts |
| Effects | permit { process.stdout.write } on the module, uses { ... } on each function | Contracts |
| Ownership | own T consumes; borrow T reads; a moved value cannot be reused | Ownership |
| Resources | resource R { drop trivial; } or drop import "host.symbol"; | Resources |
| Strings | string_concat(a, b); view string_as_str(binding); bytes str_as_bytes(view) | Built-ins |
| Vectors | vec_with_capacity<i64>(4usize); v = vec_push<i64>(v, 1); | Collections |
| Laws | @id("l.order") law relational (a: i64, b: i64) a <= b || b < a evidence smt_proved; | Laws |
| Session protocol | session protocol "name" { states {...} initial S; on S label: send T via "id" -> S2; } | semaprax help language |
| Import across files | use function @id("pkg.fn") from other.module as name; right after module | Modules |
| A test | fn test_add() -> i64 with an @id in a test module; return 0 to pass | Testing |
| Standard library | [dependencies] std.core = "^0.1.0" then use function @id("std.core.min") ... | Standard library |
Habits that fail: return, else if, x += 1, tuples, a[0], "a" + "b",
Some(1), i++, break, as casts, macros. The fix for each is in
Diagnostics.
A complete syntax reminder
module app.reminder;
@id("reminder.double")
fn double(value: i64) -> i64
requires value >= 0
ensures result == value * 2
{
value * 2
}
@id("app.main")
fn main() -> i64
{
let answer = double(21);
if answer == 42 { answer } else { 0 }
}
Reading a command synopsis
Angle brackets name values to replace, square brackets are optional parts, and |
means choose one. Do not paste the brackets into a shell. If a command says
<input>, give it a .spx file, a project directory or semaprax.toml.
Need a word explained? Open the glossary.