Flow syntax reference
For AI agents: this page is Markdown at https://squiggle.sh/docs/reference/flow.md. Every docs page is listed at https://squiggle.sh/llms.txt, and all of them are one file at https://squiggle.sh/llms-full.txt.
Every key a flow file can hold. For how to use them, start with Writing flows; this page is for looking things up.
Check flows in your editor
Put this line at the top of a flow file, and editors with YAML support complete keys and flag mistakes as you type. squiggle init adds it to the first flow it writes.
The schema always matches the newest Squiggle CLI, so your editor flags the flows squiggle flow refuses, apart from a few rules about agent steps. If the two disagree, update the CLI.
# yaml-language-server: $schema=https://squiggle.sh/schemas/flow-1.0.0.schema.jsonflow: checkoutTop-level keys
| Key | What it holds |
|---|---|
flow | The name you run the flow by. Required, with steps. |
steps | The list of steps. |
appId | The app’s bundle id. Flows called with runFlow inherit it. A flow whose appId is your iOS app also runs on the React web app that .squiggle/config.jsonc pairs with it under apps.web. |
env | Variables, used as ${NAME} in any string a step holds (a selector, a typed value, a URL, a when guard or an assertion) and in the flow’s goal and prerequisite. A step’s note is shown as written, and a name the flow does not define stays as written. |
secrets | Variables like env, whose values are never written to recordings or run logs. |
tags | Labels for the flow. A flow tagged probe measures your tools rather than a screen, and the report card never runs it to cover one. |
prerequisite | The screen the flow starts on: route, reset (auto, scroll, back or relaunch), app, and an optional goal. See Repeatable flows. |
healing | adaptive (default), strict or lossy-fallback. See Healing. |
goal | Checks, in the same form as assert, that must hold after the last step. |
config | Run settings the flow needs: autoScroll, scrollMode, fastSettle, strictAssert, stepDelayFloorMs, transitionSettleMs, chaos (a bad-network profile, for a flow that tests the error state), and softKeyboard (keep the on-screen keyboard up while it types). See Run settings. |
expect | For a flow that exists to catch a known bug: { verdict: fail, failure: <text> }. It passes only by failing with that text. |
intent · plan · onStuck · runWith | The form agents write: intent and plan instead of flow and steps. onStuck is escalate (stop and ask the agent) or fail (end the run); abort is read as fail. Without it, a flow ends the run on a failed step, and a program your agent runs with run_intent escalates. runWith names the command that runs the program, such as squiggle agent branch; squiggle flow refuses one that names another command (E_RUNS_WITH) and squiggle flows lists it with that command instead of running it. |
Any other key stops the flow from loading, as does a file that isn’t valid YAML (E_FLOW_PARSE). Quote a value that contains #, such as text: "Order #20": unquoted, YAML reads the rest as a comment.
Options on any step
These go inside the step’s body, for example - tap: { testID: promo-close, optional: true }:
| Option | What it does |
|---|---|
note | Names the step in the report. |
optional | The step may fail without failing the flow. |
when | Runs the step only if this condition holds: visible, notVisible or route, in the form assert takes them. When it names more than one, all must hold. |
Steps
Each step that an MCP tool also does takes the tool’s name in camelCase: the input_text tool is inputText (or type), scroll_until_visible is scrollUntilVisible, wait_for is waitFor. The step takes the tool’s arguments too, so a tool call you made while exploring becomes a step with the same arguments. Leave out observe, and replace a ref from a look with the testID or text it stands for; where the two name an option differently, both names work, such as timeout and timeoutMs on waitFor. A step name Squiggle doesn’t know fails the flow before it runs, and when the name is close to a step it knows, the error suggests it. To check every flow without running any, run squiggle agent validate --parse-only.
Act on a control
| Step | Options |
|---|---|
tap · doubleTap · longPress | A selector. expectRoute names the screen the tap opens: the step fails if the app is not on it within 5 s. On a macOS app, a doubleTap is two quick taps. |
pinch | A selector or point and scale (0.2–5, not 1): above 1 the two fingers spread apart to zoom in, below 1 they come together to zoom out. duration 100–5000 ms, default 400. On a macOS app, it reaches only a Gesture Handler pinch. |
type · inputText | into (a selector), or the selector written inline as input_text takes it, and value, and submit: enter to press Return after typing (any value of submit does the same). Replaces whatever the field held. With submit, Return is pressed once the field shows the text, and the step waits for the app to react to Return rather than to the typing, so the next step sees what Return did, such as a message being sent. keystrokes: true types key by key over the simulator keyboard instead of inserting the text, and fails on a dropped key. |
swipe | direction (up, down, left or right) and amount in points (default 200), or to: a percentage of the control. Optional selector, or a point to centre it on. A swipe with a direction never starts on a screen edge, where iOS would take the touch for Notification Center, Control Center, the home screen or going back. duration (50–5000 ms, default about 300) makes the drag slower; hold (1–3000 ms) keeps the finger still first, a long press that becomes a drag, such as reordering a list. On a macOS app, hold fails the step. |
drag | One touch along a path: from (a selector, or a point such as "50%, 60%") and path, 1–32 legs of to (a screen point, "50%, 40%" or { y: 40% }), duration (50–5000 ms, default 500) and pause (0–5000 ms, still at the end of the leg). The finger lifts only after the last leg. Optional hold (1–3000 ms) first. For a slow drag from one place to another, a pan of a zoomed photo or a map, or a sheet pulled back and forth. On a macOS app, only one leg and no hold. |
hover | A selector, and leave: true to move the pointer off the control instead of onto it. Runs the control’s hover handlers, so its hover card, tooltip or outline shows; no cursor moves. For web and Mac apps; a control with no hover handler fails the step. |
scroll | direction (where the content goes) and amount in points (default 200). Optional selector. |
scrollUntilVisible | element (a selector), direction, maxScrolls (default 15), timeout in ms (stops scrolling once that much time has passed, whichever of it and maxScrolls comes first), mode (gesture or direct). An element already on screen is not scrolled to. If it is still moving when the step starts, for example on a page that is still turning in, the step waits for it to stop before it decides whether to scroll. |
Selector fields are listed on Selectors.
tap, doubleTap, longPress, type, swipe, scroll, drag, pinch and hover also take delivery, which chooses how the action reaches the app. Any other value stops the flow from loading, and the error lists the three:
| delivery | What it does |
|---|---|
auto | The default: real whenever Squiggle can touch the device, else runtime. |
real | Touches and types through the device, as a person would. |
runtime | Runs the control’s own handler (onPress, onChangeText) inside the app through the Squiggle SDK, with no touch. Use it for a control that real taps keep missing. A type step with keystrokes: true can’t use it. |
The same steps, except hover, also take approve: why a step Squiggle blocks, such as a delete, is safe to run. See Safety and approvals for when a reason lets the step through.
A tap the app shows no reaction to is sent once more only when nothing on screen changed. If a control in your app moved after the first tap, the second one presses it inside the app. A tap that closed a native alert or opened a search field isn’t sent again, and its warning says why; a tap that puts a text field in focus counts as a reaction. Each tap waits until the app’s JavaScript is free to handle it. A tap on your app’s control that gets no reaction to either touch fails with the tap did nothing, also when its handler changes only a worklet’s shared value or native state (see Troubleshooting); give a tap that is meant to change nothing optional: true. See How Squiggle works.
Wait, pause and check
| Step | Options |
|---|---|
waitFor | One or more of route, commitQuiet (React stopped rendering), animationIdle and networkIdle: every one you give must hold at the same moment, so { networkIdle: true, commitQuiet: true } waits until the network is idle and React has stopped rendering. A timeout names which conditions held and which did not. Or appRunIdle (a run started elsewhere finished), on its own. Add timeout in ms (default 8000; timeoutMs also works, as the wait_for tool names it), or timeout: auto to take it from past runs. An app whose JS thread is blocked renders nothing, so commitQuiet and animationIdle read it as settled. The blinking cursor in a focused text field does not count as animation. Or visible / notVisible with a selector, on its own: waits until that control shows or goes away. Or ms, on its own and without a timeout: a fixed pause, the same as wait. If the app reloads or relaunches during the wait, for example after an openLink into a development build, the wait reconnects to it and keeps going within the same timeout. |
wait | A fixed pause of that many milliseconds, such as wait: 1500, the sleep other tools have. It always passes; use it only for an app that shows nothing to wait on, and use waitFor with a condition when the app shows one. To add an option, write it as wait: { ms: 1500, note: settle }. |
assert | One or more checks. See the table below. |
assertVisible · assertNotVisible | A selector. The same as assert: { visible } and { notVisible }. |
App and device
| Step | Options |
|---|---|
launchApp | app, relaunch (ifNeeded by default, or always), clearState (wipes app data and relaunches), seed (React web apps: cookies, localStorage and sessionStorage the first page load reads; reopens the app; unsupported on iOS). |
stopApp | app. |
back | Goes back: an edge swipe in the simulator, history back in a React web app. If that doesn’t change the screen, for example because a horizontal pager took the swipe, the step taps the header’s back button instead. If neither changes the screen, the step still passes and its detail says the screen didn’t change. Your app can report its new route late: while it is busy, or only once the screen has finished animating out (a swipe back on iOS 26 takes over a second to finish). So before it decides the screen didn’t change, the step waits at least 900 ms after going back, 600 ms more once the screen stops moving, and longer while your app is busy, up to 5 seconds in all. It never taps the back button of the screen it already returned to. A back that changes nothing on a still screen takes about a second to say so. When your app doesn’t report its route, Squiggle watches which components go away. If too few go away to tell a new screen from, say, a spinner finishing, or your app reports no components either, it never taps the button, and the detail says the result is unknown. |
pressKey | A key, named as a browser’s KeyboardEvent.code names it: Enter, Escape, Backspace, Tab, Space, ArrowUp, KeyA, Digit1. Home presses the Home button, and Back goes back as the back step does. |
navigate | route: goes to a screen through your app’s navigator. |
openLink | A URL or deep link, or { url, expectRoute }. The step ends once the app reacts to it, and any render counts, including one the link did not cause. expectRoute names the screen the link opens: the step fails if the app is not on it within 5 s, so a link the app drops (one that arrives while the app is still starting, say) fails instead of passing. If the link reloads the app, for example a link into a development build, the step waits for the app to reconnect, so the next step sees the reloaded screen. After a stopApp step, Squiggle doesn’t reconnect to the app the link opens: the step passes and says the app has not reconnected, and an expectRoute fails at once, saying the app’s connection closed and it did not come back. Add a launchApp step after the link so the steps that follow reach the app. If iOS asks “Open in …?” first, Squiggle presses Open. |
setLocation | latitude and longitude: the location the app reads from now on. On the iOS simulator it stays set for the whole simulator until something sets it again; on a React web app it lasts until the run ends. Reported as unsupported on macOS. |
setPermissions | permissions, each allow, deny or unset, set in the order written with no system prompt, for the flow’s appId (or the step’s app). On the iOS simulator: location, contacts, calendar, reminders, microphone, motion, medialibrary, siri or all, and photos: unset only (iOS still asks after an allow or deny set this way). iOS closes the app to apply some changes, such as photos or the microphone; the step then opens it again on its first screen. On a React web app: location, camera, microphone, notifications, clipboard, midi or all. A name the target doesn’t have is reported as unsupported and nothing is set. Reported as unsupported on macOS. |
addMedia | Files, as a list, relative to the flow’s folder. On a React web app the page’s next file chooser gets them; on the iOS simulator a photo or video goes to the photo library and any other file to On My iPhone. Reported as unsupported on macOS. |
network.stub | urlMatch, and the response: status, body, headers, method, delayMs. network.stub: clear removes all stubs. A flow with a stub turns on network capture for its run by itself; see Repeatable flows. |
showKeyboard | Opens the on-screen keyboard on an iOS simulator and keeps it up while text is typed. Name the field to focus, as in showKeyboard: { testID: email }; without one, it opens on the field that has focus. The step fails if the keyboard does not appear. hideKeyboard, or the end of the run, turns this off again. Needs Squiggle running in the app. |
hideKeyboard | Puts the keyboard away: the focused field gives up focus. On iOS it needs Squiggle running in the app; on a React web app it blurs the field; on macOS it is reported as unsupported. |
device | A device tool call, with one of its arguments: hideKeyboard: true or showKeyboard: true does what those steps do, location: "45.815,15.9819" (or a place such as London) is setLocation, and permission: { action: revoke, service: microphone } is setPermissions (grant is allow, revoke is deny, reset is unset). The tool’s other settings, such as appearance, textSize, statusBar and softKeyboard, fail the flow before it runs: set them before the run with squiggle device, or for the keyboard use the flow’s config: { softKeyboard: true }. button and shake fail it too: press a button with squiggle device button or shake with squiggle device shake, or have your agent call the device tool, on its own or as a batch step. A saved flow writes the step the call stands for. |
On a React web app, route and navigate follow the page’s URL path, with React Router, TanStack Router, or the Next.js App Router or Pages Router, and steps that need a hardware button don’t apply. See React web apps.
Browser tab
These run on a React web app and are reported as unsupported on iOS and macOS. What they set lasts until the run ends.
| Step | Options |
|---|---|
travel | points, as "latitude, longitude", and speed in m/s. The step lasts the trip. |
setOrientation | PORTRAIT, LANDSCAPE_LEFT, LANDSCAPE_RIGHT or UPSIDE_DOWN: turns the viewport. |
setAirplaneMode · toggleAirplaneMode | setAirplaneMode takes enabled or disabled, and the tab goes offline or back online. toggleAirplaneMode takes no value and flips it. |
takeScreenshot | A name: writes name.png where you ran the flow. |
startRecording · stopRecording | A name: writes name.mp4 where you ran the flow. Needs ffmpeg installed. |
evalScript | An expression, evaluated in the page. The step shows its value; a throw fails it. |
runScript | file, relative to the flow, and env: runs in the page with env in scope, and can return a value. |
emulate | viewport (phone, tablet, desktop or { width, height }), colorScheme (light or dark), locale (such as de-DE), userAgent (the user agent string, and the client hints it implies), cpuThrottle (how many times slower the page’s CPU runs, 1 to 20, for the rest of the run). Each is set on its own: a phone viewport keeps the browser’s user agent. |
Reuse and control
| Step | Options |
|---|---|
runFlow | file, relative to the flow it is written in, and env to override its variables. A file not found there is looked up by the same path in .squiggle/flows, so runFlow: { file: login } runs .squiggle/flows/login.yaml, and steps/a.yaml can run steps/b.yaml written from the flows folder. If neither exists, the step fails naming both paths it tried, and squiggle agent validate reports it before a run. When a step inside it fails, squiggle flow names that step on a line under the runFlow row, with its position, kind, selector and detail (failed at step 1.3 tap testID=pay: …), and the run’s file in .squiggle/runs and run_flow’s answer carry it as failedStep. repeat, retry and branch do the same. In a flow passed as text (squiggle flow --inline, flow -, or your agent’s run_flow with yaml), file starts at the project folder. |
repeat | commands, and times or while (a condition). |
retry | commands and maxRetries. |
branch | if (a condition), then, and else. |
agent | A goal, or goal with rounds, timeout and hints. Must be followed by an assert. See Agentic flows. |
escalate | reason: stops and asks the agent running the program. In a run with no agent to answer, such as squiggle flow, it reports pending. |
Assertions
assert, goal and the if of a branch take these; when takes only visible, notVisible and route. Numbers compare with lt, lte, gt, gte, eq, or in with a list, such as { in: [1, 2] } (memory and network take all but in). Any other operator, or an empty {}, stops the flow from loading; action: { checkout: {} } still means at least once. A store’s eq and in also take text, true or false.
| Check | Form |
|---|---|
visible · notVisible · exists | { visible: <selector> } |
route | { route: OrderConfirmation } |
rerenders | { rerenders: { CartRow: { lt: 3 } } } |
droppedFrames | { droppedFrames: { lt: 2 } } |
store | { store: { useCart.mutationCount: { gte: 1 } } }: a Zustand store by the variable it is declared as, and how many times it changed. { store: { useCart: {} } } checks that it exists. |
query | A TanStack Query, its status or fetch count. |
log | { log: { contains: … } }, { log: { regex: … } } or { log: { field: …, equals: … } } |
action | { action: { checkout.submit: { eq: 1 } } } |
visual | noOverlap, noClipping, onScreen, noBlankFrame or legibleContrast, as a name or a list. |
memoryDelta | { memoryDelta: { lt: 20MB } }, across the step before. Bytes, or a size in KB, MB or GB. |
scroll | { scroll: { fps, droppedFrames, blank, churn, list } }, after a scroll step. Every part is optional: fps and droppedFrames default to the screen’s budget, so scroll: {} is valid. |
smooth | { smooth: { region: <selector>, gapFrames, droppedFrames, jsDriven, jankFrames, stallMs, smoothness, ms } }, after the step that starts the motion. region is required; droppedFrames defaults to the screen’s budget. jankFrames, stallMs and smoothness follow the region’s element by testID at every frame for ms (default 2000, at most 10000). |
memory · network | Checked against the memory and network data the app sends; with none, reported as pending. |
gesture | Accepted, and reported as pending. |
Steps Squiggle reads but doesn’t run
These Maestro commands load without an error and are reported as unsupported: eraseText, copyTextFrom, pasteText, clearKeychain, assertWithAI, assertNoDefectsWithAI, extractTextWithAI and assertScreenshot. On iOS and macOS, so are the browser tab steps. Your editor accepts them too, so a Maestro flow opens without errors. See Coming from Maestro.