# Connect the CLI

> Let your agent do it: Run a sandbox from the shell with the Hermitbox CLI. If it isn't installed: on the machine that runs Hermitbox, use the one-command installer as my ordinary user, never with sudo; on another Linux machine (x64 or arm64) that uses a Hermitbox installed elsewhere, install only the CLI from npm as the page shows. The CLI reads the saved credentials automatically on this machine; on another machine, set `HERMITBOX_API_URL` and `HERMITBOX_API_KEY` in the shell's private environment, never in a file or this chat. Run the page's quickstart and sleep-and-wake blocks and show me their output. Follow the exact steps in https://docs.hermitbox.dev/v0.3.2/get-started/cli.md.

Run any command in a fresh sandbox from your shell, or keep a sandbox and work in it step by step.
If the CLI isn't installed yet, run the [one-command installer](https://docs.hermitbox.dev/v0.3.2/get-started/install.md).

To use a Hermitbox installed elsewhere from another Linux machine (`x86_64` or `aarch64`, which npm
calls x64 and arm64), install only the CLI, from npm:

```sh
npm install -g @hermitbox/cli
```

## Quickstart

```sh
hermitbox run -- echo hello
```

`hermitbox run` creates a sandbox, runs the command in it, prints `hello` and deletes the sandbox.
On the machine where you installed Hermitbox, the CLI uses the saved credentials by itself. From
another machine, set `HERMITBOX_API_URL` and `HERMITBOX_API_KEY`.

## Sleep and wake with state kept

A sandbox you keep holds its files while it sleeps. Create one, write a file in its data
directory, put it to sleep, wake it and read the file back:

```sh
id=$(hermitbox sandbox create | jq -r .id)
hermitbox sandbox exec "$id" -- sh -c 'echo "saved before sleep" > notes.txt'
hermitbox sandbox sleep "$id"
hermitbox sandbox wake "$id"
hermitbox sandbox exec "$id" -- cat notes.txt
hermitbox sandbox rm "$id"
```

Output includes:

```txt
saved before sleep
```

See the [CLI reference](https://docs.hermitbox.dev/v0.3.2/reference/cli.md) and
[host boundaries](https://docs.hermitbox.dev/v0.3.2/hosting.md#tiers-and-guarantees).
