# Use the CLI

```
openprogram --print "Summarize what the python files in this directory do"
```

Prints one reply and exits, without the TUI. The conversation is saved and can be continued in the Web UI or TUI.

| Worker for the profile | Runs in | Has |
| --- | --- | --- |
| Running (Desktop App, `openprogram worker start`, foreground `openprogram web`) | That worker, live in its Web UI session | Built-in browser, channel bridges, the session's settings |
| None, or `--standalone` (`OPENPROGRAM_PRINT_IN_PROCESS=1`) | This process | Neither browser nor channels |

| On the worker | Result |
| --- | --- |
| Follow-up question | Printed on stderr and answered in the terminal. With no terminal the turn continues unanswered. |
| Ctrl-C or SIGTERM | Stops the turn on the worker, as the Web UI's stop button does, and waits up to 30 seconds for it to end (2 seconds once a second signal comes); exit code 130, or 143 for SIGTERM. A worker restart during that wait does not lose the stop: the command reconnects and stops the turn on the worker that comes back. If the worker did not confirm the stop, stderr says the turn may still be running |
| Stopped in the Web UI | `[cancelled]` on stderr, exit code 130; the partial reply stays in the session |
| Worker error | Printed to stderr, exit code 1 |
| Worker restart (deploy, update) | The command reconnects and follows the same turn to its end |
| No worker back within three minutes, or the turn was interrupted | The command says so; the Web UI session shows where it stopped |

Piped input goes along with the prompt as a `<stdin>` block; `-p` is short for `--print`, and with no prompt the prompt itself comes from stdin:

```
cat <file> | openprogram -p "Review this code"
echo "Summarize the README" | openprogram -p
```

`--json-schema PATH` requires output matching a JSON Schema; `-` reads the schema from stdin.

## Resume a session

```
openprogram sessions list
openprogram --resume <session-id> --print "Given last time's conclusion, what is the next step"
```

Without `--print`, `--resume` opens that session in the [TUI](https://fzkuji.github.io/OpenProgram/docs/interfaces/tui.html).

## Isolate an environment

```
openprogram --profile ci --print "..."
```

`--profile <name>` moves config, sessions and credentials to `~/.openprogram-<name>/`. Environment variable: `OPENPROGRAM_PROFILE`.

## Other scriptable commands

```
openprogram sessions list
openprogram providers list --json
openprogram providers discover --json
openprogram status
openprogram programs run <name> --arg key=value
```

Most subcommands support `--json`. `openprogram -h` and each subcommand's `-h` give the full list.
