Overview
How an AI coding agent works with Sakura Lang - the skill to install, the tools it calls, and the loop from signature to tested code.
This section is for anyone who has a coding agent (Claude Code, Codex, Cursor and others) write Sakura Lang, and for people building tools around the compiler. It covers what to give the agent, which compiler tools it calls, and the loop it follows.
Stable
v1.0.0 is the current release, and it is stable: what the Stability page
lists keeps working across 1.x, and a breaking change waits for 2.0. A security fix that has to
break something comes with a migration in the changelog. Native, packages and
workers are experimental and may change. These docs follow the main branch, which can be ahead of the latest release. See
Stability for what you can rely on and Changes for what
each release changed.
The idea in one paragraph
Agents write the code; humans review the signatures. A signature is everything a function
promises from the outside: its parameter and result types, any refinements on them (limits
such as where it > 0), its effect row (the side effects it may perform, such as Console
or Http, written after !), the errors it can fail with, and its contracts (requires
for what callers must guarantee, ensures for what the function guarantees back). An agent
fills in bodies to match; a reviewer reads the signatures and how they changed.
The working loop
Use this loop with the sakura command line (CLI) or the compiler's MCP server.
A check that passes can still contain unfinished parts, so always finish with tests and a build.
Report every signature, effect, error or permission change to the reviewer.
Load the language
Read docs/llms.txt once per session, or run sakura prompt, which prints the same file. It is
the whole core language in one file. Look up library functions with the MCP symbol_query tool
instead of guessing; sakura doc --search does the same offline.
Write signatures first, bodies as holes
A typed hole is a placeholder, ?name, for code not written yet:
fn clamp(x: Int, lo: Int, hi: Int) -> Int
requires ordered: lo <= hi
ensures bounded: lo <= result && result <= hi
{
?body
}sakura check accepts holes. The signatures are what a human reviews, so get them right first.
Check
Run sakura check --json, or call the MCP check tool. Each typed hole
comes back as a hole record: the type it must have, the effects allowed there, the local
variables in scope, and ranked suggestions.
Fill holes and fix diagnostics
Each problem comes back as a diagnostic record with a stable code (such as V3001), the exact
place in the source, what was expected and what was found, and suggested fixes. See
Diagnostics. sakura explain V3001 explains a code.
Apply fixes by impact
Every fix says what it changes, its impact. local fixes marked machine_applicable are safe
to apply. Fixes with impact interface_change, contract_change or authority_change are never
machine_applicable, and sakura fix never applies the last two. Then run sakura test --json
and sakura fmt.
Report signature changes
If the task really needs a new effect, error, permission or a changed contract, make the change
and list it for the reviewer. To stop an agent from editing the spec to make a check pass, run
--frozen-specs all --since <baseline> against the agreed Git revision; MCP callers pass
frozen_specs: "all" on both patch calls. Run sakura build after the tests: it refuses any
hole that is left.
What an agent should never do
- Add an effect, error tag or
[permissions]entry without flagging it. - Weaken or delete a
requires,ensuresorwhereclause, or edit atestbody, to make a check pass. A contract violation (D020,D021) means the caller or the function is wrong, not the spec. - Use
.trust(@trust("...")),Secret.expose,.expectorEmail.fromoutside trusted boundaries, or without a true reason. - Leave a
?holein code meant to build.sakura buildandsakura runreject it withV2050. - Borrow syntax from other languages: call-site type arguments (
f<T>(x),V0011) and named arguments (f(name: v),V0014) do not exist. Annotate the binding (let rows: List<User> = Sql.query(q)) and pass a record for options. Import every name outside the prelude explicitly (import std/http.{Http}andimport std/request.{Request}).
Install the Sakura skill
A skill is a folder of instructions an agent loads on demand. The sakura skill teaches the
compiler workflow, with examples and common repairs. Read the raw
SKILL.md, or download the complete skill ZIP
with its SHA-256 checksum and
content manifest.
- Verify the ZIP:
shasum -a 256 -c sakura-skill.sha256. - Extract its
sakura/folder into one project-local skill directory:.claude/skills/sakura/,.agents/skills/sakura/or.cursor/skills/sakura/. - Keep its
references/and anyassets/next toSKILL.md.
The files are a byte-identical copy of
skills/sakura/ in the
repository. The manifest records the compiler version, every file's SHA-256 and the ZIP's
SHA-256, but no Git commit, so the same source always produces the same files. The website
follows the current source; your installed compiler carries its own matching copy, filled in
from its version and the SAKURA_GIT_COMMIT it was built with. Prefer the compiler's copy when
versions differ. For a URL that never changes, pin a commit:
https://raw.githubusercontent.com/icantcodefyi/sakuralang/<commit>/skills/sakura/SKILL.md.
What to read
| Resource | What it is |
|---|---|
docs/llms.txt | The language reference for agents: the whole core language in one file. |
/llms.txt | An index of every page on this site, with titles, descriptions and URLs. |
/llms-full.txt | Every page on this site in one Markdown file. |
/docs/<page>.md | Any page on this site as Markdown: add .md to its URL. The docs root is /docs.md. |
| Copy as Markdown | A button at the top of every page, next to a menu with the .md link and the GitHub source. |
The two llms.txt files are different things; see llms.txt.
The tools
| Tool | What it does |
|---|---|
sakura check --json | Reports diagnostics, holes and a summary as JSON Lines (one JSON object per line). |
?name typed holes | Placeholders the checker describes: expected type, effects, locals and suggestions. |
sakura prompt | Prints the embedded language guide; --budget drops whole sections to fit a size. Look up signatures with sakura doc. |
sakura fix, --frozen-specs | Applies compiler fixes by impact, and refuses patches that touch frozen specs. |
sakura audit | Lists every place the code asks to be trusted. |
sakura doc | Searches signatures offline. |
sakura build --manifest | Records what a build trusts and which contract checks it keeps. |
sakura verify | Proves contracts and arithmetic safe, or finds a counterexample. |
sakura test --record | Records HTTP and model exchanges once; ordinary tests replay them offline. |
sakura mcp serve | Runs the compiler as Model Context Protocol tools. |
The roadmap says what is finished, experimental and planned.
Pages in this section
llms.txt
The site's Markdown exports and the language's docs/llms.txt.
MCP server
The compiler as tools an agent calls directly.
Diagnostics
The JSON Lines format, error codes and fix impact.
Typed holes
Writing programs a step at a time with ?name.
Trust audit
Find every place the code asks to be trusted.
Offline API search
Look up signatures, effects and contracts with sakura doc.
Build manifest
See what a build trusts and which checks it keeps.
Verify contracts
Prove contracts with a solver and read counterexamples.
Cassettes and recording
Replay HTTP and model exchanges offline; record them when you choose.
For contributors
The design document explains the reasoning behind these tools (section 12 covers the agent interface). It is provisional and includes decisions not built yet; the compiler and its matching guide say what is available.
Last updated
Embedding a library in Node
Call a Sakura Lang library's public functions from a Node program, on the WebAssembly or the JavaScript build, with callEntry, the entry rule, permissions and the value mapping.
llms.txt and Markdown exports
The two llms.txt files for Sakura Lang - this site's Markdown exports, and the language reference in docs/llms.txt that sakura prompt emits.