Skip to content

Write a flow

A flow is a Markdown document saved in Reflow or in your repository, run with reflow plan and reflow apply. YAML frontmatter declares its configuration, prose explains intent, and named fenced steps execute the check. Markdown outside those fences is context only: it is never executed. Every step contains RFL statements. No model runs inside the runner, so a step with an empty fence is refused; your coding agent writes the statements.

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.

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–4
needs: [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–7
providers:
  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–10
inputs:
  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–20
site.expect selector="[data-testid=discount]" text="10%"
site.snapshot name="discount-applied"
```
checkout.md
---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"```

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 orders
providers:
db: PostgreSQL
inputs:
orderLimit: {type: integer, default: 10}
---
### Capture recent orders
```rfl
db.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:

Terminal window
reflow target --group orders --bindings /absolute/path/to/connections.json --inputs /absolute/path/to/inputs.json
reflow plan
reflow apply

Use 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 without opening a browser or connecting to a plugin:

---
name: Choose order test data
inputs:
unitPrice: {type: number, default: 25}
---
### Generate the order
```rfl
capture suffix = random.string length=12
capture quantity = random.integer min=1 max=5
capture orderId = "test-${suffix}"
capture total = expression "number(${quantity}) * number(${inputs.unitPrice})"
```

The consumer declares the dependency and the outputs it reads. This .reflow/flows/check-order.md example prints a summary through LocalBash; replace the command with your application’s check when adapting it:

---
name: Check the generated order
needs: [seed-order]
providers:
worker: LocalBash
references:
needs.seed-order.outputs.orderId: {type: string}
needs.seed-order.outputs.quantity: {type: string}
needs.seed-order.outputs.total: {type: string}
---
### Show the order values
```rfl
worker.bash command="printf 'Order %s / quantity %s / total %s\\n' '${needs.seed-order.outputs.orderId}' '${needs.seed-order.outputs.quantity}' '${needs.seed-order.outputs.total}'"
```

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:

Terminal window
reflow plan .reflow/flows/check-order.md
reflow apply .reflow/flows/check-order.md

The 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.

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 administrator
url: /login
providers:
site: Browser
inputs:
email: {type: string}
outputs:
userId: {type: string}
---
### Sign in
```rfl
fill label="Email" "${inputs.email}"
click role=button name="Sign in"
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 details
providers:
site: Browser
inputs:
adminEmail: {type: string}
---
### Sign in
```rfl
use sign-in-admin as admin email="${inputs.adminEmail}"
```
### Open billing
```rfl
site.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.

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-menu

expires 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.

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.

FieldPurpose
nameDisplay name of the flow.
providersAliases for plugins and their private connection names.
pluginsPlugin name, source commit and descriptor digest from the installed catalog.
inputsTyped parameters with optional defaults.
referencesTypes of values read from other flows.
outputsCaptures 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.
urlStarting path for a browser flow, such as /checkout.
needsFlow slugs that must complete before this flow runs.
prerequisitesChecks and optional setup before the steps.
coversRepository globs used to select flows affected by a change.
goldenValidation marker: runs lists 1-8 IDs of the passing runs that validated this flow and its needs ancestors; environment is an optional label. It is not part of step identity, so with a golden-capable CLI (reflow help plan lists --golden) writing or rewriting it never re-runs steps. Older CLIs count it as step input: their local plan and apply re-run the flow’s steps after the block is written or changed. Agents load the golden-authoring skill for the golden check before writing it.
uploadsFiles the flow’s upload statements may select, each pinned by size and SHA-256. See upload files.
tagsOne to three words that say what the flow is for, such as tags: [golden, v2] or tags: [pr-8839]. See tags.
invariantsRFL expect assertions, one per entry, such as expect text="Ready". They are checked against the Browser page once, at the end of a run in which every step passed; a failed one fails the run. An entry that does not parse as RFL is refused at planning.
browserBrowser engine; local browser flows use Chromium.
devicePlaywright device preset for browser emulation.
timeoutHow long the whole flow may run, such as 5m (500ms, 30s, 5m, 8h or 1d). A run on your device lasts as long as this allows, and a few minutes more for preparation and clean-up; a flow without one is stopped after 31 minutes, and reflow plan notes a step whose timeout= is longer than that. Each provider call (for example a long LocalBash command, or a provider’s launch) gets whatever remains of it, and never more than 30 minutes; without a timeout each call may take up to 30 minutes. So saving a flow (flows create or flows save) refuses a statement timeout= longer than 30 minutes on a typed plugin call or a Browser statement (an email wait reads the mailbox and may wait longer), and a run fails that step before the call: split longer work into several statements and give the step and the flow the whole time. A step that reaches a time limit (its statement’s, its own, the flow’s, the 31 minutes of a flow without one, or the 30 minutes of one provider call) fails with a message that names the limit, and the next plan runs it again without reflow taint. A step sets its own in its fence (```rfl timeout=45s) and a statement with timeout=; 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, because no model runs inside the runner. See 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-8839 is 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 plan lists --tag; older CLIs count tags as step input and re-run a flow once after its tags change.
  • Reuse, do not invent. reflow flows tags lists the tags in use with their flow counts. Pick from it before adding a new word, so v2 does not end up beside v2-suite and V2Suite.

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:

Terminal window
reflow flows tags # every tag and how many flows carry it
reflow flows list --tag v2 --exclude-tag scratch # matching flows, golden mark, tags
reflow plan --tag v2 --tag shard-a # flows carrying both
reflow apply --tag pr-8839
reflow 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 20 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.

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 expense
url: /expenses/new
uploads:
- path: fixtures/receipt.pdf
bytes: 48213
sha256: 5f2b6c0e9d1a4b7c8e3f0a1b2c3d4e5f60718293a4b5c6d7e8f9a0b1c2d3e4f5
mimeType: application/pdf
---
### Attach the receipt
```rfl
open /expenses/new
upload label="Receipt" fixtures/receipt.pdf
expect 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:

FieldValue
pathThe file, relative to the root of the checkout your target selects. No .., no absolute path. The upload statement names exactly this path.
bytesThe file’s size in bytes: wc -c < fixtures/receipt.pdf.
sha256Its SHA-256 as 64 lowercase hex digits: shasum -a 256 fixtures/receipt.pdf (or sha256sum).
mimeTypeThe 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 upload of 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.

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.

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.