Set up with a coding agent
If you use Claude Code or Codex, you can have it add KeepSnappy to your app. It follows a skill, a set of instructions for the agent, shown in full at the end of this page. The skill drives the init command of the command line tool: the agent explains the plan, shows you the changes as a diff, helps you choose which tests to measure, and checks the result. You type your CI key yourself, in your own terminal. The agent never reads it, asks for it or prints it.
This works for apps whose end-to-end tests are Maestro flows, Appium tests or e2e tests. Init does not set up Detox; a Detox command still works with the command runner (Any other test command).
Ask your agent
Start your agent in the app repo and send it this line. Setup in the dashboard shows the same line:
Add KeepSnappy to this app. Read the setup guide with `curl -fsSL https://keepsnappy.com/docs/agent-setup.md` and follow it step by step.The guide is the skill shown at the end of this page, as a plain text file, so the agent reads every rule word for word. You install nothing first.
Install the skill instead
The command line tool can also copy the skill into the folder your agent reads. The published npm package still copies the earlier skill. That copy calls an older CLI than the one these pages pin, and assumes your comparison branch is main. Use the line above until keepsnappy skill install copies the text shown on this page.
npx @keepsnappy/agent skill install --claudeFor Codex, use --codex. For both, give both flags. The skill goes to .claude/skills/keepsnappy-setup/ for Claude Code and to .agents/skills/keepsnappy-setup/ for Codex, and nothing else changes. Run the command again to get a newer skill: a copy you edited is never overwritten unless you add --force. Then send your agent:
Use the keepsnappy-setup skill to add KeepSnappy to this app.What it does
- It asks
initfor a plan without changing anything, and tells you the files it will touch, the build switch, the time per job and when the first result comes. - It lets
initmake the changes and shows you the diff. Your own workflows and your app code are not edited. - If the GitHub secret is missing, it asks you to run the key step of
initin your own terminal. That is where you enter the key. - It helps you pick the journeys to measure, about 10 minutes for one pass, and checks them against the journey rules.
- It runs the app checks of
doctor, fixes what they find in the files init wrote, and tells you about any line left. - It makes a branch and a commit. It pushes and opens a pull request only after you say yes.
- It confirms which branch the app compares with. Once you have merged, it prints the 3 commands that run the workflow on that branch 3 times, for the 3 sessions a comparison needs. A merge may not start the workflow, so it does not count on one. It does not run the commands.
- It tells you what you will see on a pull request, and where to read it.
To do the same steps by hand, see Getting started.
Tell your agent about KeepSnappy for later
Init does not change your AGENTS.md or CLAUDE.md. If you want your coding agent to know about KeepSnappy in later sessions, add these lines to that file yourself:
## KeepSnappy
This app is measured by KeepSnappy. Its docs for agents: https://keepsnappy.com/docs/llms.txt- Run its command as `npx --no-install keepsnappy`.- Never ask for, read, print or pass a KeepSnappy key. Only a person runs `init --key`.- Journeys must use the same data every run: https://keepsnappy.com/docs/journeys.md#use-the-same-data-every-runThe skill
This is the skill text your agent reads. You don’t need to read it yourself.
Show the skill text (for your agent)
---name: keepsnappy-setupdescription: Add KeepSnappy to a React Native or Expo app repo that already has Maestro, Appium or e2e (e2e.com) end-to-end tests. Use when asked to set up KeepSnappy, add KeepSnappy to this app, or wire KeepSnappy into CI. Drives `keepsnappy init`, shows every change as a diff, helps pick the journeys, and never handles the CI key.---
# Setting up KeepSnappy in an app repo
KeepSnappy measures an app's render times on an iOS simulator or an Android emulator in CI and says on each pull request whether it made the app slower. This skill puts it into the repo you are in. **`keepsnappy init` makes the changes. You drive it, explain it and show the result; you do not do the integration by hand.**
Supported test runners: **Maestro**, **Appium** and **e2e**. `keepsnappy init` does not set up Detox: if the repo's tests are Detox (or anything else), still run step 1's `init --detect --json`, then stop, and end your last message with this sentence, copied exactly: "`keepsnappy init` does not set up Detox." Nothing else is changed. e2e (formerly TesterArmy e2e) is the `e2e` package: `init` finds it by an `e2e.config.*` with its packages, and writes its command into `keepsnappy.yml` as `e2e run --target <the config's iOS target> --retries 0 --strict-cache --exclude-tag ai` through the repo's package runner (or the package script that runs `e2e run`, with `flows.e2e_report`). KeepSnappy refuses every run with an AI step, so `init` names each test file with AI steps and no `ai` tag as a next step. Real devices through e2e's BrowserStack package are not supported ([e2e](https://keepsnappy.com/docs/test-tools/e2e/)). A Detox command still works with `runner: command` in `keepsnappy.yml`; see [Any other test command](https://keepsnappy.com/docs/journeys/#any-other-test-command) in the Journeys page. If `init --detect` identifies an Android emulator job it can copy, step 3 lists what to add. For jobs init cannot use, point the user to [manual Android setup](https://keepsnappy.com/docs/android/#android-emulator).
## Rules
1. **Never handle the key.** The CI key is created in the KeepSnappy dashboard (Setup, step 1) by an owner or admin, and typed by the user at a hidden prompt in their own terminal. Never read it, ask for it, paste it, echo it, pass it as an argument, or look for it in `.env*` files (never open, search or grep them, not even to list variable names or with values redacted), the shell history or the CI settings. Never search the whole repo for `KEEPSNAPPY`: open only the files you name, and use doctor's `build-switch` line to check the workflows. Never print, quote or copy a key value, even one you come across by accident: refer to the key only by its name (`KEEPSNAPPY_KEY`, or `${{ secrets.KEEPSNAPPY_KEY }}` in a workflow). If a key value ever shows up in your output, tell the user to revoke it in the dashboard. Never run `init --key` yourself.2. **Never edit app code.** The only files that change are the ones `init` writes. Test-code advice (step 4) is a separate, optional diff the user agrees to, never app code, and nobody has to add step markers: results are correct without them. A general "carry on", "continue" or "go ahead" is not a yes to a change outside the files `init` writes: ask about that change by name and wait for a yes to it.3. **Never edit an existing workflow.** `init` writes a new file, `.github/workflows/keepsnappy.yml`. The user's own end-to-end workflow stays as it is.4. **The build switch `KEEPSNAPPY=1` belongs in the KeepSnappy job only.** If it ends up in `.env`, in a shared CI environment or in an EAS production or preview profile, the measuring code goes into a store build. Check this in step 2.5. **When `init` stops, stop.** If it says a setup is not covered yet (for example an Android job that starts no emulator, a BrowserStack target, or EAS Workflows as the place that runs the tests), tell the user its message in plain words and change nothing.6. **Push, open a PR and start CI runs only after the user says yes.** You never start a KeepSnappy run: you print the commands (step 7).
## The three keys
Rule 1 covers all three: you never handle any of them. An owner or admin gets each one on the dashboard's **Setup** page.
| Key | Where it goes | Who needs it ||---|---|---|| CI key | The GitHub secret `KEEPSNAPPY_KEY`. The user types it at the hidden prompt of `init --key` (step 3). | Every setup || SDK key | The GitHub secret `EXPO_PUBLIC_KEEPSNAPPY_KEY`, read by the build. It is not the CI key. | An Android job, or real phones on BrowserStack || Read key | `KEEPSNAPPY_KEY` in the user's shell, never in the repo. For investigation in CI, the GitHub secret `KEEPSNAPPY_READ_KEY`. It does not replace the CI secret. | Later: a coding agent or the MCP server that reads results |
## Steps
Work in the app repo's root. Before `init` has run, call the tool as `npx @keepsnappy/agent`: there is no npm package named `keepsnappy`, so `npx keepsnappy` alone would fetch something else. First run `git status --short`. If the tree is not clean, ask the user to commit or stash first, so that the diff you show in step 2 is only `init`'s.
### 1. Explain the plan
```shnpx @keepsnappy/agent init --detect --json```
This writes nothing. It says what `init` found (package manager, Expo, the test runner, the CI job it will copy) and what it will do. Tell the user in plain words, in this order:
- **The files it will touch:** `package.json` and the lockfile (the SDK, through the package manager), `app.json`, `metro.config.js`, `keepsnappy.yml`, one new workflow file and `.gitignore`. No app code.- **The build switch:** the new workflow builds the app with `KEEPSNAPPY=1`. Their store builds and their existing end-to-end job do not.- **Time per job:** the new job builds once and runs every journey 5 times per session by default, so budget build + repetitions × journey time, plus setup, upload and verdict wait. Use a macOS runner for the iOS simulator and the existing emulator runner for Android. Their normal end-to-end job is not slowed down.- **When the first answer comes:** The first verdict needs 3 sessions on the app’s comparison branch. Use the branch init reports for workflow pushes and confirm it matches the app’s comparison branch before dispatching (step 7). With zero sessions on the same phone model, a pull request says "No main to compare".
An Android job needs the app’s registered link scheme, such as `expo.scheme` in `app.json`, for the SDK’s activation and flush links. With no scheme, an Android-only setup stops before applying changes. If init can also set up iOS, it can write the iOS job and leave out Android. Show the message init prints, ask which scheme the app registers, and have the user add it before rerunning init.
If the detect output says the repo is not supported, apply rule 5. Otherwise, ask as a question whether to apply the plan, and wait for the answer.
### 2. Apply it and show the diff
```shnpx @keepsnappy/agent init --yes --no-key```
`--no-key` leaves the key for step 3. Then show what changed: `git status --short` and `git diff`, and the content of the new files (`keepsnappy.yml` and `.github/workflows/keepsnappy.yml`). Explain each in a sentence.
Check, and say what you checked:
- Only the files from step 1 changed. Anything else: say so, and do not commit it.- `KEEPSNAPPY=1` is scoped to the new KeepSnappy job, typically in its job-level `env`. Check that store builds, `eas.json` and other workflows leave it unset by opening those files by name; doctor's `build-switch` line checks the workflows for you. Never search the whole repo for `KEEPSNAPPY` (`grep -r`, `git grep`, `rg`): a `.env` file, even a committed one, can hold the key, and the match prints it. Do not open, search or print `.env*` files (rule 1). Ask the user to confirm that none of them sets `KEEPSNAPPY=1`.- A file `init` could not edit safely (for example an `app.config.ts` or `app.config.js` that is code, or a `metro.config.js` with other wrappers) is not edited: `init` prints the line to add (`by you`). Show that line and the file it goes in, and leave the edit to the user, even if they say yes or "go ahead": an app config is app code (rule 2). Until they add it, doctor's `plugin` line (or `metro` line) is MISS; that is expected, so say so and do not loop on it.
### 3. The key
Read the `key` line from init’s app checks, or run the doctor command in step 5 to see it. Skip the CI key command below only when the line starts with `ok` and says `KEEPSNAPPY_KEY is set as a GitHub secret`. An `ok` that says `accepted by the API` checked a key in this shell, not the GitHub secret. Run `env -u KEEPSNAPPY_KEY npx --no-install keepsnappy doctor --group app` to check the secret instead: it passes no key, and doctor then asks GitHub whether the secret exists, never its value. If doctor says the secret is missing, ask the user to run this themselves, in their own terminal:
```shnpx @keepsnappy/agent init --key```
(In Claude Code they can type `!` in front of it to run it in this session. In Codex they open a terminal.) It asks for the key at a hidden prompt, checks it, and with their yes stores it as the `KEEPSNAPPY_KEY` secret of the GitHub repo. If they have no key yet: owner or admin, dashboard, Setup, step 1, Make a CI key. Wait until they say it is done. Do not ask what the key was or whether it worked: step 5 checks it.
If `init` wrote an Android job, that job reads two more things from the GitHub repo, and `init` prints all three at its end: the secret `KEEPSNAPPY_KEY` (above), the secret `EXPO_PUBLIC_KEEPSNAPPY_KEY` (the SDK key, from Setup → Keys; it is not the CI key) and the repository variable `KEEPSNAPPY_API` (the API address). Tell the user to add them in GitHub (Settings, Secrets and variables, Actions), and apply rule 1 to the SDK key as well: never ask for it or handle it.
### 4. Pick the journeys
A journey is one end-to-end test. Each runs 5 times per session by default, so choose a subset that takes about **10 minutes for one pass**, the ones that matter for speed: the main screens, a long list, a heavy screen, start-up. Not every test. A command wrapping a whole suite repeats that whole suite each time. For a shorter first measurement use `--repeat 3` on `keepsnappy run`, or narrow the journey with the runner’s file/spec filter in `flows.command`. Keep at least 3 valid runs doing the same work for comparison. The starter CI timeout is 90 minutes: 20 build + 5 × 10 journey + 20 setup/upload/verdict; increase it for longer builds or tests.
**The same data every run comes first.** Each journey must show the same data in every run: the same account, content, date and settings. Different data means different work. That reads as a slowdown the code did not cause, or hides a real one. The usual ways: a mock server or recorded responses; a test account with fixed seed data, reset on the server before the app launches (never by clearing the app); a frozen clock and time zone; remote flags and A/B tests pinned to one value; fixed list sizes; a live feature the journey tests (chat, feeds, presence) kept on and driven by a mock server or a recorded script, so the same messages arrive in the same order and at the same moments, with only untested live content (ads, real-user counters) turned off; one language and region; no randomness. Details: https://keepsnappy.com/docs/journeys.md#use-the-same-data-every-run
1. List the tests: the Maestro flow files, the Appium spec files, or the e2e test files the command runs. Ask how long the user's suite takes in CI (or read the duration of their last end-to-end job) and which flows matter most.2. Propose a subset and say why each is in.3. Check each against the journey rules in the [Journeys page](https://keepsnappy.com/docs/journeys/). First and most important: it uses [the same data every run](https://keepsnappy.com/docs/journeys/#use-the-same-data-every-run) (the same account, content, date and settings, from a mock server or a test account reset before the launch, never by clearing the app). Name this rule to the user in these words, "the same data every run", and say for each chosen journey whether it meets it; if the test does not show how its data is set up, ask. Then: it starts from the same state; it waits on a condition, never a fixed time; it finds elements by `testID`; it scrolls the same way every run; it ends on the home screen. An e2e test also uses no AI step (`agent.act`, `agent.assert`, `agent.waitFor`, `agent.extract`): such a run is refused. Report each problem on its own line as `path:line` (for example `e2e/maestro/flow.yaml:26`) with the rule it breaks; two problems in one file are two lines.4. Apply the choice only in `keepsnappy.yml` and in the test command of the new workflow, so the two agree: Maestro paths or tags under `flows`; for Appium, the spec files in the command; for e2e, the test filter in the command, keeping `--retries 0`, `--strict-cache` and `--exclude-tag ai`.
Fixes in test code (a fixed sleep to replace with a wait, a missing reset) are advice. Offer them as a separate diff, in a separate commit, and make them only after the user answers yes to that diff. A missing `testID` is a change in the app: tell the user, do not make it. Say that changing a journey later changes what it measures, so journey changes belong in their own pull request.
### 5. Check the setup until it is green
Run this right after step 2, even before the CI key exists (it then shows `WARN key`, which is expected), and again before you commit. Show its full output: do not filter it through `grep`, `head` or `tail`.
```shnpx --no-install keepsnappy doctor --group app```
`init` has added `@keepsnappy/agent` to the repo's dev dependencies at an exact version, so from here `npx --no-install keepsnappy` runs that copy. It checks, without running anything in CI: the SDK plugin and the Metro wrapper are there, `keepsnappy.yml` is valid, the bundle id matches `app.json`, the build switch is only in the KeepSnappy job, and the CI key status. Read the leading status on the `key` line. An `ok` that says `KEEPSNAPPY_KEY is set as a GitHub secret` passes this setup check, even if the parenthetical says the API was not checked because the key is absent from the shell. If doctor says the secret is missing, ask the user to complete step 3. If doctor could not check GitHub, follow its hint and rerun the check. A `bundle-id` line that says the app does not say its iOS bundle id is expected for an Expo app with no `ios/` folder whose `app.config.*` computes the bundle id instead of writing it as plain text: `expo prebuild` writes the folder in CI. When `app.bundle_id` in `keepsnappy.yml` is the app's id, take that line as done and do not loop on it. Fix each other failing line it names, only in the files `init` wrote, then run it again. Stop after three rounds with no progress and give the user its last output. If `init --help` or `doctor --help` lists a local dry run (a build and one test run on a booted simulator, without upload), offer it: it takes about as long as one Release build.
### 6. Branch and commit
Make a branch (for example `keepsnappy/setup`) and commit the files from step 2, by name, not with `git add -A`. Do not add `.env` files or anything else. Show the user the commit. Then ask: "Push the branch and open a pull request?" Only on a yes:
- `git push -u origin HEAD`, then `gh pr create` with a title and a short body that says what was added and that the key is a repo secret the user set.
### 7. What to do next
KeepSnappy compares every pull request with the last 3 measurements of the app's `main` branch. Until main has 3, pull requests show Can’t tell.
Once this pull request is merged (the files `init` added are on `main`), the workflow has to run on `main` 3 times. A merge may not start the workflow, so all 3 sessions are started by hand. Print the 3 commands for the user:
```shgh workflow run keepsnappy.yml --ref maingh workflow run keepsnappy.yml --ref maingh workflow run keepsnappy.yml --ref main```
Print all three lines as they are, in one code block; one line with "run it three times" is not enough.
If the branch init reports for workflow pushes (also under `on.push.branches` in `.github/workflows/keepsnappy.yml`) isn't `main`, use its name instead, as one shell-quoted argument to `--ref`. If you cannot confirm that it is the app’s comparison branch, ask an app owner or admin before dispatch.
The 3 sessions can run at the same time. Without the terminal: **Actions → KeepSnappy → Run workflow** on that branch, 3 times. When the 3 sessions are done, the next pull request gets its word: Worse, Slightly worse, No change, Better or Can’t tell.
### 8. What the user will see
Tell the user, in short:
- Each journey on a pull request gets one result: Worse, Slightly worse, No change, Better or Can’t tell.- Before the comparison branch has a session on the same phone model, a pull request shows No main to compare. Until it has 3, it shows Can’t tell.- During the pilot, `keepsnappy.yml` has `verdict_gate: advisory`: the KeepSnappy check passes even when the result is Worse, and the result still says Worse.- Where to read a result: the KeepSnappy check's **Details** on GitHub; **Branches**, then the branch, on the dashboard; or `npx --no-install keepsnappy status --branch <branch>`, which the user runs with a key in `KEEPSNAPPY_KEY`.
## If something fails
Each line starts with what init or the CI log prints. Fix only what is in the files `init` wrote, and apply rule 1 to every key.
- `No changes made.`: the user said no, or init had no terminal to ask in. If the user said no, stop. If init printed `No terminal to confirm the plan` and the user has agreed to the plan, run step 2's command again: `npx @keepsnappy/agent init --yes --no-key`.- `Cannot go on: The iOS bundle id is not in app.json or the Xcode project.` (in step 1's `--detect --json`, the same text is in `problems`): the app config builds the bundle id in code. Ask the user for the bundle id of the Release build, then run `npx @keepsnappy/agent init --yes --no-key --bundle-id <it>`.- `init does not set up Detox`: stop (rule 5). A Detox command works with `runner: command`, written by hand.- `--upload needs the project key in the environment variable KEEPSNAPPY_KEY`: the secret `KEEPSNAPPY_KEY` is missing, or does not reach the step. Run step 5's doctor. If its `key` line says the secret is missing, ask the user to do step 3 (rule 1). If the secret is set, check that the step that runs `keepsnappy` still has `KEEPSNAPPY_KEY: ${{ secrets.KEEPSNAPPY_KEY }}` in its `env:` block. A pull request from a fork or from Dependabot gets no secrets: run it from a branch of the repo.- `cannot open a run set at …: invalid_key (check KEEPSNAPPY_KEY)`, or `… CI key was revoked. …`: the key in the secret is wrong or stopped. The user makes a new CI key on **Setup** and stores it with `init --key`.- `Session failed: no run sent any data. Check that the build carries the SDK and that the app reaches the API.`: check that the KeepSnappy job sets `KEEPSNAPPY=1` for `prebuild` and the build, that `measureFromLaunch` is not turned off in the plugin options, and that the build is installed on the booted simulator.- `Session failed: no run sent any data. Every run failed its test command`: the tests failed. After a local run, read `test.log` in each run folder of `keepsnappy-out`. In CI that folder stays on the runner, because the workflow `init` wrote does not upload it. Check that the same journeys pass in the user's own end-to-end job. If they do, offer to add an `actions/upload-artifact` step for `keepsnappy-out` (with `if: always()`) to `.github/workflows/keepsnappy.yml`, as a separate diff the user agrees to, and read `test.log` from the next run.
More lines and their fixes: https://keepsnappy.com/docs/troubleshooting.md
## Read more
Every page is Markdown: https://keepsnappy.com/docs/llms.txt lists them all. For setup, the ones to read are:
- Getting started: https://keepsnappy.com/docs/getting-started.md- Journeys: https://keepsnappy.com/docs/journeys.md- CI: https://keepsnappy.com/docs/ci.md- Keys: https://keepsnappy.com/docs/keys.md- Troubleshooting: https://keepsnappy.com/docs/troubleshooting.md- The command line tool: https://keepsnappy.com/docs/reference/cli.md