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

# `archil` npm CLI

> Reference for the Node CLI that signs in, manages sandboxes and disks, opens desktops, and connects over SSH.

The [`archil`](https://www.npmjs.com/package/archil) npm package ships the `archil` command for managing sandboxes and
disks from any machine with Node.js 22.19 or later. Run it with `npx archil`, or install it with `npm install -g archil`.

```bash theme={null}
npx archil <command> [options]
```

It's a different program from the [Linux `archil` client](https://docs.archil.com/reference/archil-cli) that mounts disks, but both answer to
`archil`. When the npm CLI receives a mount command it doesn't handle, such as `archil mount` or `archil unmount`, it
passes the command to the Linux client. If the Linux client comes first on your `PATH`, run the commands on this page
with `npx archil`.

## Sign in

```bash theme={null}
npx archil login     # opens the Archil console to approve this machine
npx archil whoami    # shows the account, profile, and region in use
npx archil logout    # deletes the saved profile and key from this machine
```

`archil login` opens the console in your browser. After you approve, the console creates an API key named
`CLI on <hostname>` and hands it to the CLI, which saves it as a profile and makes it the default. Pass `--no-browser`
to print the link instead of opening it. `logout` removes the key from this machine. To revoke the key itself, delete
it under **API Keys** in the console.

Without a browser, such as in CI or over SSH, set `ARCHIL_API_KEY` and `ARCHIL_REGION`, or save a key with
`archil profile create`:

| | Env var | Flag |
| - | - | - |
| API key | `ARCHIL_API_KEY` | `-k`, `--api-key` |
| Region | `ARCHIL_REGION` | `-r`, `--region` |
| Profile | `ARCHIL_PROFILE` | `--profile` |

Flags take precedence over environment variables, which take precedence over the selected profile. Manage profiles
with `archil profile create`, `list`, `use`, and `delete`.

## Sandboxes

Commands accept an exact sandbox ID or a unique name. Lifecycle commands wait for the sandbox to settle; pass
`--no-wait` to return once the request is accepted.

```bash theme={null}
npx archil sandbox create dev --vcpu-count 4 --mem-size-mib 8192 --env NODE_ENV=development
npx archil sandbox list
npx archil sandbox get dev
npx archil sandbox pause dev
npx archil sandbox resume dev
npx archil sandbox stop dev
npx archil sandbox start dev
npx archil sandbox fork dev agent-task
npx archil sandbox wait dev --status running --timeout 60
npx archil sandbox delete dev
```

`create` also accepts `--base-image`, `--max-ttl-seconds`, `--idle-ttl-seconds`, `--on-timeout pause|delete`, and
`--max-concurrent-processes`.

### Run commands and open shells

```bash theme={null}
npx archil sandbox run dev -- sh -c 'echo "$NODE_ENV"'
npx archil sandbox shell dev
```

`run` streams output and exits with the remote command's exit code. Put `--` before the command so its flags aren't
parsed as CLI options. In a `shell`, `Ctrl+]` is the emergency escape.

### Desktops

```bash theme={null}
npx archil sandbox create my-desk --desktop
npx archil sandbox desktop my-desk             # private, in your browser, until Ctrl-C
npx archil sandbox desktop my-desk --share     # prints a public link
npx archil sandbox desktop my-desk --unshare   # invalidates links and disconnects viewers
```

`desktop` also accepts `--port` for the local port and `--no-open` to print the URL without opening a browser. See
[Desktops](https://docs.archil.com/compute/sandboxes/desktops.md).

### SSH and port forwarding

```bash theme={null}
npx archil sandbox ssh dev
npx archil sandbox ssh-config --install        # then: ssh, scp, rsync, or VS Code to dev.archil
npx archil sandbox forward dev 3000            # http://127.0.0.1:3000, privately, until Ctrl-C
```

See [SSH and port forwarding](https://docs.archil.com/compute/sandboxes/ssh-and-ports.md).

## Disks

`archil disk` takes the same commands as the [`disk` CLI](https://docs.archil.com/reference/disk-cli):

```bash theme={null}
npx archil disk create my-disk
npx archil disk list
npx archil disk dsk-abc123 exec "ls -la"
npx archil disk grep "ERROR" dsk-abc123/logs
npx archil disk api-keys list
```

## Output and scripting

In a terminal, commands show progress and print tables. When stdout is piped, `list`, `get`, `create`, and the
lifecycle commands print JSON instead; pass `-o table` or `-o json` to choose. Progress and errors go to stderr. Set
`NO_COLOR` to turn colors off.

The standalone `disk` and `sandbox` executables in the [`disk`](https://www.npmjs.com/package/disk) package take the
same commands and keep their original output: tables unless you pass `-o json`, and `Error (<status>): <message>`
errors.

## Shell completion

```bash theme={null}
source <(archil completion zsh)    # add to ~/.zshrc
source <(archil completion bash)   # add to ~/.bashrc
archil completion fish > ~/.config/fish/completions/archil.fish
```

Completion covers commands, options, profile names, and your sandbox names.


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