Set up CI
In CI, one job runs keepsnappy run --upload. It reads keepsnappy.yml, runs your journeys, and uploads the measurements as one session. Getting started has init write it. This page has a complete workflow to write by hand, its timeout, and required or advisory checks. Every keepsnappy.yml setting, the flags of keepsnappy run and its exit codes are on keepsnappy.yml and run flags.
Budget the first session
Each journey runs 5 times per session by default, from the CLI’s repetitions default. A session is one job, not one run. Estimate the job timeout as build + repetitions × journey time + overhead. Journey time is one pass of all selected journeys; with a command runner the whole command (even a 68-file suite) is one journey. Build and install time count against the CI timeout, but are not measured journey time. Overhead includes dependency setup, activation and flush, upload and up to 10 minutes of waiting for the result with --wait.
The starter workflows allow 20 + 5 × 10 + 20 = 90 minutes: a 20-minute build, a 10-minute pass of the selected journeys and 20 minutes for setup, upload and the wait for the result. That exceeds 60 minutes, so init and the matching examples use timeout-minutes: 90. Init raises shorter numeric job timeouts, preserves larger ones, and asks you to check expression-based timeouts. This is a planning example, not a measured promise: time your own build and journeys and leave headroom. Longer suites need a larger timeout or a smaller selection. Existing workflows already written by init are yours to update.
For a shorter first session, run npx --no-install keepsnappy run --repeat 3 --upload --wait after building and installing the app, or put a smaller repeatable selection in flows.paths (Maestro) or flows.command (your runner’s file/spec filter). For that sample, 20 + 3 × 10 + 20 = 70 minutes. At least 3 valid runs doing the same work are still needed for comparison; a lower requested count does not change the rules. Three sessions of main remain separate jobs, each with its own build and runs.
Init warns when your suite looks too big for the job’s timeout. Its estimate assumes one minute per test file or Maestro flow and does not read your runner’s filters, so a missing warning doesn’t prove the suite is small: time your own job.
A full keepsnappy.yml with every setting, and a custom simulator set, are on keepsnappy.yml and run flags.
A complete workflow
keepsnappy init writes this kind of file from your own end-to-end job. To write it by hand, put keepsnappy.yml in the repository root (keepsnappy.yml), then add the workflow. It runs on every pull request, on every push to main, every night at 03:00 UTC, and by hand from the Actions tab.
name: KeepSnappyon: pull_request: push: branches: [main] # your default branch schedule: - cron: '0 3 * * *' workflow_dispatch:jobs: keepsnappy: runs-on: macos-15 timeout-minutes: 90 env: KEEPSNAPPY: '1' steps: - uses: actions/checkout@v4 with: ref: ${{ github.event.pull_request.head.sha || github.sha }} fetch-depth: 0 - uses: actions/setup-node@v4 with: node-version: '24' - run: npm ci - name: Boot a simulator run: | UDID=$(xcrun simctl list devices --json | jq -r '[.devices[][] | select(.name == "iPhone 16" and .isAvailable)][0].udid') xcrun simctl boot "$UDID" || true xcrun simctl bootstatus "$UDID" -b echo "SIMULATOR_UDID=$UDID" >> "$GITHUB_ENV" - name: Build and install the KeepSnappy build run: | npx expo prebuild --platform ios npx expo run:ios --configuration Release --device "$SIMULATOR_UDID" - name: Install Maestro run: | curl -fsSL "https://get.maestro.mobile.dev" | bash echo "$HOME/.maestro/bin" >> "$GITHUB_PATH" - name: Measure with KeepSnappy env: KEEPSNAPPY_KEY: ${{ secrets.KEEPSNAPPY_KEY }} run: > npx @keepsnappy/agent run --upload --wait --device "$SIMULATOR_UDID" --commit ${{ github.event.pull_request.head.sha || github.sha }}Each job is one session. The tool reads the branch from GitHub. To try the measure step on your machine, add --branch with your branch name.
- The checkout takes the pull request’s own commit, not GitHub’s merge commit, and
--commitreports that same commit. fetch-depth: 0fetches the full history, so KeepSnappy can find where the branch leftmain.- The build and the measurement both use the simulator the first step booted.
- The nightly run keeps the history of
mainfresh. - Keep the Install Maestro step if the workflow runs Maestro through
flows.commandor after--, as well as withflows.runnerset tomaestro. Omit it when the test command does not use Maestro.
With pnpm or yarn, replace the npm ci step. A bare React Native app (no expo prebuild) links the SDK’s native module after the install:
jobs: keepsnappy: steps: # pnpm: the action reads the pnpm version from packageManager in package.json - uses: pnpm/action-setup@v4 - run: pnpm install --frozen-lockfile # yarn 2 or newer, instead - run: yarn install --immutable # bare React Native, after the install - run: cd ios && pod installA bare React Native app also replaces the two build lines with the xcodebuild and xcrun simctl install lines of Try it on your Mac, with "$SIMULATOR_UDID" as the simulator.
Commit keepsnappy.yml, metro.config.js, app.json, package.json and its lock file, and the workflow. A bare React Native app also commits ios/Podfile.lock. Add keepsnappy-out/ and .keepsnappy/ to .gitignore: each session writes its runs there.
In a repository set up by init, @keepsnappy/agent is a dev dependency, so npx --no-install keepsnappy run works. By hand, either add it as a dev dependency (Install the CLI) or keep npx @keepsnappy/agent run as above.
These commands always use the latest release. To pin a version in CI, add it after the package name, e.g. @keepsnappy/agent@<version>. The compatibility table lists the versions that work together.
How a result is decided says what the job prints after the upload and when the result appears.
What init writes in your workflow
Init writes a separate .github/workflows/keepsnappy.yml from your own end-to-end job, with two changes: KEEPSNAPPY: '1' in the job’s env, so the build sees it, and your test command wrapped in keepsnappy run.
jobs: keepsnappy: env: KEEPSNAPPY: '1' steps: - uses: actions/checkout@v4 with: ref: ${{ github.event.pull_request.head.sha || github.sha }} fetch-depth: 0 - run: npx expo run:ios --configuration Release - run: npx --no-install keepsnappy run --upload --wait --commit ${{ github.event.pull_request.head.sha || github.sha }} -- <your end-to-end test command>This shows only the lines that change: the whole file, with the simulator, Maestro and the key’s env:, is above. Your existing workflows and app code are not touched. Step markers in your tests are optional: results are correct without them.
Before init has run, npx --no-install keepsnappy does not exist: add @keepsnappy/agent as a dev dependency (Install the CLI) or run npx @keepsnappy/agent run.
Init’s workflow runs on pull requests, pushes to the default branch and by hand. It adds a nightly run at 02:17 UTC only if you answer yes when init asks, or pass --nightly. Otherwise, to keep main fresh when nothing is merged for a while, add a schedule under on: in .github/workflows/keepsnappy.yml, next to pull_request, push and workflow_dispatch. This runs it on main every night at 03:00 UTC, as the complete workflow does:
on: schedule: - cron: '0 3 * * *'Builds that send their own measurements
The complete workflow is for the iOS simulator, where the keepsnappy command reads the measurements from the simulator. On Android, and on real phones on BrowserStack, the app sends its own. Its build needs two values in the build environment, never in app.json:
EXPO_PUBLIC_KEEPSNAPPY_KEY: the SDK key. It is a different key from the CI key, and the CI key can’t read or make it.EXPO_PUBLIC_KEEPSNAPPY_INGEST_URL: the API address.
Setup, step 1, in the dashboard shows both values, under Builds that send their own measurements. SDK lists every build variable.
Some apps require a fresh run token on every upload from the SDK (require_run_token): a short-lived token that KeepSnappy gives each run when the CLI opens it. The SDK sends it in the x-keepsnappy-run-token header, so activate the app with the token of the current run. run_token_required means the token is missing. run_token_expired means you start a fresh run and activate the app again. When the CI key that made a token is revoked or expires, its tokens stop working for these apps too. Other apps upload with the SDK key alone.
Android, on an emulator in your CI
Start with keepsnappy init --detect. If the plan names your Android emulator job, follow the steps it prints. If init cannot use the job, follow the manual setup in Android. The e2e (e2e.com) Android template (e2e) sets EXPO_PUBLIC_KEEPSNAPPY_INGEST_URL from the repository variable KEEPSNAPPY_API. Make a Release build has the Android build commands.
For an Android phone on a cable, see Android.
Real phones on BrowserStack
Real phones on BrowserStack, iOS or Android, run through the farm command, in place of keepsnappy run. During the pilot, the KeepSnappy team sets these runs up with you (Real phones on BrowserStack).
The flags of keepsnappy run and what each exit code means are on keepsnappy.yml and run flags.
Required or advisory checks
This section explains verdict_gate; other pages link here. Exit codes has every exit code.
During the pilot, keep verdict_gate: advisory, which init writes, and do not make the KeepSnappy check required: a blocking Worse then passes the check, and a false alarm is marked on the dashboard. With verdict_gate: blocking or no verdict_gate, that Worse leaves the check red, and a mark does not turn the check green (False alarms). With a CLI release that sends your gate setting, Slack, the dashboard and the MCP server then say Would block the merge; advisory during the pilot, CI passes.
The verdict gate fails only on blocking Worse, and only with verdict_gate: blocking or no verdict_gate: with --upload --wait, a blocking Worse on a pull request then exits 3. With verdict_gate: advisory it exits 0 (below). Worse (not blocking), Slightly worse, Can’t tell and not judged pass. A verdict timeout is a separate failure (4); build, configuration and infrastructure errors can also fail the job.
To block merging, set verdict_gate: blocking in keepsnappy.yml (or leave the key out), keep --upload --wait, let the measurement step fail normally (no continue-on-error), and make the keepsnappy job in the KeepSnappy workflow a required status check in your GitHub branch protection rule or ruleset. If you renamed the workflow or job, select its actual check name.
For an advisory check, leave that check out of the required checks. Set continue-on-error to true on the measurement step if the workflow should continue after a measurement failure; this also tolerates its infrastructure errors and timeouts. Uploaded results still reach the dashboard. Without --wait, the result never affects the step’s exit code.
With verdict_gate: advisory, a blocking Worse passes the step (exit 0). The job log says Worse — advisory: the step passes (verdict_gate: advisory in keepsnappy.yml), keepsnappy-result.json records gate as advisory, and the job summary, the dashboard and Slack still say Worse. Infrastructure, configuration and verdict timeout still fail the step (1, 2, 4). npx --no-install keepsnappy doctor --group app shows the setting on the config line. A CLI older than the release that adds verdict_gate refuses the key as a configuration error (exit 2): pin the CLI release that adds it.
Without act, the pull request shows only the check status: read the result on the workflow run’s Summary page, the dashboard or with keepsnappy status. A green check can include a Worse that does not block.
If the workflow uses pr-comment, run its phone and final commands and act in one GitHub Actions concurrency group per PR. Each job needs its turn to update the general comment. Disable cancellation of running jobs and let all pending jobs queue, or sequence the writers with job dependencies. The act run on a fix branch writes the source pull request’s comment, so it uses the source pull request’s group: the number is the -pr<source> ending of the fix branch’s name, read in an earlier job as act’s guide shows.
See also
- How AI review skips the AI when the app did not change between the two builds: AI review in CI.
- Ready-made e2e workflows, for the iOS simulator and the Android emulator: e2e.
Next: every keepsnappy.yml setting, the flags of keepsnappy run and its exit codes are on keepsnappy.yml and run flags.