The flow command
Everything in this Book is done with one program, flow. This page describes it as it is today, in the four groups flow --help uses, so you can find a command by what you want to do. The exact rules a command follows live in the Reference, in Running a program, and each section below links to the part it depends on. flow <command> --help lists every option.
Most of the commands deal with a run's record, the file on disk that holds the run's input and every answer it was given. The Run commands start runs and add to their records, the Look at runs commands only read records, Write and check works on source code and never touches a run, and Setup looks after the installation and what it may start.
Check, run, resume and replay
The manager's approval from Waiting for the manager makes a short tour. In the project's 3-manager-answers-tomorrow folder, check the program first:
flow check main.flow✓ main.flow main(order: Text, dollars: Int) -> Text · 1 Tool: tools.ask_managerStart a run. ask_manager's library posts every question it gets to tools/questions.txt and holds the call for a person to answer, so the run waits at the first one and the command exits with status 3:
flow run main.flow order=A-1042 dollars=40run da0845eccb67da0845eccb67 waiting: every open call waits for a replyopen root#1, held by its implementation key: da0845eccb67da0845eccb67da0845ec/root#1 tools.ask_manager arguments: {"question":"Refund 40 dollars on A-1042?"}reply details: flow show da0845eccb67 'root#1'next: flow show da0845eccb67flow runsda0845eccb67 waiting main.flow … 1 call heldThe answer goes to the library, not to flow: the library's answer.py saves it under the call's key, and flow resume with --resend asks the held call again in a new process, so the library can return it. An answer the library can't read as the call's type is not an answer: it logs why and holds again, and the run waits as before:
python3 tools/answer.py 'da0845eccb67da0845eccb67da0845ec/root#1' '"Maybe"'flow resume da0845eccb67 --resend 'root#1'› "Maybe" is not an answer: 'Maybe' is not a constructor of Approve | Denynote: Open calls were selected for resend. The original call ID does not guarantee external deduplication; an external effect may happen again.da0845eccb67 waiting: every open call waits for a replyopen root#1, held by its implementation…python3 tools/answer.py 'da0845eccb67da0845eccb67da0845ec/root#1' '"Approve"'flow resume da0845eccb67 --resend 'root#1'Approved: refund 40 dollars on A-1042note: Open calls were selected for resend. The original call ID does not guarantee external deduplication; an external effect may happen again.da0845eccb67 completednext: flow replay da0845eccb67flow replay da0845eccb67Replay da0845eccb67: matchedNo tools were called.Write and check
| Command | What it does |
|---|---|
flow new FILE.flow |
Creates a program with a main and a @test. A Tool library is created by its toolkit instead, with flow-toolkit-python new DIR or flow-toolkit-rust new DIR, with one Tool and its contract already built. |
flow check FILE |
Checks a program without running it, and prints main's inputs, its result and the Tools it can reach. -v adds each Tool's identity and the program's functions. --fix makes the repairs the checker is sure of. Exits 2 if it doesn't check. |
flow test [PATH…] |
Runs the @test functions in the files it is given, with fakes in place of Tools, and replays saved runs. With no path, it searches the current directory. See Testing. |
flow fmt [PATH…] |
Formats source in place. --check changes nothing and names the files that aren't formatted. With no path, it formats standard input. |
flow build [PATH] |
Writes a library's contract, contract/lib.flow, from its Python or Rust code. --check only reports a contract that is out of date. |
flow doc FILE… |
Writes documentation from /// comments, for the program and the libraries it uses. --all adds the standard library. |
flow explain CODE |
Explains a diagnostic, such as flow explain non-exhaustive-match. |
Run
| Command | What it does |
|---|---|
flow run FILE KEY=VALUE… |
Starts a run at main, or at the pub flow that --entry NAME names. Each KEY=VALUE gives one parameter: a Text one as written, any other in the value notation, and an Option one, or one with a default, can be left out. To give a parameter the contents of a file, let the shell read it: plan="$(cat plan.txt)". The result is printed on standard output for people to read, and --json prints it as JSON. --name NAME gives the run a name that later commands accept in place of its id. See Entry. |
flow resume RUN [FILE] |
Continues an open run: one that waits for answers, stopped, or whose process died, handing it every answer its record holds. It continues on FILE, or on the file the run was started from, so an edited program picks up where the run is, provided it makes every recorded call the same way; an open call it would replace is listed first, and --drop naming exactly those calls says yes ahead of time. --resend CALL asks an open call again under the same key, and a bare --resend asks every open call that isn't held. With --from N it starts a new run from a copy of the run's facts 1 to N instead, and leaves the original as it was. See Resume, Open calls and Forks. |
flow logs RUN |
Prints what the run's Tools logged, which is kept beside the record but is not part of it. -v adds debug lines and which Tool and call wrote each line. |
A call's id, such as root#1, is printed on the open line of a waiting run; copy it from there rather than guessing it.
A call that was out when the run's process died may or may not have reached the other side. flow resume never sends it again unless you pass --resend, which sends it again under the same id. Use --resend only when the Tool can recognise a repeated call, or when doing the work twice is harmless. A payment that timed out and When the process dies mid-call show both choices, and Open calls has the rule.
Binding Tools
Every Tool a program can reach needs something to answer it before a run can start, and flow run refuses with tool-unbound when one doesn't. A library whose flow.toml names its implementation, as the Python libraries in this Book do, binds itself. A library in your own project starts without asking; code from a library fetched from elsewhere has to be approved once first, with flow approve. No option on the command line binds a Tool, so flow resume finds the same libraries the run started with.
A Tool that waits on a person holds its call: it promises to answer later, and the call stays open, with the run waiting on it, until the library answers it. Every answer from outside a run comes through a Tool's library this way, either when the run asks the call again or, for a run in the default store, by the call's key (Answering calls from your own service says when each works). People and webhooks builds such a library.
Look at runs
None of these commands calls a Tool or changes a run.
| Command | What it does |
|---|---|
flow runs |
Lists the runs in the store with their state. A run whose process died prints no id when it stops, so this is how you find it again. |
flow show RUN [CALL] |
Prints the run's record: how it stands, each open call with the command that answers it, and its latest entries. --all shows every entry, --kind Call only the calls, and --fact N one entry. Given a call's id, it prints that call, its type and its answer. --tui opens the record in a terminal browser. |
flow replay RUN |
Runs the program stored in the record again, answering every call from the record, and says matched or where the two differ. See Replay. |
flow runs export RUN --out DIR |
Copies a run, with every source file it used, to a new directory. flow test DIR then replays it as a test. |
flow runs import DIR |
Adds an exported run to the store. |
flow runs delete RUN --yes |
Removes a stopped run and everything stored with it. Without --yes it asks first. |
Setup
| Command | What it does |
|---|---|
flow approve FILE |
Lists the code from fetched libraries that the program can start, and asks once whether to allow it. --yes approves without asking, for CI. A library in your own project is never asked about. |
flow update FILE |
Accepts a library tag that has moved since the program first used it. |
flow doctor |
Says which installation is in use and where it keeps things. |
flow daemon |
Starts, stops or installs the per-user host that every live run runs under. flow run starts it when it is not running. |
flow mcp |
Offers checking, running, resuming and reading records to an MCP client, over standard input and output. |
flow completions SHELL |
Prints a completion script for bash, zsh, fish, elvish or PowerShell. |
The Reference also describes two commands this CLI doesn't have yet: flow attach and flow stop.
Where runs are kept
Every run is kept in runs inside FLOW_HOME, which is ~/.flow unless you set it, and every command reads that one store. To keep a set of runs apart from the rest, give their commands a FLOW_HOME of their own.
Exit status
| Status | Means |
|---|---|
| 0 | done |
| 4 | completed with Err: the entry's result is an Err |
| 3 | open: the run stopped, or waits only for replies |
| 2 | refused, and nothing was started, recorded or changed: a compile error, an unbound Tool or one whose implementation does not fit its contract, a library that fails to start, bad input, a name in use |
| 1 | the answer is no, such as a failed test or a replay that does not match; or the store or the reference host failed |
| 130 | Ctrl-C stopped a command that drives no run. A command attached to a run returns 3. |
Only a completed run has ended. Everything else that happens to a run, whatever its cause, leaves it open, and the command prints why it stopped.
Status 2 covers many different refusals. A script that has to tell them apart should pass --json and read the diagnostic's code, such as run-ended or tool-unbound, instead of the status. How a run ends gives the rule.
Output for programs
--json, before or after the command name, prints one JSON document on standard output instead of text, whether the command succeeds or fails: flow --json run …. What the command produced is under data, and why it failed under errors, with data null when it produced nothing. flow help json lists every key. NO_COLOR=1 or --color never turns colour off. The CLI contract fixes the JSON document, and the flow command describes the text.
Three more options also go anywhere on the command line. -q prints only the result and any errors, with no status lines, call lines or suggested commands. -v adds detail, such as debug log lines and where each one came from. Neither changes the --json document. --no-input, or FLOW_NO_INPUT=1, means the command never asks a question: one that would ask is refused instead, and names the option that answers ahead of time, such as flow runs delete's --yes. flow help environment lists these and every environment variable.