# 06 · Driving Blackbird From Programs

> Canonical HTML: https://multiplayer.tech/blackbird/other-programs/
> Manual Index: https://multiplayer.tech/blackbird/index.md

Hand Blackbird work from shell scripts, CI, or other agents with `--once`, or drive a long-lived stateful session over framed binary stdio pipes with `--application`.

## One-Shot Commands (`--once`)
```bash
blackbird --once 'Inspect this project and explain its build.' --effort medium
```
- Runs one turn in plain mode and exits.
- Displayed reply goes to `stdout`; session path, status lines, tool outcomes, and warnings go to `stderr`.
- Pass `--session DIRECTORY` to reuse a session (one process per session), and pass an `--effort` supported by your provider.
- `SIGTERM` stops cleanly with exit status `143`.
- Runs with full user tools and zero confirmation prompts.

## The Application Interface (`--application`)
```bash
blackbird --application
```
- Exchanges 4-byte big-endian length-prefixed `BBM2` packets (magic bytes `42 42 4d 02`, sizes 5 to 4,194,304 bytes) over `stdin`/`stdout`; diagnostics go to `stderr`.
- Malformed, oversized, or truncated frames close the connection immediately.
- **Commands you send:** `open` (first, replies `ready`), `turn` (`id`, `objective`, optional `observations`), `steer` (cancel + replace), `cancel`, `close` (flushes, emits `closed`, exits).
- **Events you receive:** `text`, `status`, `final` (`completed`, `cancelled`, `failed`), `error` (`message`, `final_follows`).
- **Drain `stdout` continuously:** Stopping reads can stall cancellation; closing `stdin` cancels active work.
- Full spec: https://github.com/antimemeai/blackbird/blob/master/docs/APPLICATION_INTERFACE.md
