# Quickstart

URL: /docs/quickstart
Markdown: /docs/quickstart.md

> 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 [#1-install]

You need [Node 26](https://nodejs.org): `sakura run` and `sakura test` run the compiled
JavaScript with `node`. Then install the compiler with npm:

```bash
npm install --global sakuralang
sakura --version
```

On macOS or Linux x64 you can use Homebrew instead:

```bash
brew tap icantcodefyi/sakuralang
brew trust --tap icantcodefyi/sakuralang
brew install sakuralang
```

[Install](/docs/install) covers Windows, the installer script, other versions and every
platform.

## 2. Create a project [#2-create-a-project]

```bash
sakura new cli hello
cd hello
```

This 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 [#3-run-it]

```bash
sakura run
```

```text
hello, world
```

Anything after `--` goes to your program:

```bash
sakura run -- Ada
```

```text
hello, Ada
```

## 4. Read the code [#4-read-the-code]

Open `src/main.sak`:

```sakura title="hello/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") }
```

- `greeting` has no `!` in its signature, so it is **pure**: it only builds a string.
- `main` ends 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.first` returns an `Option`: `Some(first)` or `None` for an empty list. There is no
  `null`. `Option.unwrap_or` picks `"world"` when there is no argument.
- The `test` sits next to the code it tests.

## 5. Test and check [#5-test-and-check]

```bash
sakura test
```

```text
test 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:

```bash
sakura check
```

```text
no problems
```

## 6. Break it on purpose [#6-break-it-on-purpose]

Make `greeting` print, without changing its signature:

```sakura expect=V3001 title="hello/src/main.sak"
import std/cli.{Cli}

/// The greeting for `name`.
pub fn greeting(name: String) -> String {
  Console.print("greeting {name}") // [!code highlight]
  "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:

```text
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 error
```

The 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](/docs/agents/diagnostics).

## 7. Ask the compiler what fits [#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:

```sakura holes
fn unfinished(x: Int) -> Int { ?result }
```

```text
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](/docs/agents/typed-holes).

## What is in the project [#what-is-in-the-project]

- **`sakura.toml`** names 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](/docs/manifest).
- **`src/`** holds the code. One file is one module, and `src/main.sak` holds `main`.
- **`AGENTS.md`** and **`CLAUDE.md`** give coding agents short instructions: run `check`,
  `fmt --check` and `test`, 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 [#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](/docs/cli) lists every command, flag and exit code.

## Install from source [#install-from-source]

To follow `main` between releases, build the compiler yourself. You need
[rustup](https://rustup.rs) and Node 26. rustup fetches the pinned Rust version on the first
build.

```bash
git clone https://github.com/icantcodefyi/sakuralang
cd sakuralang/compiler
cargo install --locked --path crates/sakura_cli
sakura --version
```

From a checkout, `sakura run compiler/examples/counter` runs one of the
[example projects](https://github.com/icantcodefyi/sakuralang/blob/main/compiler/examples/README.md).

## Next [#next]

Start the [Language Tour](/docs/tour/basics), or [build and deploy a server](/docs/server).
