How Squiggle works
For AI agents: this page is Markdown at https://squiggle.sh/docs/how-it-works.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.
Squiggle has a part in your app and a part on your Mac. When you write tests, one rule matters most: a step that passes was sent, which is not the same as working.
The SDK, in your app
The SDK is the @squiggle.sh/react-native package. While your app runs, it keeps a live model of it: every component on screen, what rendered and why, store changes, network requests, the current screen, and what each tap set off. The docs call this model the runtime graph.
A React web app gets the same SDK without installing anything: Squiggle’s own Chrome window loads it into the page. To use your own browser instead, add the @squiggle.sh/react package. See React web apps.
Everything else in Squiggle reads that model. A flow finds the Add to cart button in it, Studio draws it, and a performance finding points at a component in it. If the SDK isn’t in your app build, Squiggle has nothing to read, so setup starts there.
The SDK only records while something on your Mac is connected to it. With nothing connected, it stays idle and costs close to nothing.
Studio and the CLI, on your Mac
Studio is the desktop app. It shows your simulator, the Inspector, performance and analytics, and it records and replays flows. The CLI is the squiggle command. It runs flows in your terminal and in CI, and it includes the MCP server that lets a coding agent drive your app.
Both talk to the same app, and both keep their files in one .squiggle/ folder at your project root, so a flow recorded in Studio runs from the terminal unchanged. The Project folder page lists what’s in it and what to commit.
To drive the simulator quickly, Squiggle runs a small agent inside your app. A debug build of your app on the simulator starts it by itself, however you launch the app: from Xcode, with expo run:ios, from Studio or by a flow. A build for a device never contains it, and a release build only if you keep Squiggle in it. The app loads the agent that came with your squiggle: after you update the command, the next one that launches or checks the app refreshes the copy it loads, and the app’s next launch uses it, without a rebuild. Troubleshooting explains how to tell when the agent is missing. A web app runs in Squiggle’s own Chrome window, which the first flow, agent tool or Studio that needs it opens and which stays open until you close it; Studio shows and drives that window too.
In a Niteshift task, Squiggle runs in the task’s Linux sandbox and the simulator is on another machine. The agent inside your app connects to Squiggle, Squiggle drives the app from inside, and anything outside the app, such as a launch, is a step for the task’s agent. See Niteshift tasks.
A passing step was sent, not proven
When a flow taps a button, the step passes once the tap reaches the button and the app reacts in any way: something renders, the screen changes or a field takes focus. It doesn’t check that the reaction was the right one, so a broken button that only shows its pressed state still passes. A tap that gets no reaction at all is handled as described below.
A touch can also be lost while your app’s JavaScript is busy, for example rendering data that just arrived: the touch reaches a row that is about to be replaced. So each tap first waits, for up to three seconds, until the app’s JavaScript answers promptly and the renders it was working on have landed. An idle app answers in a few milliseconds, so this adds nothing to most taps.
A touch can be lost while a screen is still moving, so a tap the app shows no reaction to is sent once more, once the screen has settled. It is sent again only when the first tap changed nothing: the control is still there, the same thing is under the finger, and the app’s JavaScript has caught up with the tap. If a control in your app moved after the first tap, such as a Send button riding up with the keyboard or a sheet springing into place, the second tap presses it inside the app, and the step’s detail says the target moved under the tap. A tap that closed a native alert, opened a search field, started a transition or moved a control iOS draws is never sent twice, and the step’s warning ends with (not sent again: …) and the reason. A step with delivery: real is always tapped through the device (see the flow reference). In a browser tab, where a click isn’t lost, it is never sent twice. A tap that puts a text field in focus counts as a reaction, though nothing on screen re-renders. A view settling by a point or two, or a row’s text fading in, doesn’t count as a change. If the second tap on one of your app’s controls gets no reaction either, and the same view is still under the finger, the step fails with the tap did nothing. A handler that changes only a worklet’s shared value or native state looks the same, so show something the tap changes and assert on it (see Troubleshooting). Mark a tap that is meant to change nothing optional: true. A control iOS draws can change without Squiggle seeing it, so a second silent tap on one passes with the warning no graph reaction … (retried). A tap on UI outside your app, such as a system sheet or Expo’s developer menu, is never sent twice: it fails with the tap did nothing when, for 2 seconds after it, that UI shows exactly what it showed before and your app doesn’t react.
To check that something happened, add an assert after the action. An assert looks at the screen again and fails when the result isn’t there. Try both versions of the same flow against a broken Add to cart button:
- tap: { testID: add-to-cart }- taptestID=add-to-cart
- ✔ PASS 1 of 1 steps
The button showed its pressed state, so the app reacted and the step passes. Nothing checked that the cart changed.
End every journey with an assert about what someone using your app should see. The flows page covers the kinds of assert you can write.