# CLI commands

> Documentation version: 3.0
> HTML: https://docs.flarelive.manifolddynamics.com/reference/api/cli.html
> [Complete contents](https://docs.flarelive.manifolddynamics.com/contents.md) · [Agent index](https://docs.flarelive.manifolddynamics.com/llms.txt)

The command-line program is `flare-live-cli` (`flare-live-cli.exe` on Windows). A Linux AppImage accepts `--cli` before these arguments. Use `--help` for the options in your installation.

## Start and discover instances

For ordinary scripted work, start a GUI or headless instance and connect using [flarelive-client](https://docs.flarelive.manifolddynamics.com/manual/operation/rpc.md).

```text
flare-live-cli --version
flare-live-cli instances
flare-live-cli serve
flare-live-cli serve --project robot.fll
```

`serve` owns a persistent headless instance and prints its readiness information. For a new scene, it uses the current directory as the working directory. `--project` loads an FLL; `--workdir /path/output` sets the working directory explicitly. See [running modes](https://docs.flarelive.manifolddynamics.com/manual/operation/index.md#running-modes).

Add `--json` before a command when a machine-readable response is needed. For selecting among several running processes, see [Multiple instances](https://docs.flarelive.manifolddynamics.com/manual/operation/rpc.md#multiple-instances).

`--simulation-io` on `serve` starts the legacy flcpy listener on localhost. `--io-port` and `--io-allow-remote` require it. See [legacy flcpy](https://docs.flarelive.manifolddynamics.com/manual/operation/messaging.md) for its connection and migration rules.

## Embedded script jobs (advanced)

These commands execute scripts inside Flare Live's bundled interpreter. General application and simulation scripts should use RPC. Embedded execution is useful when you need [GUI control or application-window capture](https://docs.flarelive.manifolddynamics.com/reference/api/gui.md).

```text
flare-live-cli run task.py
flare-live-cli exec task.py
flare-live-cli exec task.py --detach
flare-live-cli status --job JOB
flare-live-cli stop --job JOB
```

`exec` sends source to an existing instance. `run` creates a one-shot headless instance and closes it after the script completes. Their positional file is **Python source**. The interpreter provides `flarelive.current_workspace()` for that instance's Workspace. `exec -` reads source from stdin; arguments after `--` reach the script.

Script jobs and Workspace Operations have separate IDs/status APIs. Detached submission is not completion. Poll the original job, inspect terminal state/output and truncation; stop is cooperative, not killing the host. Stop --job does not shut down serve. Interrupt your own serve process when finished.

## Activation and exit codes

Exit codes: 0 success, 2 command/input, 3 instance selection, 4 IPC/protocol, 5 script/listener failure, 6 cancelled/non-running job, 7 activation failure. Account/login/activate/logout are separate user-scoped commands; see [activation](https://docs.flarelive.manifolddynamics.com/manual/installation-and-activation.md).
