> ## Documentation Index
> Fetch the complete documentation index at: https://docs.styne.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# CLI reference

> Drive VMs and browsers from a terminal or a script with styne: create, list, exec, files, snapshots, forks, ports, logs, pause, resume and kill.

`styne` is a single static binary for Linux and macOS (amd64 and arm64).

## Install

```bash theme={"theme":"css-variables"}
curl -fsSL https://styne.ai/install | sh
```

The script needs no root and checks the release's checksum before it installs; the options, the update and the uninstall are on
[Install the CLI](https://docs.styne.ai/install.md).

## Verify the download by hand

```bash theme={"theme":"css-variables"}
curl -fsSLO https://styne.ai/cli/latest/SHA256SUMS
curl -fsSLO https://styne.ai/cli/latest/styne-linux-amd64
sha256sum --check --ignore-missing SHA256SUMS
```

## Run your first command

```bash theme={"theme":"css-variables"}
styne login                      # paste your API key; it is stored in ~/.config/styne/config with mode 600
id=$(styne vm create --template base --timeout 300)
styne vm exec "$id" -- 'echo hi; uname -m'
echo 'hello' | styne vm files write "$id" /tmp/hello.txt
styne vm files read "$id" /tmp/hello.txt
styne vm kill "$id"
```

`styne vm create` starts `base` unless `--template` names another; `styne template list` shows the templates your
key can start, with their aliases and size (`--json` for the API's answer).
`styne login` also takes the key from `STYNE_API_KEY`, which wins over the stored key, so CI jobs need no login step.
`styne vm exec` runs a single argument through `/bin/sh -c` and several arguments as an argv, prints stdout and
stderr as they stream, and exits with the command's exit code. `--api-url` or `STYNE_API_URL` points the CLI at another
API host.

## Command reference

| Command | What it does |
| - | - |
| `styne login [--skip-check]` | Stores an API key from `STYNE_API_KEY` or stdin, after checking it against the API. |
| `styne logout` | Removes the stored key. |
| `styne version` | Prints the CLI version, OS and architecture. |
| `styne mcp [--client NAME] [--url URL]` | Prints the command or config entry that adds the Styne MCP server to your agent's MCP client; the key is named by its environment variable. |
| `styne agent-guide` | Prints the guide an AI agent reads to use the sandboxes: CLI, MCP and docs. |
| `styne regions [--json]` | The regions sandboxes and browsers can run in. |
| `styne template list [--json]` | Templates your key can start, with aliases, vCPUs, memory and disk. |
| `styne vm create [--template base \| --from-snapshot NAME] [--timeout 300] [--json]` | Starts a sandbox and prints its id. `--from-snapshot` starts it from a saved snapshot instead of a template. |
| `styne vm list [--json]` | Your sandboxes: id, template, state, start and end time. |
| `styne vm get <id>` | One sandbox as JSON. |
| `styne vm run\|exec [--cwd DIR] [--env K=V] [--timeout SECONDS] <id> -- <command> [args...]` | Runs a command and exits with its exit code (124 on timeout, 128+N for signal N). One argument runs through `sh -c`, several run as an argv. |
| `styne vm files write <id> <path> [<local-file> \| -]` | Writes a file from a local file or stdin. |
| `styne vm files read <id> <path>` | Prints a file. |
| `styne vm pause <id>` | Saves the sandbox's state and stops its compute. |
| `styne vm resume [--timeout S] <id>` | Starts a paused sandbox again. |
| `styne vm kill <id>` | Ends the sandbox. |
| `styne vm snapshot <id> [--name NAME] [--json]` | Saves a running sandbox as a snapshot and prints its name. |
| `styne snapshot list [--json]` | Your saved snapshots: name, source sandbox, template, size and creation time. |
| `styne snapshot get <name>` | One snapshot as JSON. |
| `styne snapshot delete <name>` | Deletes a saved snapshot. |
| `styne vm fork <id> [--count N] [--timeout S] [--json]` | Copies a running sandbox and prints one new id per line; exits 1 if a copy was refused. |
| `styne vm ports <id> [--json]` | The sandbox's exposed ports and their URLs. |
| `styne vm ports <id> expose <port> [--public]` | Exposes a port and prints its URL; `--public` lets it through without the traffic token. |
| `styne vm ports <id> hide <port>` | Closes an exposed port. |
| `styne vm logs <id> [--follow] [--limit N] [--json]` | Output of the sandbox's commands, stdout lines on stdout and stderr lines on stderr; `--follow` keeps printing new lines until Ctrl-C. |
| `styne vm history <id> [--limit N] [--json]` | The commands the sandbox ran, newest first, with status, exit code and duration. |
| `styne vm ssh [--key FILE.pub] [--print] <id>` | Authorizes your OpenSSH public key on the VM and opens `ssh`; `--print` prints the command instead. |
| `styne browser create [--region R] [--timeout S] [--json]` | Starts a Chromium session and prints its id and CDP URL. |
| `styne browser list [--json]` | Your browser sessions: id, state, region, expiry. |
| `styne browser connect <id>` | Prints a fresh CDP URL for a running browser. |
| `styne browser rm <id>` | Ends the browser session. |

[Quickstart: the command line](https://docs.styne.ai/quickstart.md) walks the first run.
Flags may stand before or after the sandbox id, except for `exec` and `files`, where everything after the id belongs to
the remote command. If `styne help` does not list a command above, run the install one-liner again to update.

Aliases: `vm` is also `vms`, and `sandbox` still works; `template` is also `templates`; `list` is also `ls`; `kill` is also `rm`; `exec` is also `run`.
`styne help` and `styne --help` print the usage text.

## Global flags and variables

| Flag or variable | Meaning |
| - | - |
| `--api-url URL`, `STYNE_API_URL` | Use another API host. The default is `https://api.styne.ai`. |
| `STYNE_API_KEY` | The API key; it wins over the stored key, so CI jobs need no `login` step. |

## Run commands

```text theme={"theme":"css-variables"}
styne vm exec [--cwd DIR] [--env K=V] [--timeout-ms N] <id> -- <command> [args...]
```

A single argument after `--` runs through `/bin/sh -c`, so a shell line works; several arguments run as an argv, with no
shell. Output arrives as it is produced, stdout on stdout and stderr on stderr. The CLI exits with the command's exit code.

## Exit codes

| Code | Meaning |
| - | - |
| `0` | The command succeeded. |
| `1` | A call failed (the message is on stderr; a `401` adds a hint to run `styne login`). |
| `2` | Usage error: an unknown command, a missing argument or flag. The usage text is printed. |
| `124` | The command passed `--timeout-ms` and was killed. |
| `128` + signal | `exec` only: the command was ended by a signal. |
| other | `exec` only: the exit code of the command in the sandbox. |

## Files

`files write` and `files read` run through the sandbox's shell (`cat`), so they move any bytes, text or binary, and the
sandbox's disk (1 GiB on `base`) is the limit. For links without a key and whole folders, see [Files](https://docs.styne.ai/files.md).

## Uninstall

Run the installer with `--uninstall`; see [Update and uninstall](https://docs.styne.ai/install.md#update-and-uninstall).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.