Write a flow
A flow is a Markdown document saved in Reflow or in your repository, executed deterministically with reflow plan and
reflow apply. YAML frontmatter declares configuration, prose explains intent, and named
fenced steps carry executable RFL statements. Markdown outside fences is human context only; your coding agent authors the RFL statements inside each step.
Choose where new tests are saved during onboarding or in Team settings. The syntax, dependencies, plugin bindings and execution workflow are the same in both locations. Repository examples use .reflow/flows/; shared tests are created through manage_flows or reflow flows create.
Walk through a checkout flow
Section titled “Walk through a checkout flow”checkout.md uses a seed-customer dependency and a private Browser connection
named site.
Your agent can adapt the journey, setup flow and selectors to your application.
Name the behavior you want to check.
A flow is a Markdown test saved in Reflow or in your repository. Give it a useful name and a starting path. The path is combined with the target you select, so the test can follow your app from localhost to a PR preview.
Lines 1–3---
name: Checkout with a discount
url: /checkout Declare what must happen first.
This checkout depends on seed-customer, a separate flow that prepares its test customer. Reflow puts that dependency in the plan and runs it first. If it cannot complete, checkout is blocked.
Lines 4–4needs: [seed-customer] Choose the commands your test can use.
The site alias adds Browser commands to this flow. It uses the private connection named site on the machine running the test. The application lock selects one release for every flow. Run init to install that selection on each device.
Lines 5–7providers:
site: Browser
Make the values explicit.
promoCode is a string input with a default. Supply a different value through your target’s input file, without rewriting the journey. Private connection settings and credentials stay outside the flow.
Lines 8–10inputs:
promoCode: {type: string, default: QA10}
--- Write steps in your application’s language.
The heading explains the intent. Commands inside the rfl fence execute in order. Here, the browser opens checkout and enters the declared promo code. Replace these selectors with the controls in your app.
Lines 11–17
### Apply the customer’s discount
```rfl
site.open url="/checkout"
site.fill selector="[data-testid=promo]" value="${inputs.promoCode}"
site.click selector="[data-testid=apply-promo]" Assert the outcome. Capture the result.
Check that the customer sees the discount, then capture the screen. The assertion checks a business outcome; the named snapshot gives your agent a visual to compare and bring into PR review.
Lines 18–20site.expect selector="[data-testid=discount]" text="10%"
site.snapshot name="discount-applied"
``` ---name: Checkout with a discounturl: /checkoutneeds: [seed-customer]providers: site: Browser inputs: promoCode: {type: string, default: QA10}--- ### Apply the customer’s discount ```rflsite.open url="/checkout"site.fill selector="[data-testid=promo]" value="${inputs.promoCode}"site.click selector="[data-testid=apply-promo]"site.expect selector="[data-testid=discount]" text="10%"site.snapshot name="discount-applied"``` Database steps and variables
Section titled “Database steps and variables”Use your business data alongside browser checks. This flow captures a repeatable
selection of orders; orderLimit is a typed input with a default:
---name: Inspect ordersproviders: db: PostgreSQLinputs: orderLimit: {type: integer, default: 10}---
### Capture recent orders
```rfldb.query sql="SELECT id, status FROM orders ORDER BY id LIMIT ${inputs.orderLimit}" key="id" checkpoint="orders"```db uses the private connection with the same name. key="id" uses a unique, non-null column to give the rows a stable order.
The retained results let your agent inspect which order values changed.
To override the default, save {"orderLimit": 25} in a private JSON input file
and supply it when selecting your target:
reflow target --group orders --bindings /absolute/path/to/connections.json --inputs /absolute/path/to/inputs.jsonreflow planreflow applyUse numeric or boolean inputs for values such as limits and feature switches. Do not concatenate untrusted text into SQL. See variables for typed references and outputs from upstream flows.
Generate values and pass them between flows
Section titled “Generate values and pass them between flows”Use capture to give a value a name. Later statements can read it; a flow that
lists this flow in needs can read its saved outputs. Receipts retain captures as
strings; declared types restore numbers when consumed. Use number(...) to
convert a text capture before arithmetic.
For example, .reflow/flows/seed-order.md generates test data and creates the
order with your application’s own ./bin/create-order, which prints the new
order as JSON:
---name: Choose order test dataproviders: worker: LocalBashinputs: unitPrice: {type: number, default: 25}---
### Generate the order
```rflcapture suffix = random.string length=12capture quantity = random.integer min=1 max=5capture orderId = "test-${suffix}"capture total = expression "number(${quantity}) * number(${inputs.unitPrice})"worker.bash ( command="./bin/create-order '${orderId}' '${quantity}' '${inputs.unitPrice}'" expect=json( {"json": [{"pointer": "/status", "equals": "open"}]} ))```The consumer declares the dependency and the outputs it reads. This
.reflow/flows/check-order.md example passes the values to your application’s
own check through LocalBash, as arguments of one command; it assumes
./bin/check-order, so replace it with your application’s check when adapting it:
---name: Check the generated orderneeds: [seed-order]providers: worker: LocalBashreferences: needs.seed-order.outputs.orderId: {type: string} needs.seed-order.outputs.quantity: {type: string} needs.seed-order.outputs.total: {type: string}---
### The order matches its generated values
```rflworker.bash command="./bin/check-order '${needs.seed-order.outputs.orderId}' '${needs.seed-order.outputs.quantity}' '${needs.seed-order.outputs.total}'" checkpoint="order-values"```The generated values above have a fixed safe format. Shell and SQL interpolation is text substitution, not argument escaping or query parameterization; do not insert arbitrary user text this way. Keep credentials in private bindings and avoid capturing sensitive input values: captures become shared run evidence.
Run the consumer; Reflow includes its dependency:
reflow plan .reflow/flows/check-order.mdreflow apply .reflow/flows/check-order.mdThe generated suffix and quantity belong to this flow’s named test data in the
selected execution group. Re-planning, new applies, retries, browser replay and
reflow taint seed-order preserve them. Changing unitPrice recomputes total
without choosing another quantity. Renaming a generated capture creates a new
identity; changing its generator options requires a reset or a new name.
To choose fresh data for the whole selected group, run reflow reset, then plan
and apply again. Reset also replaces the group’s named mailboxes; it does not
remove application records. Separate setup flows remain useful for expressing
shared dependencies, but are not needed merely to keep random values stable.
The producer must succeed and provide the named output before a consumer can run.
See the variable reference for exact scope and
Mailbox plugin for reusable test accounts.
Use one flow inside another
Section titled “Use one flow inside another”needs runs a whole flow first, as its own execution. When several flows begin
with the same steps (signing in, creating a user), write those steps once as a
flow and run them inside each caller with use. This .reflow/flows/sign-in-admin.md
is an ordinary flow that also says which captures it hands back:
---name: Sign in as an administratorurl: /loginproviders: site: Browserinputs: email: {type: string}outputs: userId: {type: string}---
### Sign in
```rflfill label="Email" "${inputs.email}"click role=button name="Sign in"expect role=heading name="Dashboard"capture userId = text of testid=user-id```A caller runs it as one of its own steps, in the same browser session, and reads the declared outputs under the name it chose:
---name: Edit billing detailsproviders: site: Browserinputs: adminEmail: {type: string}---
### Sign in
```rfluse sign-in-admin as admin email="${inputs.adminEmail}"```
### Open billing
```rflsite.open url="/users/${admin.outputs.userId}/billing"```The use statement is the whole of its step. The execution page shows the step
with the used flow’s own steps nested under it, and the flow graph draws a dashed
line from the used flow to each flow that uses it. Editing the used flow re-plans
its callers. The caller must declare the same providers as the used flow, and a
used flow cannot declare needs, prerequisites, uploads or invariants, use
another flow, or generate random.* values. See
use another flow as a step.
Keep the sign-in between flows
Section titled “Keep the sign-in between flows”Add a session to the used flow and its browser session is kept on your device,
so only the first flow to use it signs in:
session: expires: 8h valid: expect testid=account-menuexpires is how long a saved session is trusted (30m, 8h, 7d; at most
30d). valid is one assertion that holds only while signed in. On every use,
Reflow restores the saved cookies and local storage, opens the page the flow
ended on and runs valid. If it passes, the flow’s steps are not run and its
outputs are the saved ones. If there is no session, it has expired or valid
fails, the steps run and the session is saved again. The step passes either way
and its result says which happened: ran, restored, or ran · session rejected. reflow plan says what it expects.
Only what the used flow’s steps add or change in the browser is kept. Put the
use step before the caller’s own steps on the site: a cookie the caller already
holds, which signing in upgrades without changing its value, is not saved, and
later callers would sign in again (ran · session rejected).
The session stays in your device’s private profile for the selected target
group. It is never uploaded and never appears in evidence. reflow taint sign-in-admin forgets it, as do reflow reset, a new target and an edit of the
flow. See keep a used flow’s browser session
for what is kept and when to leave it off.
Clean up what a flow makes
Section titled “Clean up what a flow makes”A flow that creates data, changes a role or starts something undoes it in a
cleanup step: a fence written rfl cleanup, below the step whose work it undoes.
It runs after the flow’s steps, whether they passed or failed, and only when that
step started:
---name: A new agent is stored onceproviders: db: PostgreSQLinputs: suffix: {type: string}---
### Create the agent
```rfldb.execute sql="INSERT INTO agents (name) VALUES ('zz-e2e-${inputs.suffix}')"```
```rfl cleanup step="Delete the agent"db.execute sql="DELETE FROM agents WHERE name = 'zz-e2e-${inputs.suffix}'"```
### The agent is stored once
```rfldb.query ( sql="SELECT count(*) AS agents FROM agents WHERE name = 'zz-e2e-${inputs.suffix}'" expect=json( {"json": [{"pointer": "/0/agents", "equals": 1}]} ))```The results list the cleanup step after the flow’s steps as cleanup: Delete the agent. When it fails, the run fails, and the step that failed first keeps its
own error. Several cleanup steps run last armed first; a used flow’s cleanup
steps run at the end of the calling flow. Write what the cleanup accepts in its
check (a delete that may find nothing) instead of ignoring errors in a script.
See clean up after a flow for the
complete rules: time, reuse, holds and what stops cleanup.
Run a flow across a matrix
Section titled “Run a flow across a matrix”Declare matrix in frontmatter to fan one flow out into parallel variants—each with its own result, evidence, and reuse—instead of duplicating files or writing a shell loop:
---name: Verify base and head buildsproviders: worker: LocalBashmatrix: - {side: base, expectedStatus: open} - {side: head, expectedStatus: closed}---
### Check order status for each build
```rflworker.bash ( command="./bin/check-build '${matrix.side}'" expect=json( {"json": [{"pointer": "/status", "equals": "${matrix.expectedStatus}"}]} ) checkpoint="build-status")```Up to 3 axes and 8 variants per flow; each variant counts toward the 500-flow plan limit. See Matrix runs and parallel execution for inputs.json variant overrides, needs: fan-out, --parallelism, and evidence diff --request, and matrix rules for the complete grammar.
Configure plugins once per flow
Section titled “Configure plugins once per flow”Aliases belong in frontmatter; executable commands belong in the steps:
providers: db: PostgreSQL shell: LocalBash ui: {use: Browser, binding: site}The short form uses the alias as its private connection name. Use binding only
to select a differently named connection, as ui does above. Run reflow init to generate or verify the application lock, then inspect its
selected releases with list_plugins.
Keep connection strings, working directories and credentials in the private JSON
file passed to reflow target --bindings. The flow stays portable: each teammate
supplies their own connections without editing the test.
LocalBash adds shell commands; DockerUbuntu runs commands inside an existing Ubuntu container. PostgreSQL captures database rows and can prepare test data. A custom plugin can add commands and comparisons that express your business rules. See writing a plugin.
Frontmatter reference
Section titled “Frontmatter reference”| Field | Purpose |
|---|---|
name | Display name of the flow. |
providers | Aliases for plugins and their private connection names. |
requires | Programs (and optional >= version floors) verified on each provider alias’s PATH before step 1. See requires:. |
plugins | Plugin name, source commit and descriptor digest from the installed catalog. |
inputs | Typed parameters with optional defaults. |
matrix | Fan out the flow once per combination (e.g. matrix: {side: [base, head]}), read as ${matrix.side}. Max 3 axes and 8 variants (Matrix runs and parallel execution, matrix rules). |
if / unless | Whole-flow Browser condition judged at url before step 1; skips cleanly (exit 0) when unmet (flow conditions). |
references | Types of values read from other flows. |
outputs | Captures this flow hands to a flow that runs it with use, each with its type. See use one flow inside another. |
session | {expires, valid}: keep this flow’s browser session on the device, so flows that use it restore it instead of signing in again. See keep the sign-in between flows. |
url | Starting path for a browser flow, such as /checkout. |
needs | Flow slugs that must complete before this flow runs. |
prerequisites | Checks and optional setup before the steps. |
covers | Repository globs used to select flows affected by a change. |
golden | Validation marker (runs: 1–8 passing run IDs validating this flow and its needs ancestors; optional environment). Not part of step identity, so updating it re-runs nothing. Load golden-authoring before writing it. |
uploads | Files the flow’s upload statements may select, each pinned by size and SHA-256. See upload files. |
tags | One to three words that say what the flow is for, such as tags: [golden, v2] or tags: [pr-8839]. See tags. |
invariants | RFL expect assertions, one per entry (e.g. expect text="Ready"), checked on the Browser page after all steps pass. |
browser | Browser engine; local browser flows use Chromium. |
device | Playwright device preset for browser emulation. |
timeout | Whole-flow time budget (500ms, 30s, 5m, 8h, 1d; default cap 31m, max 30m per provider call). Steps (```rfl timeout=45s) and statements (timeout=) set tighter bounds; timed-out steps rerun automatically without reflow taint. See timeouts. |
self_heal: false, validate: false, repair_proposals: false, provider_key and
budgets.tokens are accepted and ignored. Planning refuses self_heal: true,
repair_proposals: true and validate: true (what planning refuses).
Tags are how you find a set of flows again: a suite, the flows written for one task, the probes left by one pull request. A tag is a word in the flow file:
tags: [golden, v2, shard-a]- One word each. Lower-case letters, digits and hyphens, at most 48
characters, no comma, not starting with a hyphen. Up to 16 per flow; one to
three is usual. Matching ignores case. A tag has no key or value:
pr-8839is a word, not a field. - Only in the file. There is no other place a tag is set. Changing tags saves a new version of the flow.
- Nothing re-runs. Tags are not execution input. Adding, changing or removing
them re-runs no step, keeps completed work reusable and leaves a golden flow
golden. This needs a CLI whose
reflow help planlists--tag; older CLIs count tags as step input and re-run a flow once after its tags change. - Reuse, do not invent.
reflow flows tagslists the tags in use with their flow counts. Pick from it before adding a new word, sov2does not end up besidev2-suiteandV2Suite.
In the app, Flows and Executions have a filter bar with a chip per tag. One tap
shows only flows with that tag; several tags narrow further (a flow must carry
all of them); a second tap on a chip excludes the tag instead. Golden and
“untagged” are chips in the same bar. The filter is the page address, for
example flows?view=list&tag=v2&tag=-scratch&golden=1, so a filtered page is a
link to that suite. Executions are filtered by the flow’s current tags, not the
tags of the version that ran.
The same selection works from the command line:
reflow flows tags # every tag and how many flows carry itreflow flows list --tag v2 --exclude-tag scratch # matching flows, golden mark, tagsreflow plan --tag v2 --tag shard-a # flows carrying bothreflow apply --tag pr-8839reflow flows tag 'review-pr-8839-*' --add pr-8839 --dry-run # retag existing flows--tag repeats to require several tags, --exclude-tag leaves a tag out and
--untagged selects flows with none. A plan holds at most 500 flows including the
flows they need; a tag selection beyond that is refused with the count and the
tags that would narrow it. reflow flows tag rewrites only the tags: line of
each selected flow: a new version for a flow kept in Reflow, the checkout file
for a repository flow, which you then commit.
reflow ci run --label <tag> runs golden flows carrying
any of the given labels (several labels widen the selection there, where
several --tag narrow it). Case does not matter.
Upload files
Section titled “Upload files”To put a file into an <input type="file">, keep the file in your checkout,
declare it in the flow’s frontmatter and name it in an upload statement:
---name: Submit an expenseurl: /expenses/newuploads: - path: fixtures/receipt.pdf bytes: 48213 sha256: 5f2b6c0e9d1a4b7c8e3f0a1b2c3d4e5f60718293a4b5c6d7e8f9a0b1c2d3e4f5 mimeType: application/pdf---
### Attach the receipt
```rflopen /expenses/newupload label="Receipt" fixtures/receipt.pdfexpect text="receipt.pdf"```upload is written bare, as upload <target> <path>: a target such as
label="Receipt", then the declared path. It is a statement of the language,
not a command of the Browser alias, so site.upload … or ui.upload … is not
a statement and planning refuses it.
Each entry has four fields:
| Field | Value |
|---|---|
path | The file, relative to the root of the checkout your target selects. No .., no absolute path. The upload statement names exactly this path. |
bytes | The file’s size in bytes: wc -c < fixtures/receipt.pdf. |
sha256 | Its SHA-256 as 64 lowercase hex digits: shasum -a 256 fixtures/receipt.pdf (or sha256sum). |
mimeType | The type the page receives, such as application/pdf or text/csv. |
A flow can declare at most 8 files, 16 MiB each and 64 MiB together. You can
also declare a guess and copy the values from the refusal: when the file in the
checkout differs from its declaration, reflow plan prints the file’s actual
bytes and sha256.
reflow plan and reflow apply check every declared file before anything
runs. They refuse, naming the flow, the path and the fix:
- a file that is missing from the checkout;
- a file whose size or SHA-256 differs from the declaration;
- a symbolic link, a directory or a path that passes through a symbolic link;
- an
uploadof a path the flow does not declare.
The worker that runs the flow reads the file again, checks it again and sends exactly those bytes to the page. The run keeps them as evidence, with an inventory of the declared files. That shows which file was selected; whether your application received and stored it is for your own assertions.
Changing a file means changing its declaration, and an edited declaration is an edit of the flow: the flow’s steps run again instead of reusing evidence.
Declared files are read from the checkout of the selected target, also when the flow itself is saved in Reflow instead of the repository. Commit the files so teammates and CI have them; a checkout without them is refused at plan.
A declared upload needs no code execution opt-in, because the flow pins the
bytes. An upload in a flow without uploads is different: its path is any
file on the device (a relative path resolves against the checkout root). That
is local file access, so it runs only when both reflow plan and
reflow apply are given --allow-code-execution (or
REFLOW_LOCAL_ALLOW_CODE_EXECUTION=1), and nothing is retained for it.
Without the opt-in reflow plan still succeeds and prints a note naming the
step and the path; reflow apply then fails the flow before a browser opens
and before any step starts. Prefer declaring.
upload accepts only the timeout modifier. It cannot be optional and
cannot be part of a | fallback chain. On a
held execution,
debug_execution act accepts an upload line under the same rules.
Run against different environments
Section titled “Run against different environments”Use a path for url. Reflow combines it with your selected target, so the same
flow can run against a local app, a PR preview or staging. An open command can
use an absolute URL to visit another origin.
Select the target with reflow target, inspect the work with reflow plan, then
execute it with reflow apply or reflow run. Your agent uses the same controller
through MCP’s manage_execution tool. Plugins run on the connected device, so
localhost reaches that device’s application.
The hosted API executes no flows.
TypeScript steps
Section titled “TypeScript steps”A flow with a Browser provider can also carry named TypeScript steps. They are
code, so a local run refuses them unless the device explicitly sets
REFLOW_LOCAL_ALLOW_CODE_EXECUTION=1 for flows it trusts:
```ts step="the checkout heading is visible"await page.goto(URL);await expect(page.getByRole("heading", { name: "Checkout" })).toBeVisible();```Within a ts step="…" fence, a body made entirely of valid RFL statements runs
as RFL. Otherwise, the complete body runs as TypeScript with page, expect
and URL in scope. Keep prose outside the fence: it is not valid TypeScript.
An empty fence is refused with [prose_step_removed]: no model runs inside the
runner to carry out the named step.
Prefer non-empty rfl fences. When a step fails, your coding
agent repairs and reruns it.