Skip to content
Sakura Lang
v1.0.0Published on npm

Agent-first programming language

The programming language built for agents.

Your coding agent writes the code. Each function's signature says what it may touch and how it can fail, and the compiler holds every change to it. Sakura compiles to JavaScript and WebAssembly.

$ npm i -g sakuralang·agents: GET /llms.txt

Why would I use it?

Your agent can't quietly do more than the signature says.

Three things you would otherwise catch in code review. The compiler checks them on every change.

01

Every function says what it touches.

signup may use the database, the clock and randomness, and can fail with SignupError. Nothing else. When an agent adds a network call, sakura check stops it with V3001. Allowing the call means changing the signature, and that is for a person to approve; here the agent removes the call instead.

Effects

02

Bad values don't compile.

Cents is an Int that is never negative. Writing -5 where Cents is expected won't compile, and an unchecked Int only becomes Cents through a check: Cents.from or Cents.validate.

Refinement types

pay(250)✓ Cents250 >= 0 holdspay(-5)V5004never a valid Centspay(n)V2001an Int is not a Centstype Cents = Int where it >= 0

03

Tests give the same result every run.

Under sakura test the clock is fixed, randomness is seeded and output is captured. A test can't reach the network by accident: it has to supply a fake.

Testing

Handlers for each effect: under sakura run the host answers; under sakura test the handlers are deterministic.
Effectsakura runsakura test
Clock
Random
Env
Console
Http
1 passed, 0 failed, 0 skipped (seed 0)

How does it work with my coding agent?

One command connects your agent to the compiler.

Claude Code, Codex and Cursor get the compiler as an MCP server, plus a skill that teaches them the language. From then on the agent asks the compiler instead of guessing. Agent docs

terminalan agent's session
sakura setup --client all --apply  create .claude/skills/sakura/SKILL.md  create .mcp.json  create .codex/config.toml  create .cursor/mcp.json   …sakura check --json{"kind":"diagnostic","code":"V1004","message":"cannot find `list`; `List` exists but names differ in case …", "fixes":[{"title":"Use `List`","applicability":"machine_applicable","impact":"local", …}]}sakura fixf:db8db68ac7c828f3.0  V1004  src/count.sak:1:34  Use `List`  [machine_applicable, local]  appliedsakura test1 passed, 0 failed, 0 skipped (seed 0)
Recorded from the current compiler; long output trimmed with …
sakura mcp serveyour agentClaude Code · Codex · Cursor10 tools over stdiocompilerthe same answers as the CLIcompiler_info · check · symbol_query · hole_context · docs_queryexplain_diagnostic · format · check_patch · apply_patch · test

What does the code look like?

Read the signature. The compiler reads the body.

One file that compiles today. You review the three highlighted lines; check, test and verify make sure the body keeps to them. Language tour

  1. 01

    Takes. An Account and Cents: an Int that is never negative.

  2. 02

    May do. Ledger, and fail with Overdrawn. No network, files or clock.

  3. 03

    Requires. amount > 0. Breaking it is the caller's bug, reported as D020.

  4. 04

    Ensures. The new balance, checked on every return; sakura verify proves it ahead of time.

  5. 05

    Tests. Live beside the code and bring their own fake Ledger.

type Cents = Int where it >= 0type Account = { id: String, balance: Cents }error Overdrawn(balance: Cents) effect Ledger {  fn record(acct: Account) -> Unit} fn withdraw(acct: Account, amount: Cents) -> Account ! {Ledger, Fail<Overdrawn>}  requires positive: amount > 0  ensures result.balance == acct.balance - amount{  if amount > acct.balance { fail Overdrawn { balance: acct.balance } }  let next = Account { id: acct.id, balance: Cents.from(acct.balance - amount) }  Ledger.record(next)  next} fn ignore_ledger() -> Handler<Ledger> {  handler Ledger {    fn record(acct) { () }  }} test "withdraw never overdraws" {  let acct = Account { id: "a1", balance: 500 }  with ignore_ledger() {    expect_eq(withdraw(acct, 200).balance, 300)    expect_fail(fn() { withdraw(acct, 900) }, Overdrawn { balance: 500 })  }}
terminal
$ sakura test account.saktest withdraw never overdraws ... ok1 passed, 0 failed, 0 skipped (seed 0)
terminal
$ sakura verify account.sakproved      main::account::withdraw overflow t%21 = acct.balance - amount at account.sak:14:57proved      main::account::withdraw where Cents at account.sak:14:46proved      main::account::withdraw ensures withdraw at account.sak:11:113 proved, 0 disproved, 0 unknown, 0 unsupported (0 reused) (profile js, z3 5.3.1, rlimit 10000000)

Is it fast?

Native Sakura, counted against C, Rust, Go, OCaml and Koka.

The same programs in six languages, each one's work counted on one machine. For the typical program native Sakura does 45× the work of C. Its closest and furthest results are both below. Every number

  • vs C

    45×

    the work, for the typical program

    Within 1.94× of C on binary_trees. Furthest: 2,107× on countdown.

  • vs Rust

    15×

    the work, for the typical program

    6.30× less work than Rust on tokenizer. Furthest: 351× on handled_reentry.

  • vs Go

    8.56×

    the work, for the typical program

    23× less work than Go on tokenizer. Furthest: 211× on handled_reentry.

  • vs OCaml

    5.43×

    the work, for the typical program

    1.93× less work than OCaml on handled_d16. Furthest: 76× on awfy_permute.

  • vs Koka

    2.76×

    the work, for the typical program

    7.92× less work than Koka on awfy_mandelbrot. Furthest: 31× on awfy_cd.

Why native Sakura is fast

  • Cranelift machine code

    --target native compiles straight to machine code. Typed numbers stay plain machine numbers.

  • Memory reused in place

    When nothing else holds a value, an update rewrites it where it is instead of copying it (Perceus).

  • Borrowing, not copying

    A function that only reads its argument borrows it, so the call does no reference-counting work.

  • No collector pauses

    Reference counting frees memory the moment it is last used: there is no garbage collector to stop the program.

Work means CPU instructions per call, counted on an Apple M4 Pro: unlike seconds, a count repeats from run to run. Baseline 70c64513, 2026-10-22. Wall time on a GitHub runner: run 39810593780.

Is it ready?

1.0 is out.

v1.0.0 is the first stable release. The language, standard library, CLI, JSON output and runtime ABI keep working across 1.x; breaking changes wait for 2.0. Native, packages and workers are experimental.

.saksakura checkJavaScriptNode 26WebAssembly--target wasmnativeexperimental

stable in 1.x

  • CLI commands, flags and exit codes
  • Diagnostic codes and --json records
  • Standard library signatures
  • WebAssembly runtime interface
  • Editor (LSP) and agent (MCP) tools

experimental

  • --target native
  • [dependencies] packages
  • std/worker and @worker

StabilityRoadmap

How do I start?

Install it, then check a project.

Binaries for macOS, Linux and Windows. Platforms · Quickstart · For agents

needs Node 26

installs Node with it

checks SHA256SUMS; verifies attestations when gh is installed

  1. 1sakura new cli hello && cd helloscaffolds src/main.sak, AGENTS.md, CLAUDE.md
  2. 2sakura checkno problems
  3. 3sakura test1 passed, 0 failed, 0 skipped (seed 0)
  4. 4sakura runhello, world