# CLI

Needs Node.js 22.12 or later. Install it from your console, under **Agent setup → Copy command**. See [Quickstart with a terminal](https://boring-cloud.app/docs/quickstart.md).

Agents should add `--json` to every command: the answer is then JSON on standard output. Refusals of the platform are also JSON, `{ "error": { "code", "message", "details", "requestId" } }`. Wrong use of the command is explained on standard error.

## Commands

| Command                                                         | What it does                                                                         |
| --------------------------------------------------------------- | ------------------------------------------------------------------------------------ |
| `setup --url <console>`                                         | sign in and install the command                                                      |
| `login [--url <console>] [--token-stdin]`                       | store a token. It is never shown                                                     |
| `logout`                                                        | remove the stored token                                                              |
| `whoami`                                                        | person, workspace and permissions                                                    |
| `guide [--out AGENTS.md]`                                       | what this workspace approved. Read it first                                          |
| `init --template <name> [dir]`                                  | copy a starter into an empty folder: `team-tracker`, `web-research` or `hello-world` |
| `pack [--dir .] [--out release.json]`                           | check and package the build without deploying                                        |
| `apps list`                                                     | apps you can see                                                                     |
| `apps create --name <name> [--description <text>]`              | create an app, private to you                                                        |
| `app status --app <id>`                                         | URL, status, access and current version                                              |
| `app open --app <id>`                                           | print the URL. It does not open a browser                                            |
| `deploy --app <id> [--dir .]`                                   | package what the manifest names, and deploy it                                       |
| `deployments list --app <id>`                                   | releases, newest first                                                               |
| `rollback --app <id> --to <deployment-id>`                      | make an earlier release live. Data does not go back                                  |
| `share --app <id> --email <email> [--role <viewer or manager>]` | give access to one member                                                            |
| `share --app <id> --workspace`                                  | give access to every member                                                          |
| `revoke --app <id> --user <user-id>`, or `--workspace`          | remove access                                                                        |
| `mcp`                                                           | a local MCP server with the same tools as the remote one                             |

`deploy` and `pack` never run your build. Run it before, and check that the files named in [`boringcloud.json`](https://boring-cloud.app/docs/manifest.md) are up to date.

Use `--workspace-id <id>` with `apps list`, `apps create` and `guide` to name a workspace. A token belongs to one workspace, so this is rarely needed.

## Exit codes

| Code | Meaning                                                         |
| ---- | --------------------------------------------------------------- |
| 0    | done                                                            |
| 1    | refused or failed for another reason, for example no permission |
| 2    | wrong use: unknown command or missing option                    |
| 3    | not signed in, or the token ended                               |
| 4    | the files or values are not valid. Fix them before trying again |
| 5    | the deployment failed. The previous release is still live       |

## Environment

| Variable             | Use                                      |
| -------------------- | ---------------------------------------- |
| `BORINGCLOUD_TOKEN`  | token. It wins over the stored one       |
| `BORINGCLOUD_URL`    | console address                          |
| `BORINGCLOUD_CONFIG` | path of the file that stores the sign-in |

## In CI

```bash
export BORINGCLOUD_URL=https://console.boring-cloud.app   # and BORINGCLOUD_TOKEN from the secrets of the CI
npm ci && npm run build
boringcloud deploy --app "$APP_ID" --dir . --json
```
