Quickstart
Install Sakura Lang, then create, run and test a first program in about two minutes.
This page takes you from nothing to a running program. It takes about two minutes.
1. Install
You need Node 26: sakura run and sakura test run the compiled
JavaScript with node. Then install the compiler with npm:
npm install --global sakuralang
sakura --versionOn macOS or Linux x64 you can use Homebrew instead:
brew tap icantcodefyi/sakuralang
brew trust --tap icantcodefyi/sakuralang
brew install sakuralangInstall covers Windows, the installer script, other versions and every platform.
2. Create a project
sakura new cli hello
cd helloThis makes a hello folder with a manifest (sakura.toml), your code in src/main.sak,
and an AGENTS.md that tells coding agents how to work in the project.
3. Run it
sakura runhello, worldAnything after -- goes to your program:
sakura run -- Adahello, Ada4. Read the code
Open src/main.sak:
import std/cli.{Cli}
/// The greeting for `name`.
pub fn greeting(name: String) -> String { "hello, {name}" }
pub fn main() -> Unit ! {Cli, Console} {
let name = Option.unwrap_or(List.first(Cli.args()), "world")
Console.print(greeting(name))
}
test "greets by name" { expect_eq(greeting("Sakura Lang"), "hello, Sakura Lang") }greetinghas no!in its signature, so it is pure: it only builds a string.mainends with! {Cli, Console}. These are its effects, the things it does besides returning a value. It reads command-line arguments (Cli) and prints (Console), and nothing else.List.firstreturns anOption:Some(first)orNonefor an empty list. There is nonull.Option.unwrap_orpicks"world"when there is no argument.- The
testsits next to the code it tests.
5. Test and check
sakura testtest greets by name ... ok
1 passed, 0 failed, 0 skipped (seed 0)Tests run with a fixed clock, seeded randomness and captured output, so they give the same
result every time. sakura check type-checks the project without running it:
sakura checkno problems6. Break it on purpose
Make greeting print, without changing its signature:
import std/cli.{Cli}
/// The greeting for `name`.
pub fn greeting(name: String) -> String {
Console.print("greeting {name}")
"hello, {name}"
}
pub fn main() -> Unit ! {Cli, Console} {
let name = Option.unwrap_or(List.first(Cli.args()), "world")
Console.print(greeting(name))
}sakura check refuses it:
error[V3001]: function `greeting` performs `Console`, which its signature does not allow (allowed: `{}`)
┌─ src/main.sak:4:8
│
4 │ pub fn greeting(name: String) -> String {
│ ^^^^^^^^
5 │ Console.print("greeting {name}")
│ -------------------------------- `Console.print` performs `Console` here
│
= expected: {}
= found: {Console}
= help: Add `Console` to the signature
= help: Handle the effect locally with `with`
= see `sakura explain V3001`
1 errorThe signature promised a pure function, and the body broke that promise. You have two honest
fixes: add ! {Console} to the signature, so a reviewer sees the change, or remove the print.
sakura explain V3001 describes the error with a wrong and a fixed program.
Agents read the same error as JSON with sakura check --json. See
Diagnostics.
7. Ask the compiler what fits
A typed hole is a placeholder, ?name, for code you have not written yet. sakura check
accepts it and tells you what could go there:
fn unfinished(x: Int) -> Int { ?result }hole ?result: expected Int, effects {}; locals [x: Int]; candidates [x, Int.abs(?i), Int.clamp(?i, ?lo, ?hi), …]sakura build and sakura run refuse a program that still has holes. See
Typed holes.
What is in the project
sakura.tomlnames the package. Its[permissions]table lists what the program may reach: files, network hosts and environment variables. It starts empty, because this program only reads its arguments and prints. See sakura.toml.src/holds the code. One file is one module, andsrc/main.sakholdsmain.AGENTS.mdandCLAUDE.mdgive coding agents short instructions: runcheck,fmt --checkandtest, and never weaken a contract to make a check pass.
Format your code with sakura fmt. It has no options, so every project looks the same.
Common commands
| Command | What it does |
|---|---|
sakura new cli NAME | Create a project (lib, agent and api also exist) |
sakura run [-- ARGS] | Build and run main |
sakura test | Run every test and property |
sakura check | Type-check without running |
sakura fmt | Format the code |
sakura explain CODE | Explain an error code |
sakura build --target wasm | Build for WebAssembly instead of JavaScript |
The CLI reference lists every command, flag and exit code.
Install from source
To follow main between releases, build the compiler yourself. You need
rustup and Node 26. rustup fetches the pinned Rust version on the first
build.
git clone https://github.com/icantcodefyi/sakuralang
cd sakuralang/compiler
cargo install --locked --path crates/sakura_cli
sakura --versionFrom a checkout, sakura run compiler/examples/counter runs one of the
example projects.
Next
Start the Language Tour, or build and deploy a server.
Last updated