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

# CLI

> Use Fibre from your terminal: install one program, sign in, start sandboxes, run commands with their output live, open a shell, and copy files in and out. Every command also speaks JSON for scripts and agents.

The Fibre CLI is a single program called `fibre`. It lets you do from your terminal everything you would otherwise
do with the API or an SDK: start a sandbox, run commands in it and watch their output, open an interactive shell,
copy files and folders in and out, and clean up afterwards. It is just as useful in scripts and CI, and for coding
agents, because every command can print its result as JSON.

## Install

The CLI is a standalone program, so you do not need Node.js or anything else installed. Run the command for your
system:

```bash title="macOS and Linux" norun reason="installs on your own machine" theme={null}
curl -fsSL https://fibre.dev/install.sh | sh
```

```powershell title="Windows" norun reason="installs on your own machine" theme={null}
irm https://fibre.dev/install.ps1 | iex
```

```bash title="npm" norun reason="installs on your own machine" theme={null}
npm install -g @fibre-dev/cli
```

The install scripts download the right program for your system and **check its SHA-256 checksum** before
installing it, so a damaged or altered download is never installed. Check that it works:

```bash title="Terminal" run theme={null}
fibre --version
```

> [accordion] Output
>
> ```text title="output" expected theme={null}
> 0.1.0
> ```

## Sign in

The CLI needs an API key, just like the SDKs. Run `fibre login`, create a key in the dashboard under **API keys**,
and paste it when asked. The CLI checks the key with Fibre and saves it for the next commands, in a file only you
can read.

```bash title="Terminal" norun reason="asks for your own key" theme={null}
fibre login
```

In CI and scripts, there is nothing to save: set the `FIBRE_API_KEY` environment variable and every command uses
it. `fibre whoami` shows which key and account the CLI is using.

## Start a sandbox and work in it

`fibre create` starts a sandbox and prints its details. It accepts the same options as the API, written as flags:
`--size`, `--image`, `--label`, `--lifetime`, `--idle-timeout` and more. Here we ask for JSON, so a script can read
the ID:

```bash title="Terminal" run capture=SBX=.id theme={null}
fibre create --label project=docs --lifetime 20m --json
```

> [accordion] Output
>
> ```json title="output" expected theme={null}
> {
>   "id": "…",
>   "status": "running",
>   "runtime": "standard",
>   "labels": {
>     "project": "docs"
>   }
> }
> ```

**`fibre exec` runs a command in the sandbox as if it ran on your machine.** Its output appears in your terminal
as it is written, and `fibre exec` exits with the command's own exit code, so it works in scripts and in `&&`
chains. Put the command after `--`:

```bash title="Terminal" run theme={null}
fibre exec "$SBX" -- python3 -c "import platform; print('hello from', platform.system())"
```

> [accordion] Output
>
> ```text title="output" expected theme={null}
> hello from Linux
> ```

A few more things you can do with a running sandbox:

| You want to | Command |
| - | - |
| Open an interactive shell | `fibre shell <id>` |
| Pass your input to a command | `cat data.csv \| fibre exec <id> -i -- python3 load.py` |
| Run something in the background | `fibre exec <id> --detach -- npm run build`, then `fibre logs <id> <command-id> -f` |
| Keep a server running, even across sleep | `fibre exec <id> --detach --keep -- node server.js` |
| See its public address, or open it | `fibre url <id>`, `fibre open <id>` |

## Copy files in and out

`fibre cp` copies a file or a whole folder. Write the sandbox side as `<id>:/path`:

```bash title="Terminal" run theme={null}
mkdir -p demo && echo "print('copied in')" > demo/main.py
fibre cp demo "$SBX:/work/demo"
fibre exec "$SBX" -- python3 /work/demo/main.py
```

> [accordion] Output
>
> ```text title="output" expected theme={null}
> copied in
> ```

Copying out works the same way, with the sandbox first: `fibre cp <id>:/work/report.json .`

## Run one command in a fresh sandbox

When you only need a sandbox for one command, `fibre run` does it all: it starts a sandbox, runs the command with
its output live, and exits with the command's exit code. With `--rm`, it deletes the sandbox afterwards.

```bash title="Terminal" run theme={null}
fibre run --rm -- python3 -c "print(sum(range(101)))"
```

> [accordion] Output
>
> ```text title="output" expected theme={null}
> 5050
> ```

## Clean up

```bash title="Terminal" run theme={null}
fibre delete "$SBX"
rm -rf demo
```

## For scripts and agents

Three things make the CLI easy to use from code:

* **`--json` works on every command.** The result is printed as JSON, and so are errors, under `"error"`.
* **Exit codes are stable:** `0` success, `1` a failure, `2` a usage error, `3` an API error, `4` not signed in or
  a rejected key. `fibre run` and `fibre exec` exit with the command's own code.
* **There is no colour or animation** when the output is not a terminal, or when `NO_COLOR` is set.

To let a coding agent use sandboxes through tools instead of commands, add Fibre's MCP server to it: see
[MCP server and skill](https://docs.fibre.dev/build-with-ai/mcp-server.md).

## All commands

| Command | What it does |
| - | - |
| `fibre login`, `logout`, `whoami` | Sign in with an API key, sign out, show the account in use |
| `fibre create` | Start a sandbox |
| `fibre list`, `get`, `update`, `delete` | Find, inspect, change and delete sandboxes |
| `fibre run -- <cmd>` | Start a sandbox and run one command in it |
| `fibre exec <id> -- <cmd>` | Run a command in a sandbox |
| `fibre shell <id>` | Open an interactive shell |
| `fibre cp <from> <to>` | Copy files and folders in and out |
| `fibre commands`, `logs`, `kill` | Background commands: list them, read their output, stop them |
| `fibre url`, `open`, `browser`, `desktop` | Addresses and links |
| `fibre snapshot create`, `list`, `delete` | Snapshots |
| `fibre secret set`, `list`, `delete` | Secrets; give one to a command with `fibre exec --secret NAME` |
| `fibre key create`, `list`, `revoke` | API keys |
| `fibre usage` | Your spending and your plan's limits |
| `fibre mcp add <agent>`, `mcp config` | Give a coding agent Fibre's tools: see [MCP server and skill](https://docs.fibre.dev/build-with-ai/mcp-server.md) |
| `fibre skill install` | Install the Fibre skill for your coding agents |

`fibre <command> --help` describes every option.


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