flow-cli
Drive a running Flow app from a shell or an agent with flow-cli, with every subcommand, its flags and examples.
On this page
flow-cli talks to a running Flow app over its command bus, a local socket. Anything the command palette can do, flow-cli can do: open sessions and tabs, type into panes, read what a pane shows, change settings, take screenshots. It is how scripts and coding agents drive Flow.
Install flow-cli
Flow ships flow-cli inside the app. To put it on your PATH:
- Open Settings › Advanced › Command-line tools and click the flow-cli, drop and ghx button, or run Install command-line tools… from the command palette (
⇧⌘P). - Flow links
flow-cli,drop,ghx,gitxandsinkinto/usr/local/bin, asking for your administrator password once if it has to.
Each link points into the installed app, so the tools update with Flow. Flow never replaces a file at that path that isn't its own: it skips it and says so. Set FLOW_CLI_INSTALL_DIR to install into another directory. When you run Flow from its app bundle (not straight from the disk image), it offers the install once.
Quick start
flow-cli ping # is the app answering?
flow-cli --help # every command
flow-cli new-session ~/src/app --layout dev # a new session with a saved profile
flow-cli read panes # every pane: session id, session, title, process
flow-cli send-text --session 42 --enter "npm test"
flow-cli read pane 42 --lines 200 # what that pane shows, with scrollback
flow-cli action toggle_dashboard # any action, by name
flow-cli screenshot ~/Desktop/flow.png
Which app it talks to
flow-cli picks the socket in this order:
--socket PATH, when given.$FLOW_SOCKET. Flow sets it in every pane it starts, soflow-clirun inside a Flow terminal always talks to that app.~/.flow/bus.sock.- Otherwise the most recently modified
~/.flow/worktrees/*/bus.sock.
With several Flow windows open, a command acts on the workspace window you brought forward last.
Options, output and exit codes
| Option | Meaning |
|---|---|
--socket PATH | Talk to this socket. |
--timeout SECS | How long to wait for a reply. Default 10 seconds (longer for a few commands: 20 for record stop, 90 for new-session --device and puddle-mount, 60 for puddle-unmount). |
-h, --help | Print every command. flow-cli read alone lists the read commands. |
-- | Ends the flags: every word after it belongs to the command, even one that looks like a flag. |
Replies print as pretty JSON, except where plain text reads better: read pane prints the pane's lines, read panes and read tasks print one row per line, screenshot prints the file's path, and schedule-add prints the new id. Add --json to read, state, commands, ping, sync, shells, factory, record and schedule-add for raw JSON instead.
| Exit code | Meaning |
|---|---|
| 0 | Done. |
| 1 | The app refused the command; the message is on stderr after error:. |
| 2 | No app answered on the socket. |
| 64 | The command line was wrong; the usage follows on stderr. |
Commands that name a session take its name (--group NAME, or a GROUP argument). Commands that name a pane take its session id, which read panes and state list. Read commands never change focus, the page or a pane's scroll position, so an agent can call them freely.
Note: While Flow shows its license screen, the bus answers read commands only.
Basics
| Command | What it does |
|---|---|
ping | Check that the app answers. |
state | Print the app state as JSON: windows, groups, tabs, pages and more. |
commands | List every bus command. |
action <name> | Run a named action, the same as its shortcut or palette row (for example split_right). Names are listed in Keybindings. |
raw '<json line>' | Send one raw JSON command line to the bus. |
Sessions and tabs
| Command | What it does |
|---|---|
new-session <cwd> [--base <ref>] [--layout <name>] [--background] [--host <dest>] [--device <device> [--label L]] | Open a new session in a directory. --base forks from a ref, --layout applies a workspace profile, --background leaves the active session and page alone. --host (or a dest:path / ssh://dest/path directory) opens it on an ssh host; --device creates it on a paired device. |
new-tab [--group <g>] [--tile <id>] [--background] | Open a terminal tab in a tile (default: the active session's focused tile). --background changes no focus, page or active tab. |
new-files-tab [--group <name>] | Open a Files tab browsing the session's directory. |
new-notes-tab [--group <name>] | Show the session's Notes tab, opening one if none is open. |
new-shells-tab [--group <name>] [--collection <name>] [--background] | Show a Shells tab: the shells an agent session ran. |
new-webview <url> [--group <name>] | Open a web tab (needs the Web tabs experiment). |
new-webview-command <command> [--group <name>] | Open a web tab whose URL is the first line a shell command prints (needs the Web tabs experiment). |
change-directory <path> [--group <name>] | Move a local session's working directory, like the pane header's folder button. New panes start there; the primary pane changes directory only at a bare prompt. |
focus <group> [--stay] | Focus a session by name. --stay keeps the page (on the Dashboard it focuses that card). |
focus-tile <tile> | Focus a tile by id, switching to its session and the Sessions page. |
focus-tab <session> | Focus the tab holding a pane (by session id) and switch to it. |
close-tab <session> | Close the tab holding a pane, as ⌘W on it would. A pinned tab refuses. |
close-group <group> [--yes] [--everywhere] | Open the close confirm for a session, or close it at once with --yes. --everywhere also closes a mirrored session on its device. |
group <group> pin|unpin|snooze|unsnooze|mark-unread|mark-read | Set a session's flags, as its sidebar row menu does. Also mark-unread, mark-read, babysit, unbabysit, close [--everywhere]. |
group <group> label|unlabel <label> | Add or remove a sidebar label on a session. |
bundle new [<group>...] [--name <n>] | add <bundle> [<group>...] | remove [<group>...] | rename <bundle> <name> | ungroup [<bundle>] | fold <bundle> auto|open|closed|toggle | close <bundle> [--yes] | focus <bundle> [<group>] | Drive session groups: create one, add or remove members, rename, ungroup, fold, close every member, or switch to a member. |
history-restore <n> | Restore closed session N from state's history (newest first), opening the palette at its Layout step. |
history-fold <open|closed> | Fold or unfold the sidebar's History run. |
sessions-fold <open|closed> | Fold or unfold the sidebar's Sessions run. |
Snooze
See Notifications and snooze for what each condition means.
| Command | What it does |
|---|---|
snooze <group> <30m|4pm|unread|pr|ci|activity|ci-fail|woken|watch:<name>|cmd:<shell>> [--wake <words>|none|default] | Snooze a session until a time (30m, 4pm), the agent's next message (unread), its PR's verdict (pr), its CI (ci), activity on its PR, a failing check (ci-fail), until woken (woken), a named watch, or a shell command exiting 0. --wake sets what wakes this snooze early. |
snooze-wake <group> <+word|-word>... | Change what wakes a snoozed session early: +word adds, -word removes. |
wake <group> [reason] | Wake a snoozed session now (default reason "Woken manually"). |
snooze-checks <group> [--reset] <+check|-check|=check>... | Choose which CI checks count for a session's snooze, remembered per repository: +check watches, -check ignores, =check forgets a pick. |
Labels, pages and windows
| Command | What it does |
|---|---|
new-section <name> | Create a sidebar label (an empty name gets "Label N"). |
section rename <section> <new name> | Rename a label. |
section delete <section> | Delete a label. It comes off every session; no session closes. |
section icon <section> <icon> | Set a label's glyph: a Lucide icon name or an emoji. |
move <group> <section> | Add a label to a session (its other labels stay). |
folder <name|id|all> | Select the label the sidebar and Dashboard show; all shows every session. |
window open-label|close-label|focus-label <label> | Open a label in its own window, close that window, or bring it forward. |
page <page> | Go to a page: sessions, dashboard, tasks, factory, trash, puddle, schedules, pr_reviews, my_prs, tool:N or a tool's name. settings or settings:SECTION opens the Settings window. |
dashboard-filter <all|unread> | Set the Dashboard's filter (the Dashboard must be open). |
dashboard-pr-filter <all|working|complete> | Set the Dashboard's PR-status filter (the Dashboard must be open). |
popout open [--group <g>] [--tile <id>] [--tab <n>] [--mode grouped|free|docked]|return|close|focus|focus-session [<id>]|mode <id> grouped|free|docked|pin <id> [on|off|toggle]|undock <id> | Pop a tab out into its own window, change its mode (grouped, free-standing, docked) or pin, bring it or its session forward, or return its tabs. |
window-lock list|add --window-id <n> [--group <g>]|remove --window-id <n>|pin --window-id <n> [--on|--off]|jump --window-id <n> | Lock another app's window to a session so it shows only while that session does; unlock, pin, jump to its session, or list lockable windows. Needs Accessibility. |
flyover open|close|toggle|new-tab [--cwd <dir>] [--background]|focus <n>|close-tab <n> | Show, hide or toggle the flyover terminal, open a tab in it, or pick or close tab N. |
resize <width> <height> | Resize the Flow window. |
Typing, clicking and capturing
| Command | What it does |
|---|---|
send-text <text> [--group <name>|--session <id>] | Type text into the focused (or named) session's pane, or into any pane by id with --session without moving focus. --enter appends Return; - reads stdin. |
key <chord>... | Press keys through Flow's key handler. Chords use the form cmd-p, escape, cmd-shift-t, ctrl-c, enter. |
click <x> <y> [--shift] [--cmd] | Click the main window at a point (in points: a screenshot's pixels divided by its scale). |
hover <x> <y> | Rest the pointer on the main window at a point without clicking. |
palette-query [--] [text] | Set the open command palette's query as if typed. After -- every word is query text. |
context-menu [row|tab] | Open the active session's row menu or the focused tab's menu, as a right-click would. |
screenshot [path] [--clipboard] [--window main|settings|popover|palette|dialog|flow|pill|pills|image|menu|toast|flyover|window-pick|label:<name|id>|device:<device>[/<label>]|popout:<id>|window-chrome:<id>] | Capture the main window, or another Flow window with --window, to a PNG (default: a temp path) or the clipboard. |
record start [path] [--window <name>] [--fps N] [--scale S] [--max SECS] | stop | status | Record Flow's own windows to an MP4. --fps 1–30 (15), --scale 0.25–2 (1), --max 1–600 seconds (120). stop finishes and prints the path. |
notify <title> [--detail D] [--kind K] | Post a notification as an agent message. It is delivered as Settings › Notifications › Agent messages and Do Not Disturb say. |
caffeinate <on|off|duration|until <time>> | Keep the Mac awake: on, off, a duration (90m, 1:30, at most 48h) or until 6pm. |
flow-send <text>|- | Send a prompt to the active Flow agent (Flow agent experiment). - reads stdin. |
Files and notes
| Command | What it does |
|---|---|
files-open <path> [--keep] [--line <n>] [--group <name>] | Open a file in the session's Files tab, at --line; --keep keeps it as a tab instead of the preview. |
files-rename <label> [--group <name>] | Rename the focused Files tab; an empty label resets it. |
files-hunk <peek|stage|revert> <index> [--yes] [--group <name>] | Peek, stage or revert change N of the active file. Revert asks first unless --yes. |
files-cursor <line> [<col>] [--group <name>] | Put the caret on a line (from 1) and column (from 0). |
files-nav <def|refs|back|forward> [<line>] [<col>] [--group <name>] | Go to definition or find references at a position (or the caret), or step back and forward through the history. |
files-find [<query>…] [--query <text>] [--mode text|fuzzy|semantic] [--case|--word|--regex on|off] [--list on|off] [--step <n>] [--close] [--tab <id> | --group <name>] [-- <query>…] | Drive the find widget of a Files tab or a Shells tab: query, mode, options, step through matches, close. |
lang-sources <list|refresh|download|extract|remove|cancel> [<lang>] [<version>] | List, refresh, download, extract, remove or cancel the standard-library sources Settings › Code › Languages manages. |
notes-compose <path> <s> [<e>] [--group <name>] | Open the note composer on lines of a file in the focused Files tab. |
notes-add <text…> [--group <name>] | Submit text as the open composer's note. |
notes-jump-file <path> <line> [--group <name>] | Jump the Files tab to a line of a file, with its notes inline. |
notes-jump-note <slug> <page> <block> [--group <name>] | Open a note block of a notebook page in the Notes tab. |
notes-toggle-task <block> <task> [--group <name>] | Check or uncheck a task on the shown Notes page. |
notes-rename-page <page> <name> [--group <name>] | Rename a Notes page (.md is added when missing). |
notes-run-cell <cell> [--group <name>] | Run a notebook cell on the shown page (Notebooks experiment). |
notes-set-input <name> <json-or-string> [--group <name>] | Set a notebook input, re-running the cells that use it (Notebooks experiment). |
Pull requests
| Command | What it does |
|---|---|
new-pr-review [N] [--group <name>] | Open a PR review tab: PR N of the session's repository, or its branch's PR. |
open-pr-session --url <url> | --repo <owner/name> --number <N> [--head <branch>] | Open (or resume) the review session for a pull request, checked out locally when possible. |
pr-review-view <summary|changes> | Show the focused review tab's Summary or Changes. |
pr-review-mode <unified|split> | Lay the diff out unified or split. |
pr-review-scroll <dy> | Scroll the review tab by a number of points. |
pr-review-image [n] | Enlarge the Nth image of the Summary. |
pr-review-groups <open|close|scope <repo|all>|add|preset <name>|pattern <id> <regex>|hunks <id> <regex>|description <id> <text>|name <id> <text>|fold <id> <open|collapsed>|case <id> <on|off>|move <id> <up|down>|page <id> <up|down>|delete <id>|reset|discard|focus <id> <name|pattern|hunks>> | Drive the Diff groups panel: open, close, add, edit, move, delete or reset groups. |
pr-review-auto-merge <on|off> | Turn auto-merge on or off for the PR. |
pr-review-comment <body> | Post a top-level comment. A body of - reads stdin. |
pr-review-inline <path> <line> [--side left|right] [--start <line>] [--pending] <body> | Comment on a diff line or range, or hold it as a pending review draft with --pending. |
pr-review-reply <thread-index|PRRT_id> <body> | Reply to a review thread, by index or PRRT_ id. |
pr-review-resolve <thread-index|PRRT_id> [--undo] | Resolve a review thread, or unresolve it with --undo. |
pr-review-submit <comment|approve|request-changes> [body] | Submit a review with the pending drafts. |
pr-review-compose <top|inline|note|note-hunk <path> <line> [--side] [--start]|reply <thread-index|PRRT_id>|review> [--preview] | Open a comment or note composer on the review tab. |
pr-hunk-flag --file <n> [--hunk <n>] --group <id> [--tab <id>] | Mark which diff group a hunk belongs in. |
pr-hunk-eval [--repo <owner/name>] [--regex-only] | Replay flagged hunk samples through the diff-group patterns and, with Decisions on, the decisions model. |
Agent shells
| Command | What it does |
|---|---|
shells run [--collection <name> | --group <name>] [--cwd <dir>] [--description <text>] -- <command…> | Run your own command in a shell store collection, as the Shells tab's Rerun does. Prints the collection and the new run's id. |
shells kill --collection <name> --run <id> [--signal INT|TERM|KILL] | Signal a run's process group (TERM by default). |
shells view [--tab <id>] [--rail on|off] [--filter <text>] [--segment all|running|failed] | Set what a Shells tab shows: its run rail, filter and segment. |
Settings and tools
See Settings and Custom tools.
| Command | What it does |
|---|---|
settings apply <id> <json-or-string> | Write one Settings row by id, exactly as clicking it does. |
settings reset <id> | Put one Settings row back to its default. |
settings set <key> <json-or-string> | Write one raw settings key. Not every key applies live. |
settings repo-set <key> <json-or-string> [--repo <key> | --dir <path>] [--important | --not-important] | Write a scoped setting in your per-repository config. |
settings repo-unset <key> [--repo <key> | --dir <path>] | Remove a scoped setting (and its !important mark) from your per-repository config. |
reveal-setting <id> | Open the Settings window at one row, scrolled into view. |
tool cli add|edit|remove <name> [--command <c>] [--cwd <dir>] [--enabled true|false] [--icon <id>] | Add, edit or remove a CLI tool page by name. |
tool list | The flow tools found in ~/.flow/tools (same as read flow-tools). |
tool check <name> | Re-check a flow tool now and print its verdict: ready, invalid or refused, with problems. |
tool open <name> [--data] | Open a flow tool's page (its terminal), or its Data page with --data. |
tool data <name> | Open a flow tool's Data page. |
Schedules
| Command | What it does |
|---|---|
schedule-add --name <n> [--command <c>] [--cwd <dir>] [--cron '<m h dom mon dow>'] [--output session|background] [--grace 0|15m|30m|1h|2h|4h|<minutes>] [--missed skip|once|replay|recover|ask] [--replay-max N|all] [--recovery-command <c>] [--goal <text>] [--approval never|recovery|every] [--expiry 1h|4h|eod|next] [--on-expiry skip|run] [--notify-on-failure on|off] [--skip-if-running on|off] [--disabled] [--base new|existing|root] [--branch <template>] [--from <ref>] [--cleanup keep|merged|7d] [--worktree <dir>] [--layout <profile>] [--pane N] [--session-name <template>] [--label <id>|none] [--focus quiet|front] | Create a schedule and print its id. Schedules only run while the Automations experiment is on. |
schedule-update <id> [the schedule-add flags] | Change a schedule; only the flags you give are written. |
schedule-remove <id> | Delete a schedule with its logs, history and Inbox items. |
schedule-enable <id> on|off [--device <id>] | Resume or pause a schedule. |
schedule-run <id> [--device <id>] | Run a schedule now. |
schedule-stop <id> [--device <id>] | Stop a schedule's running run. |
schedule-approve <item> [--command <c>] [--device <id>] | Approve an Inbox item (run it, optionally with another command). |
schedule-skip <item> [--device <id>] | Skip an Inbox item. |
schedule-snooze <item> [--minutes N] [--device <id>] | Hide an Inbox item for N minutes (default 60). |
Task Manager, Trash, Factory and web tabs
| Command | What it does |
|---|---|
tasks-focus <cpu|memory|energy|disk|network> | Set the Task Manager's focus tab (the page must be open). |
tasks-chart-view <lines|stacked> | Set the Task Manager's chart view. |
tasks-select <group key> | Highlight a group in the Task Manager's tree. |
tasks-kill <pid> | Raise the Task Manager's Kill confirm for a pid. |
trash-delete <id> --head <sha> [--branch <name>] [--dirty]... [--device <id>] | Delete worktrees from the Trash with no confirm: only rows judged safe or pushed, each still at the --head, --branch and --dirty you read from read trash. Branches are kept. |
factory <add [--template <key>] | remove | plan set <file|-> | replan | template save <name> | template remove <name>> [--dir D] [--group G] | Put this checkout's branch in the Factory, take it out, or manage its plan and templates (Factory experiment). |
gate <report <slug> --evidence <text>|--claim|--working|--failed | blocked <reason> | unblocked | pass <gate-key> | note <text>> [--dir D] [--group G] | Record a Factory gate check, block, pass or note for this checkout's branch (Factory experiment). |
factory-open <group> | Open a session in the Factory page's pane. |
webview back|forward|reload|navigate <url> [--tab <id>] | Go back, forward, reload or navigate a web tab. |
route-url <url> [--from <bundle id>] [--ask] | Route a URL as if another app had opened it with Flow as the default browser. Uses the link router's rules while that experiment is on. |
Puddles and sync
These need the Puddles experiment and a paired device. See Sync overview.
| Command | What it does |
|---|---|
puddle-mount <device> <dir> [--open] | Mount a folder of a paired device in Finder. |
puddle-unmount <device> [<dir>] | Unmount a paired device's Finder mount. |
puddle-revoke <device> | Remove a paired device from your puddle. |
puddle-open <device> <group> [--label L] | Open a paired device's session here. |
puddle-chip <device> [--label <label>] [--hide|--show] [--glyph <icon|emoji|default>] | Hide or show a paired device's chips in the spaces bar, or set its glyph. |
device-window open|close|focus <device> [--label <label>] | Open a paired device's space in its own window. |
sync query <collection> [--where '<path> <op> <json>']... [--owner <device>|self]... [--all] [--order <path>[:desc]]... [--limit N] [--no-overlay] | --query '<json>' | Query the sync store. Values in --where are JSON. |
sync mutate <collection> <operation> '<json args>' [--lease <key>:<token>[@<holder>]] | Write this device's rows of a sync collection. |
sync intent <device> <collection> <operation> '<json args>' | Queue a write for another device; prints the message id. |
sync watch <collection> [query flags] [--count N] [--every MS] | Print one line per change to a query's result. |
sync schema [<collection>] | Print the sync contract, or one collection's entry. |
sync status | The sync store's status (same as read sync). |
Read commands
| Command | What it does |
|---|---|
read pane <session> [--lines N|--all] | A pane's text by session id: the visible screen, or scrollback with --lines N / --all. --json adds title, size, cursor, session and foreground process. |
read panes [query] | One line per pane in every session and the flyover: session id, session, title and foreground process, the focused one marked *. Filter by a substring. |
read settings [key] | The settings map as JSON, or one key's value (null when unset). |
read settings-catalog [query] | Settings rows matching a query, best first: id, section, label, control, value, default. |
read config-trace [--dir path] [--key key] | How each scoped setting resolves in a directory, layer by layer. |
read repos | The repositories Settings › Repos lists. |
read snooze-checks <group> | A session's chosen checks for Snooze and its PR's checks. |
read shells [--collection <name>] [--run <id>] [--offset <n>] | The shell store: collections, a collection's runs, or one run's log from a byte offset. |
read icons | The tab icon catalog, overlays, triggers, and each pane's program and overlay. |
read agent-context | The focused session's agent context card: sources, outputs and running shells. |
read clipboard [--query q] [--limit n] | Clipboard history, pinned then newest first. Sensitive entries are masked. |
read tasks | The Task Manager's rows: every live terminal with its pids, CPU, memory, open files, scrollback and age. |
read trash [--device <id>|--all] | The Trash page's worktrees with their verdicts (safe, pushed, loses_work, in_use). Never starts a scan. |
read schedules [--device <id>|--all] | Every schedule with its cron, next run and latest run. |
read schedule-inbox [--device <id>|--all] | The schedules Inbox: pending, snoozed and handled-today items. |
read schedule-runs <id> [--limit N] [--device <id>] | A schedule's run history, newest first, with log paths. |
read notifications | The notification history. Marks nothing read. |
read notebook [--group <name>] | The shown Notes page's notebook cells and inputs (Notebooks experiment). |
read flow-tools | The flow tools in ~/.flow/tools and offers from your other Macs (same as tool list). |
read tools | The CLI tool registry and its sync state. |
read webhooks | The GitHub webhook settings and status. Never a secret or token. |
read decisions | Settings › Decisions. Never the API key. |
read link-route <url> [--from <bundle id>] | Where the link router would send a URL, without opening it. |
read factory | The Factory page's sessions, gates and scores. |
read gate-checks [--dir D] [--group G] | The checks of one work's Factory plan. |
read factory-plan [--dir D] [--group G] | One work's Factory plan as JSON. |
read factory-templates | The templates a Factory plan can start from. |
read factory-brief [--dir D] [--group G] | The Factory's planning protocol, as text. |
read puddle | The Puddle page: the service, any invite and the paired devices. Never the pairing token. |
read puddle-mounts | The Finder mounts of paired devices' folders. |
read places | The New session picker's places: this Mac's favorites and recents, then paired devices'. |
read presence | Presence across your Macs: which one you used last and how long each has been idle. |
read sync | The sync store's status: members, freshness, outbox. |
Examples
Start a session in the background and run a command in it:
flow-cli new-session ~/src/api --background
flow-cli send-text --group api --enter "make dev" # api: the session's name
Wait for a pane to print something:
until flow-cli read pane 42 | grep -q "ready on"; do sleep 1; done
Rebind a shortcut and show the user where it lives:
flow-cli settings apply keyboard.split_right cmd-shift-k
flow-cli reveal-setting keyboard.split_right
Notify yourself when a long job ends:
make release && flow-cli notify "Release built" --detail "$(git rev-parse --short HEAD)"
Limits
flow-clineeds a running Flow app; with none it exits with code 2.- An action that does not apply where you are (no PR on the session, no Files tab focused) is reported as a no-op rather than an error.
- Commands for an experiment that is off are refused or do nothing.
Sources
Written from these files in the Flow app repo
src/bin/flow-cli.rssrc/bus.rssrc/bus_exec.rssrc/cli_install.rssrc/paywall_ui.rssrc/features.rssrc/pages.rs