> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mobster.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Add steps, save checks and script them

> Add plain-English steps to a check, save it to your project, and branch on its exit code in a script.

A check with steps proves a flow, not only a first screen. You write the steps in plain English, Mobster drives them with a model on your Claude or OpenAI key, and your expectations decide the verdict. No model grades the outcome. To let your coding agent drive the steps with no key, use [the key-less loop](https://docs.mobster.dev/mcp-server.md#the-key-less-loop).

## Add steps

**1. Write the steps and the expectations**

Each quoted argument is one step. This check opens a bookmark in Firefox for iOS and expects the page to load. Write each expectation so it holds only after the steps:

```sh theme={"theme":"css-variables"}
mobster verify "Open Bookmarks and tap Mozilla." --name "The Mozilla bookmark opens mozilla.org" \
  --bundle org.mozilla.ios.Firefox --text mozilla.org \
  --expect '{"count": {"role": "link"}, "at_least": 1}' \
  --absent label=Bookmarks,role=navbar
```

Mobster reads the key from `ANTHROPIC_API_KEY` or `OPENAI_API_KEY`, or from the file `--env-file` names.

**2. Read the verdict**

It prints the verdict, one line per expectation, the report and the command that runs the check again. The exit code is the verdict.

With no key set, it stops before it starts a simulator and exits 3:

```text theme={"theme":"css-variables"}
✗ couldn't run  The Mozilla bookmark opens mozilla.org  (0.1 s)
  These steps need Smart, and no OpenAI or Anthropic key is set.
  Set OPENAI_API_KEY or ANTHROPIC_API_KEY for Smart, or let your coding agent drive through `mobster mcp`.
  Report  .mobster/runs/20261113-104809-1d5a/report.html
  Rerun   mobster verify --check .mobster/runs/20261113-104809-1d5a/check.yaml
```

If every expectation already holds right after launch, the run ends `needs_review`: it doesn't show that the flow works.

| Flag | Default | What it does |
| - | - | - |
| `--max-usd` | 0.25, at most 1.00 | Caps the run's spend. The result's `cost_usd` is what it spent |
| `--max-seconds` | 180, at most 600 | Caps the time the steps may take |
| `--env-file` | `$MOBSTER_ENV_FILE` | Loads `ANTHROPIC_API_KEY=…` or `OPENAI_API_KEY=…` from a file only you can read. Variables already set win |
| `--name` | the first step | The check's name in the output and the report |

The steps run on Claude whenever an Anthropic key is set, and on OpenAI with an OpenAI key alone or with `MOBSTER_SMART_PROVIDER=openai`. `MOBSTER_SMART_MODEL` picks another model, and then only that provider's key will do. The run sends each screen's image and accessibility text to that provider. Launch-only and key-less runs send nothing anywhere.

## Save the check

Add `--save NAME` to any run to keep its check as `.mobster/checks/NAME.yaml`. The command above with `--save mozilla-bookmark` prints `Saved .mobster/checks/mozilla-bookmark.yaml` before the verdict.

When the run passes, Mobster also keeps the steps Smart took, and the `Saved` line says how many of them `mobster test` replays with no model and no key. Text Smart made up, rather than text your steps spell out, needs Smart on each run. A run that doesn't pass still saves the check, and its first `mobster test` runs Smart. A run of a check file (`--check`) records nothing.

The file's first line names the check's [JSON Schema](https://docs.mobster.dev/checks.md#autocomplete-in-your-editor):

```yaml .mobster/checks/mozilla-bookmark.yaml theme={"theme":"css-variables"}
# yaml-language-server: $schema=https://mobster.dev/schema/check.json
# A Mobster check. Run it with: mobster verify --check <this file>
version: 1
name: The Mozilla bookmark opens mozilla.org
app:
  bundle: org.mozilla.ios.Firefox
steps:
- Open Bookmarks and tap Mozilla.
relaunch: []
expect:
- text: mozilla.org
- count:
    role: link
  at_least: 1
- absent:
    label: Bookmarks
    role: navbar
```

Mobster saves the check even when the run couldn't run, so you can fix the setup and run it again. Edit the file and commit it. Run it with:

```sh theme={"theme":"css-variables"}
mobster verify --check .mobster/checks/mozilla-bookmark.yaml
```

[Checks](https://docs.mobster.dev/checks.md#the-check-file) documents every key.

## Use the verdict in a script

The exit code is the verdict:

| Exit | Verdict | Means |
| - | - | - |
| 0 | `passed` | The assertions and execution checks passed |
| 1 | `failed` | An assertion or another check failed, such as crash detection |
| 2 | `needs_review` | The run needs review, for example because evidence or required measurements are missing |
| 3 | `couldnt_run` | The run could not finish, for example because of an invalid check, an execution error or a resource limit |

With `--json`, or when stdout isn't a terminal, stdout carries one JSON object, [the result](https://docs.mobster.dev/checks.md#the-result-json). Progress goes to stderr. Branch on the exit code and read the result with `jq`:

```sh check.sh theme={"theme":"css-variables"}
mobster verify --check .mobster/checks/mozilla-bookmark.yaml --json > result.json
case $? in
  0) echo "bookmark check ok" ;;
  1) jq -r '.summary, .report' result.json; exit 1 ;;
  *) jq -r '.reason.message' result.json; exit 1 ;;
esac
```

With no key set, `sh check.sh` takes the last branch, exits 1 and prints:

```text theme={"theme":"css-variables"}
These steps need Smart, and no OpenAI or Anthropic key is set.
```

## Next

> [card] [Run every check](https://docs.mobster.dev/testing.md)
>
> `mobster test`: simulators and your iPhone, retries, flaky checks, JUnit and HTML.

> [card] [Checks reference](https://docs.mobster.dev/checks.md)
>
> The check file, every assertion and the verdict rules.

> [card] [When a check couldn't run](https://docs.mobster.dev/troubleshooting.md#checks)
>
> Each `reason.class` and its fix.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.