Skip to content

CLI Reference

Randy Northrup edited this page Nov 19, 2026 · 1 revision

CLI reference

Four command lines, all standard-library Python, all run from the skill folder:

Tool Path For
pb.py playbook/pb.py Read and change flows, accounts, folders and parts; check the playbook
qc.py playbook/qc.py Check drafts; list, explain and test filters
audit.py playbook/audit.py The audit log
run.py scripts/run.py Run checklists

Every command has --help. Exit codes: 0 done, 1 refused or failed (the reason is on stderr), 2 the command line was wrong. Exceptions are noted per command.

pb.py

<col> is flows, accounts, folders or parts. pb.py with no command runs list.

Every write (put, split, delete, restore, normalize) is recorded in the change history under the actor named by the environment variable AGENT_PLAYBOOK_ACTOR, or agent when it isn't set (restores add (restore)). Set it per agent, for example AGENT_PLAYBOOK_ACTOR=codex, to see who changed what.

Reading

Command Does
pb.py list Every flow by group: id, name, node count, summary. * marks flows with the owner's canvas edits.
pb.py show <flow> [--json] The flow as an outline (see Flows and nodes). <flow> may be any unique part of the id or name. --json prints {"col", "id", "rev", "doc"}, plus resolved (part references filled in) when the flow uses parts.
pb.py search <text> Nodes, accounts, folders and parts that mention the text (not case-sensitive)
pb.py accounts [platform] The accounts registry, optionally for one platform (matched as part of the name)
pb.py folders The shared folders and the flows that use each
pb.py parts The parts library and the flows that use each part
pb.py edited [YYYY-MM-DD] What was changed on the canvas, optionally since a local date. Exit 2 for a bad date.
pb.py catalog [recipe] The recipes by group; with a recipe, its checklist and every flow, part, script and QC filter it uses
pb.py catalog --pieces What each kind of piece is for, and where a new lesson goes
pb.py rev <col> <id> The document's current revision (for put --base)
pb.py versions <col> <id> Saved versions, newest first
pb.py changes [n] The latest n changes (default 40): time, who, action, document, what was removed and why

check

pb.py check [--strict] [-w] [--rule RULE] [--paths]

Schema, lint, recipe checks and the QC selftest over the whole playbook. Prints each error (and each warning, with -w or --strict) as file: path: level [rule] message, then a summary line with counts by rule.

Flag Does
--strict Warnings fail too (and are listed)
-w, --warnings List every warning
--rule RULE Only list this rule; repeatable
--paths List folders whose paths don't exist on this machine

Exit 1 on any error, or on any finding with --strict. The rules are in Flows and nodes.

put

pb.py put <col> <id> <file> [--reason "why"] [--base REV]

Saves a document from a JSON file. The file holds either the document itself (the same shape as store/<col>/<id>.json) or the output of pb.py show <flow> --json, edited: then the doc inside it is saved, and its rev is the base revision. The document is checked against the schema first; an invalid one is refused with every problem listed. The replaced version is kept in history.

  • --reason is required when the new version of a flow drops steps or connections. The refusal names what it would remove.
  • --base REV refuses the save if the stored document is no longer that revision. Without it, the base is the rev in a show --json file, or, for a plain document, the revision on disk when the command started.
  • Prints saved <col>/<id> rev <rev>, or unchanged ... when the content is the same, then warns on stderr about any dangling reference the save leaves.

The safe way for an agent to edit a flow:

  1. python playbook/pb.py show <flow> --json > current.json
  2. Edit the document under "doc" in current.json.
  3. python playbook/pb.py put flows <flow> current.json [--reason "why"]
  4. python playbook/pb.py check --strict

Because the file carries the revision the agent read, a canvas edit made in between is refused ("changed since revision ...") instead of overwritten. Read the flow again and redo the change.

split

pb.py split <flow> <plan.json> --reason "why" [--dry-run]

Splits a flow that grew a second job into single-job flows. The plan names each new flow and the nodes it takes; every other node stays in the original, which becomes the hub. Notes attached to a moved node move with it. A connection that ends up crossing between flows becomes a goto, so every path still leads on. Each new flow gets a start node leading to its entry. The result is checked with the full lint in a scratch copy before anything is saved. --dry-run checks and lists the new flows without saving.

{
 "flows": {
  "x-reply": {
   "name": "X: replies",
   "summary": "Answer everyone waiting on X.",
   "entry": "<id of the first node of this job>",
   "start": {"title": "Replies waiting", "sub": "Notifications, last 2 days"},
   "nodes": ["<node id>", "<node id>"]
  }
 },
 "hub": {"summary": "The new summary of the original flow (optional)"}
}

Optional per flow: entry_label, and also ({"<node id>": "label"}) for more ways in. The start node stays in the hub. The full format is documented at the top of playbook/lib/split.py.

delete, restore

pb.py delete <col> <id> --reason "why" [--base REV]
pb.py restore <col> <id> <version> [--reason "why"]

delete moves the document to playbook/store/.trash/ and keeps its last version in history. A reason is always required. It doesn't change anything that points at the deleted document; instead it names each reference on stderr ("warning: store/flows/release.json: nodes/rel-write uses the folder 'drafts', which is now deleted") and still exits 0. Edit those on the canvas or with put; until then pb.py check reports them as dangling-ref. (Deleting a folder, part or account on the canvas cleans up its references for you.)

