# Install the CLI

Install ons, keep it up to date, install the agent skill, verify and uninstall.

`ons` is the onshore.sh command-line tool. It runs on macOS (Apple silicon and Intel) and on
Linux (x86-64 and arm64). On Windows, use it inside WSL2.

## Install

```bash
curl --proto '=https' --tlsv1.2 -fsSL https://get.onshore.sh/install.sh | sh
```

The script:

1. Picks the build for your system and downloads the newest release.
2. Checks the release before it installs anything: the archive's Sigstore bundle must prove it
   was built and signed by the onshore.sh release workflow, and its SHA-256 checksum must match
   the signed one. If a check fails, nothing is installed.
3. Installs `ons` in `~/.local/bin` and tells you if that directory is not on your `PATH`.
4. Installs the [agent skill](#the-agent-skill) for the coding agents it finds on your machine.
5. Runs `ons login` when you run it in a terminal. In CI, or when no terminal is attached, it
   skips the login.

You can change these with environment variables:

| Variable          | Effect                                                                                                              |
| ----------------- | ------------------------------------------------------------------------------------------------------------------- |
| `ONS_VERSION`     | Install this version, for example `ONS_VERSION=<version>`. By default the script installs the newest stable release |
| `ONS_INSTALL_DIR` | Install into this directory instead of `~/.local/bin`                                                               |
| `ONS_NO_SKILL=1`  | Do not install the agent skill                                                                                      |
| `ONS_NO_LOGIN=1`  | Do not run `ons login`                                                                                              |

```bash
curl --proto '=https' --tlsv1.2 -fsSL https://get.onshore.sh/install.sh | ONS_INSTALL_DIR=<directory> sh
```

`<directory>` is where `ons` goes, for example `/usr/local/bin` (it may need `sudo`).

### macOS

Run the install command in Terminal. It needs `curl`, `tar` and `shasum`, which macOS has.

### Linux

Run the install command in your shell. It needs `curl`, `tar` and `sha256sum` (or `shasum`).

### Windows (WSL2)

Install WSL with Ubuntu once, in PowerShell:

```powershell
wsl --install -d Ubuntu
```

Then run the install command in the Ubuntu terminal. `ons login` prints a page to open:
open it in your Windows browser.

**Homebrew:** coming soon.

### Coming from `msb`

`ons` replaces `msb`, the CLI's former name. `msb update` cannot move you to `ons`: it says it is
up to date. Run the install command above, then log in again: `ons` reads none of `msb`'s
configuration and no `MSB_*` variable.

```bash
ons login
rm ~/.local/bin/msb
```

- Rename the variables you set: `MSB_API_KEY` becomes `ONS_API_KEY`, `MSB_DOMAIN` becomes
  `ONS_DOMAIN`, and so on.
- `ons` keeps its login in `~/.config/onshore`. Once you no longer need `msb`, remove
  `~/.config/minisandbox`. A [Hybrid](https://onshore.sh/docs/guides/hybrid) admin first copies its `pools/` and `trust/`
  directories to `~/.config/onshore`.
- Keys created by `msb login` keep working until you revoke them.

### Behind a proxy or firewall

The install script downloads with `curl`, which uses your `HTTPS_PROXY`. Allow these hosts:

| Host                        | Why                                                                        |
| --------------------------- | -------------------------------------------------------------------------- |
| `get.onshore.sh`            | The script, the release index, the `ons` archive and the signature checker |
| `tuf-repo-cdn.sigstore.dev` | Sigstore's public trust root, which the signature check needs              |

Once installed, `ons` connects directly to `api.onshore.sh`, to your miniVMs' own `*.onshore.sh`
addresses and, for `ons update`, to `get.onshore.sh`: it does not use `HTTPS_PROXY` yet. `ons login` opens `onshore.sh` in your browser.

## Verify before running

`curl | sh` runs the script as soon as it is downloaded. The whole script is one function called on
its last line, so a cut download runs nothing. If you would rather read it first, download it, read
it, then run it:

```bash
curl --proto '=https' --tlsv1.2 -fsSLO https://get.onshore.sh/install.sh
less install.sh
sh install.sh
```

`install.sh` is attested like every release. With the [GitHub CLI](https://cli.github.com), you can
check that our release workflow signed it before you run it:

```bash
curl --proto '=https' --tlsv1.2 -fsSLO https://get.onshore.sh/install.sh.sigstore.json
gh attestation verify install.sh --bundle install.sh.sigstore.json --repo minitap-ai/minisandbox \
  --cert-identity https://github.com/minitap-ai/minisandbox/.github/workflows/release-cli.yml@refs/heads/main \
  --source-ref refs/heads/main --deny-self-hosted-runners
```

## Verify

```bash
ons --version
```

It prints `ons <version>`. Then check that you are logged in:

```bash
ons ls
```

It lists your miniVMs (none yet), or says `not logged in` with the fix: run `ons login`.

## Log in

```bash
ons login
```

`ons` prints a page and a code. Open the page, type the code and approve. A new API key is saved
in `~/.config/onshore/config.toml`, readable only by you.

| Command                    | When                                                                        |
| -------------------------- | --------------------------------------------------------------------------- |
| `ons login`                | You, on your own computer, with a browser.                                  |
| `ons login --paste`        | The browser runs on another machine. Paste the address the browser ends on. |
| `ons login --org <org-id>` | You belong to several organizations. `<org-id>` is the one the key is for.  |
| `ons login --key`          | You have an API key. Paste it at the hidden prompt, or pipe it on stdin.    |
| `ons login --agent`        | An AI agent signs in with its own agent identity. The key lasts 1 hour.     |

In CI, do not log in. Set `ONS_API_KEY` instead:

```bash
export ONS_API_KEY=<your-api-key>
```

`<your-api-key>` is an API key from the console. Store it in your CI's secret store, never in a
file of your repository. There is no `--api-key` flag, on purpose.

## Update

```bash
ons update
```

`ons update` replaces `ons` with the newest signed release, and refreshes the agent skill
wherever it was installed. It refuses to install an older version.

| Command                                            | Effect                                                    |
| -------------------------------------------------- | --------------------------------------------------------- |
| `ons update --check`                               | Print the running and the newest version, change nothing. |
| `ons update --version <version>`                   | Install this version. `<version>` is a release number.    |
| `ons update --version <version> --allow-downgrade` | Install an older version.                                 |
| `ons update --channel stable`                      | Follow the stable channel from now on.                    |

### Switch from an alpha build

If `ons --version` shows a suffix, such as `0.2.0-alpha.3`, you have an alpha build: it follows
the alpha channel and logs in to the development platform, not to onshore.sh. Running the install
script again replaces the binary but keeps that channel and domain. Move to the stable release and
to the managed service:

```bash
ons update --channel stable
ons login --domain onshore.sh
```

The first command installs the newest stable release and keeps you on that channel. The second
signs you in to onshore.sh in your browser and saves it as your domain: keys from the development
platform do not work there.

## The agent skill

The agent skill teaches a coding agent (Claude Code, Codex, OpenCode or any agent that reads
skills) how to use `ons`: always `--json`, never a key on the command line, kill what it creates.
Each `ons` version carries its own skill.

```bash
ons skill install --target claude
```

| Target                      | Where the skill goes                                           |
| --------------------------- | -------------------------------------------------------------- |
| `--target claude`           | `~/.claude/skills/minisandbox-cli`                             |
| `--target agents` (default) | `~/.agents/skills/minisandbox-cli`, read by Codex and OpenCode |
| `--target codex`            | the same place as `agents`                                     |
| `--target opencode`         | OpenCode's own skills directory                                |

- `--project` installs into the current directory instead (`./.claude/skills/…`), to commit it
  with your project.
- `--dir <skills-dir>` installs into any other skills directory. `<skills-dir>` is that
  directory.
- `ons skill show` prints the skill. `ons skill path --target <target>` prints where it goes.

`ons skill ls` lists the skill of each agent with the `ons` version that wrote it, and says
`current` or `stale`. `ons skill update` rewrites the stale ones; `ons update` runs it for you.

## Uninstall

Remove the binary and your saved login:

```bash
rm ~/.local/bin/ons
rm -r ~/.config/onshore
```

Use the directory you installed into if you set `ONS_INSTALL_DIR`. Then remove the skill for each
target you installed, for example `rm -r ~/.claude/skills/minisandbox-cli` and
`rm -r ~/.agents/skills/minisandbox-cli`.

The API key `ons login` created stays valid until you revoke it: open **API keys** in the
console and click **Revoke** on the key named `msb login · <host>`, where `<host>` is your
computer's name.

## Troubleshooting

- **`ons: command not found`**: add the install directory to your `PATH`, for example
  `export PATH="$HOME/.local/bin:$PATH"` in your shell profile.
- **`not logged in`**: run `ons login`, or set `ONS_API_KEY`.
- **A check of the release fails**: do not install it. Write to
  <support@onshore.sh>.
- **Any error**: every `ons` error names what went wrong and the next step. Add `--json` to get
  it as `{"ok": false, "errors": [{"message": …, "fix": …}]}`.

Markdown version: https://onshore.sh/docs/install-cli.md
