# Record and crawl

The fastest way to a first flow is to use the app and let Squiggle write down what you did. To find crashes and journeys you haven't thought of, let the crawler explore the app on its own.

## Record in Studio

On the Flows screen, press **Record** and use the app in the simulator. Each tap, text entry and scroll becomes a step. Press it again to stop. The screen you started on is saved as the flow’s starting point, so the flow can return there before each run.

## Record in the terminal

`squiggle record` records until you press Ctrl-C. Then turn the recording into a draft flow:

```shell
squiggle record checkout
squiggle flow --from-recording .squiggle/recordings/checkout.sqrec -o .squiggle/flows/checkout.yaml
```

A recording shows what you did, not what should happen, so review the draft and add an `assert` at the end (see [Assertions](https://squiggle.sh/docs/flows/assertions)). The draft lists any tap on a control with no `testID` or label, with its position. Give those controls a `testID`; without one, the step can only tap a position, which breaks when the layout changes.

The draft keeps taps and the screens they led to. Of the drags, it keeps only a swipe that closed a screen, such as a sheet you swiped down: that becomes one `swipe` step labelled `dismiss` and the screen, followed by a wait for the screen it went back to. Scrolls and other drags are left out, so add those by hand if the flow needs them.

## Let the crawler explore

`squiggle crawl` drives the app on its own. It fills in text fields, taps controls, goes deeper when a tap opens a new screen, and goes back when a screen has nothing left to try. It reports the screens it reached, any crashes, and a draft flow for what it found.

```shell
squiggle crawl --seed 7 --duration 60
```

| Flag | What it does |
| --- | --- |
| `--seed <n>` | Makes the crawl repeatable: the same seed takes the same path. |
| `--duration · --max-nodes · --max-depth` | When to stop: after this many seconds (30), screens (50) or levels deep (5). |
| `--complete` | Keeps going until every reachable screen is visited, then lists the screens your app declares that it couldn’t reach. |
| `--from <route>` | Starts from one screen. |
| `--changed` | Visits only the screens built from files changed on your branch. |

The crawler skips controls whose names say they log out, delete, pay, buy, check out or close an account. It exits with code 1 if the app crashed, so you can run it in CI. In Studio, use **Crawl app** in the Flows screen’s flow tools; the flow it finds opens in the editor.

The screens a crawl visits are added to the Screen map. To find the screens no flow reaches yet, see [Find what to test](https://squiggle.sh/docs/agentic-flows/coverage).
