# Your first flow

Run the flow squiggle init wrote, then record a sign-in journey, turn it into a flow and make it check that the sign-in worked. You need a set-up app running in the simulator.

If you haven’t set up your app yet, start with [Set up your app](https://squiggle.sh/docs/setup).

## Run the smoke flow

`init` wrote `.squiggle/flows/smoke.yaml`. It waits for the app to settle and checks that the screen isn’t blank (`visual: [noBlankFrame]`). Run it by name:

```shell
squiggle flow smoke
```

You see each step as it runs, then `PASS` or `FAIL`. If it fails, the output names the step and saves a screenshot of the simulator under the failing step.

## Record a journey

Writing a flow from a blank file is slow. Instead, use the app while Squiggle records, and let it draft the flow:

```shell
squiggle record login
# use the app: sign in as you normally would, then press Ctrl-C
```

This saves `.squiggle/recordings/login.sqrec`. Turn it into a flow:

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

The draft lists each tap and screen change. When a tap hit something with no `testID` or label, the draft says so. Add a `testID` to those controls in your code, so the flow can find them again after the layout changes.

You can also record in Studio, from the Flows screen:

## Make it check something

A recording shows what you did, not what should happen. Until you add an `assert`, the flow passes as long as each tap is sent, even if sign-in is broken. Add one at the end, for something you only see after a successful sign-in:

```yaml
flow: login
steps:
  - type: { into: { testID: email-input }, value: dana@example.com }
  - type: { into: { testID: password-input }, value: correct-horse }
  - tap: { text: Sign in }
  - assert: { visible: { text: "Welcome back, Dana" } }
```

Run it:

```shell
squiggle flow login
```

> **If the second run fails at the first step**
>
> A flow starts from wherever the app is. After this flow, you’re signed in, so the next run can’t find the email field. Run with `--fresh` to relaunch the app first, or give the flow a starting state (see [flows](https://squiggle.sh/docs/flows)).

## Run it in Studio

Studio lists the flows in `.squiggle/flows/`, runs them on the simulator you’re watching, and shows each step’s result beside the screen. Studio is the Mac app; if you installed only the `squiggle` command, get Studio here:

[Get Squiggle](https://squiggle.sh/download)

## Next

Run the flow again every time you save a file in your app:

`squiggle watch login`

- [Writing flows](https://squiggle.sh/docs/flows): selectors, every step and the asserts you can write.
- [Agentic flows](https://squiggle.sh/docs/agentic-flows): write a step as a goal and let your coding agent work out the taps.