restore puts a saved version back (from pb.py versions), keeping the current one in history first. It also brings back a deleted document. Without --reason, the history records "restored the version from ".

export, normalize

Command Does
pb.py export Writes playbook/store.json next to playbook.html, for a read-only published copy
pb.py normalize [--check] Rewrites every document in the canonical stored form. --check only reports and exits 1 if anything would change.

qc.py

Command Does
qc.py check --platform P --account A --action ACT (--text-file F | --text T) [options] Checks a draft and writes a receipt. Exit 0 pass or warn, 1 blocked, 2 command-line or file problem.
qc.py filters [--platform P] [--action A] [--recipe R] [--promo] The filters, or those that apply: id, severity, type, where it applies, message
qc.py explain <filter-id> One filter in full, as JSON. Exit 2 for an unknown id.
qc.py selftest Every filter against its examples. Exit 1 if any fails.
qc.py receipts [-n 20] The latest receipts: time, verdict, platform, account, id, findings

check options: --target URL, --target-author NAME, --place PLACE, --project ID, --promo / --no-promo, --recipe ID (default: the open run's recipe), --media FILE (repeatable), --scheduled-for TIME, --ok ID=EVIDENCE (repeatable). A reply or comment needs --target and its author. Details: QC gate.

qc.py with no command prints its help and exits 2.

audit.py

Command Does
audit.py add --platform P --action ACT [fields] Log a send. Refuses duplicates, unknown accounts, accounts marked retired or skip, text without a passing QC receipt, and deletions without a reason.
audit.py update <id> [--status S] [--reason R] [--verified V] [--url U] [--note N] [--text T] [--scheduled-for TIME] Append an update. Needs at least one field; deleted and removed need --reason.
audit.py gap --platform P --account A --action ACT [--place PLACE] Before a send: READY (exit 0) or WAIT and how long (exit 1). Also exit 1 for an unknown, retired or skipped account.
audit.py today [--platform P] Today's counts and pace flags
audit.py recent --platform P [--account A] [--place PLACE] [-n 4] The last N things posted there
audit.py list [--platform P] [--project P] [--status S] [--action A] [--since DATE] [-n 50] Matching entries
audit.py show <id> One entry and its updates; the end of the id is enough
audit.py search <text> Entries that contain the text
audit.py stats Counts per platform, project, action and status
audit.py import <file.jsonl> Append entries from a file, skipping ones already logged; all or nothing

add fields: --at, --at-precision, --platform, --account, --action, --project, --url, --target, --title, --text or --text-file, --text-source, --media (repeatable), --status, --scheduled-for, --verified, --source, --notes, --reason, --place, --promo / --no-promo, plus:

Flag Does
--force Log it despite a duplicate, an unknown account, or an account marked retired or skip
--override "why" Log a reply or post without a passing QC receipt; the reason is listed by run.py finish

Times are YYYY-MM-DD or YYYY-MM-DDTHH:MM[:SS][+HH:MM]; a time without an offset is local. Details: Audit log.

run.py

Command Does
run.py recipes The recipes: id, title, when to use it
run.py start --recipe ID[,ID...] [--note "..."] Open a run (chain recipes with commas). Exit 1 for an unknown recipe or while another run is open. --kind is an old name for --recipe.
run.py status The open run's checklist. Exit 1 when no run is open.
run.py done STEP --note "evidence" Close a step. Exit 1 for an unknown step, 2 for an empty note.
run.py skip STEP --reason "why" Skip a step. A reason starting owner: marks your call; owner: next run carries it into the next run of that recipe.
run.py finish Close the run and print skips, pace flags, QC overrides and QC warnings. Exit 1 while any step is todo.
run.py abandon --reason "why" Close an unfinished run on purpose
run.py check For a Stop hook: exit 2, with the open steps on stderr, while a run has steps todo; otherwise exit 0
run.py list [-n 10] Recent runs with their state

run.py with no command prints its usage and exits 2. Details: Recipes and run checklists.

The canvas launcher and server

Command Does
python playbook/launch.pyw [--port N] [--no-browser] Start the server if it isn't running and open the page. Exit 2 for a bad port number, 1 when the port is taken by another program or the server doesn't start.
python playbook/server.py [--port N] Run the server in the foreground. Exit 1 if the port is taken.
python playbook/install_shortcut.py [--remove] Add or remove the desktop shortcut
python playbook/app/build_page.py [--check] Rebuild playbook.html from app/playbook.src.html (for development). --check exits 1 if the built page is stale.

--help on launch.pyw, install_shortcut.py and build_page.py prints their help and does nothing else. install_shortcut.py and build_page.py exit 2 for an argument they don't know; launch.pyw ignores one. When launch.pyw runs without a console (the Windows shortcut), it shows its error messages in a message box.

The port is --port, else AGENT_PLAYBOOK_PORT, else 47321; it must be between 1024 and 65535.

pb.py, qc.py, audit.py and server.py also accept a hidden --root DIR that points them at another playbook folder. The tests use it; it isn't a stable interface, and run.py doesn't have it. To experiment, copy the skill folder instead (see Quick start).

Clone this wiki locally