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

# CLI command reference

> Commands, flags, and output modes for the Sutro CLI.

## Installation

Install the CLI globally:

<CodeGroup>
  ```sh npm theme={null}
  npm install --global @sutro-dev/sutro-cli
  ```

  ```sh pnpm theme={null}
  pnpm add --global @sutro-dev/sutro-cli
  ```

  ```sh yarn theme={null}
  yarn global add @sutro-dev/sutro-cli
  ```
</CodeGroup>

The package installs the `sutro` command.

Requirements:

| Requirement | Value                  |
| ----------- | ---------------------- |
| Node.js     | 22 or later            |
| npm package | `@sutro-dev/sutro-cli` |
| Binary      | `sutro`                |

## Global options

Global options work with every command.

| Option          | Description                                                                             |
| --------------- | --------------------------------------------------------------------------------------- |
| `-V, --version` | Print the CLI version.                                                                  |
| `--json`        | Output machine-readable JSON. For `sutro dev`, output is newline-delimited JSON events. |
| `--debug`       | Print debug details, including API request context and error context.                   |
| `--color`       | Force color output.                                                                     |
| `--no-color`    | Disable color output.                                                                   |
| `-h, --help`    | Show help for a command.                                                                |

Examples:

```sh theme={null}
sutro --version
sutro status --json
sutro publish --debug
```

## Commands

### `sutro login`

Log in to Sutro through the browser and store a local CLI session.

```sh theme={null}
sutro login
```

Options:

| Option      | Description                                       |
| ----------- | ------------------------------------------------- |
| `--no-open` | Print the login URL instead of opening a browser. |

### `sutro logout`

Clear the locally stored CLI session.

```sh theme={null}
sutro logout
```

### `sutro whoami`

Show the currently logged-in user.

```sh theme={null}
sutro whoami
```

### `sutro init`

Link the current folder to a Sutro Project and Application. If no IDs are provided, the CLI creates a new Project and Application.

```sh theme={null}
sutro init --name "Task API"
```

Options:

| Option                  | Description                                                                  |
| ----------------------- | ---------------------------------------------------------------------------- |
| `-n, --name <name>`     | App name used when creating a new Project.                                   |
| `--project-id <id>`     | Link to an existing Project and create a new Application inside it.          |
| `--application-id <id>` | Link to an existing Application. The CLI reads its Project ID automatically. |
| `--entry-file <path>`   | SLang entry file to scaffold and track. Defaults to `app.slang`.             |
| `-y, --yes`             | Accept defaults without prompting.                                           |

`sutro init` writes `sutro.config.json` and creates the entry file if it does not already exist.

### `sutro dev`

Run the linked SLang app in a remote dev session.

```sh theme={null}
sutro dev
```

Options:

| Option       | Description                                                                      |
| ------------ | -------------------------------------------------------------------------------- |
| `--no-watch` | Upload once and keep the remote session alive without watching for file changes. |

`sutro dev` uploads all local `.slang` files under the project root, starts a remote preview, and prints an API URL like:

```text theme={null}
https://dev-<SESSION_ID>.app.withsutro.com/api/latest/
```

While watching is enabled, changes to `.slang` files and `sutro.config.json` trigger a remote reload. Press <kbd>Ctrl</kbd> + <kbd>C</kbd> to stop the dev session.

### `sutro validate`

Validate the linked SLang project without publishing it.

```sh theme={null}
sutro validate
```

The CLI uploads the local source to Sutro and prints compiler diagnostics if validation fails.

### `sutro publish`

Upload the linked SLang project and publish the Application.

```sh theme={null}
sutro publish
```

The command uploads all local `.slang` files, publishes the Application, waits for the published version to become active, and prints the published URL.

Publishing requires a payment method on file.

### `sutro status`

Show the linked Project, Application, entry file, publish state, and published version.

```sh theme={null}
sutro status
```

### `sutro openapi`

Open the published OpenAPI spec in Console.

```sh theme={null}
sutro openapi
```

Options:

| Option         | Description                                                                                                    |
| -------------- | -------------------------------------------------------------------------------------------------------------- |
| `--out [path]` | Save the OpenAPI spec locally instead of opening Console. Defaults to `openapi.json` when no path is provided. |

Examples:

```sh theme={null}
sutro openapi --out
sutro openapi --out ./schema/openapi.json
```

## Exit codes

| Code | Meaning                                                                                    |
| ---- | ------------------------------------------------------------------------------------------ |
| `0`  | Command succeeded.                                                                         |
| `1`  | Runtime, authentication, network, API, validation, or publish failure.                     |
| `2`  | Usage error, such as an unknown flag or missing required input in a non-interactive shell. |

## Automation

Use `--json` when calling the CLI from scripts or AI coding agents:

```sh theme={null}
sutro status --json
sutro validate --json
sutro publish --json
```

`sutro dev --json` writes newline-delimited events because the command keeps running:

```sh theme={null}
sutro dev --json
```

Each event includes an `event` field, such as `session_ready`, `session_update`, or `session_update_failed`.

## Related pages

* [Sutro CLI quickstart](/docs/getting-started/cli-quickstart)
* [Project configuration](/docs/cli/project-config)
* [Introduction to SLang](/docs/SLang/introduction)
