<!-- KeepSnappy docs for keepsnappy CLI 0.1.0-alpha.35 -->

# CLI reference

> Every command of the keepsnappy command line tool, with its usage and flags.

<!-- Generated from `keepsnappy <command> --help` of the released CLI these docs describe and from `apps/agent/src/cli-spec.ts`; do not edit. Run `bun run docs:reference` after a release. -->

This page matches the latest CLI release. Run a command with `npx @keepsnappy/agent <command>`. Find the command you need in the tables below; each name links to its help.

`keepsnappy --help` prints what the tool is and the commands a setup uses. `keepsnappy <command> --help` (or `-h`) prints the help of one command, `keepsnappy help --all` the help of every command, and `keepsnappy --version` the version. In a help block, `[ ]` marks an optional part, `|` a choice, `<…>` something you fill in, and `…` a part that can repeat.

## Commands

**Set up**

| Command | What it does |
| --- | --- |
| [`init`](#init) | Use it once per app repository to set up the SDK, `keepsnappy.yml` and a KeepSnappy workflow. |
| [`doctor`](#doctor) | Use it when something does not work: each line names a step and how to fix it. |
| [`skill`](#skill) | Use it when you want Claude Code or Codex to set KeepSnappy up in your repository. |
| [`config`](#config) | Use it to set your AI agent, its path and your repository folders once, for every command. |
| [`setup`](#setup) | Use it on a Mac that should watch results and run investigations. |

**Measure**

| Command | What it does |
| --- | --- |
| [`run`](#run) | Runs your end-to-end tests several times and measures each run; with `--upload` it sends the session to KeepSnappy for a result. |
| [`measure`](#measure) | Use it on your Mac to compare two builds before you push. |
| [`farm`](#farm) | Use it when your tests run on BrowserStack or on a real phone, not in a simulator job. |
| [`extract`](#extract) | Use it to read the data of an earlier run again without running the tests. |
| [`aa`](#aa) | An A/A check: how much each metric varies between runs of one build, to choose how many runs per journey you need. |
| [`sourcemaps`](#sourcemaps) | Use it in the job that builds your app, so that places name your source files. |
| [`activation-link`](#activation-link) | Prints the link that starts the app’s KeepSnappy session, for your own test code. |
| [`flush-link`](#flush-link) | Prints the link that makes the app send its data, for your own test code. |
| [`gc-link`](#gc-link) | Prints the link that asks the app to collect garbage, for your own test code. |

**Read a pull request’s result**

| Command | What it does |
| --- | --- |
| [`status`](#status) | Is my pull request ok? The result for the whole branch, then the result per journey and phone model, with the worst places and dashboard links. |
| [`findings`](#findings) | What got worse or better on a branch or on `main`, worst first. |
| [`finding`](#finding) | One alarm, by its ID, with its evidence. `--prompt` prints only the brief for a coding agent. |
| [`problems`](#problems) | Places over budget in the branch’s own runs, whatever `main` does. They never block. |
| [`branches`](#branches) | Use it to see the result of every recent branch at once, in a terminal. |
| [`watch`](#watch) | Use it on your Mac to hear about a slower pull request without opening the dashboard. |
| [`compare-now`](#compare-now) | Use it when a pull request had no `main` session to compare with, and `main` has one now. |
| [`mark`](#mark) | The KeepSnappy Mac app uses it to record a person’s mark, with [the Mac app’s key](https://keepsnappy.com/docs/glossary.md#the-mac-apps-key). |

**Read `main`, places and runs**

| Command | What it does |
| --- | --- |
| [`main`](#main) | `main`’s sessions, or with `--changes` its confirmed changes and the pull requests merged in them. |
| [`trend`](#trend) | One place over `main`’s sessions. |
| [`hotspots`](#hotspots) | Where to optimise on `main`: the slowest places of the newest release’s sessions. |
| [`places`](#places) | Every place of one session, from its stored statistics. |
| [`history`](#history) | The history of one place, by its exact ID. |
| [`compare`](#compare) | One run against another, without statistics. |
| [`commits`](#commits) | The measured commits between two sessions or two commits. |
| [`layers`](#layers) | How KeepSnappy decides a result, step by step. |

**AI help**

| Command | What it does |
| --- | --- |
| [`review`](#review) | Use it in CI after `run --wait` for an AI answer on each alarm. |
| [`act`](#act) | Use it in CI after `run --wait`, in place of `review`, when you also want investigations and fixes on the pull request. |
| [`investigate`](#investigate) | Use it to ask your own AI agent why an alarm happened. |
| [`hypotheses`](#hypotheses) | What `keepsnappy investigate` found about an alarm, and the tokens and cost of each investigation. |
| [`fix`](#fix) | Use it to let your own AI agent try a fix for the alarms of a pull request. |
| [`fixes`](#fixes) | The draft pull requests `keepsnappy fix` opened, and what each did to the places it was for. |
| [`conversations`](#conversations) | Use it to see or delete what your AI runs said on this Mac. |

`verdict` is removed. Results come from KeepSnappy now: use `run --upload`. `verdict` says so and exits 2.

## Exit codes

| Code | Meaning |
| --- | --- |
| `0` | The command did what it was asked. |
| `1` | Something the command needs failed, such as a request, a tool or a file. For `doctor`, the checks that can fail the command depend on the group. See the [doctor exit rules](https://keepsnappy.com/docs/reference.md#published-cli-help). |
| `2` | The command line or the configuration is wrong. Nothing ran. |
| `3` | With `--wait`: a journey’s result is Worse and `verdict_gate` is `blocking` (the default). With `verdict_gate: advisory` the same result exits 0. |
| `4` | With `--wait`: the result did not arrive within `--wait-timeout`. The log has a dashboard link to see it later. On `main` this exits 0. |

## run

Runs your end-to-end tests several times and measures each run; with `--upload` it sends the session to KeepSnappy for a result. Your KeepSnappy workflow runs it in CI, on pull requests and on `main`.

```text
keepsnappy run: runs your end-to-end tests several times, measures each run, and with --upload sends the session to KeepSnappy for a result.
  Usage: keepsnappy run [options] [-- <test command...>]
  Without a command after --, it runs the flows or the command that keepsnappy.yml names.

  --config FILE            the config file (default keepsnappy.yml)
  --repeat N               runs per journey (default: repetitions in keepsnappy.yml)
  --out DIR                the output folder (default: output.dir in keepsnappy.yml, else keepsnappy-out)
  --platform ios-sim|ios-device|android-emulator|android-device   where the app runs
  --device UDID|emulator-PORT|ADB-SERIAL   the simulator, emulator or phone to use
  --device-set PATH        a custom iOS simulator set, a folder that already exists (else ios.device_set in keepsnappy.yml, else SIMULATOR_DEVICE_SET_PATH)
  --device-model NAME --device-os VERSION   the phone model and OS version to report
  --scenario NAME          the journey name when one command runs the whole suite
  --replay <out dir>[:ARM] ...   uploads the runs of an earlier output folder instead of running the tests
  --app FILE.apk           Android: the app to install with adb install -r
  --no-markers             turns off the local address your tests send step markers to

  --upload                 sends the session to KeepSnappy
  --wait                   with --upload: waits for the result and sets the exit code (below)
  --wait-timeout MINUTES   how long --wait waits (default 10)
  --no-notify              a quiet session: the result is stored, and Slack hears nothing
  --ingest-url URL         the KeepSnappy API address
  --commit SHA             the measured commit (default: the pull request's head, else GITHUB_SHA)
  --branch NAME            the branch (default: GITHUB_HEAD_REF, else GITHUB_REF_NAME)
  --base-commit SHA        the main commit to compare with (default: the merge base)
  --fail-on-worse          changes nothing: --wait already fails the step on a Worse

  Android (android-emulator, android-device) needs --upload, a branch, and app.scheme (for example myapp://) in keepsnappy.yml.
  android-emulator takes only emulator-PORT serials, and android-device only phones in adb state "device".
  With several attached and none named, run lists them and stops.

  Exit codes with --wait:
    3  a journey's result is Worse, also when other journeys are still waiting at the deadline (Worse (not blocking) does not count)
    4  no result within --wait-timeout; the log has a dashboard link
    0  any other result (Slightly worse, Can’t tell, Not judged), with one line per journey that moved
  On main, run waits for the result and exits 0, even on a timeout.
  verdict_gate: advisory in keepsnappy.yml turns exit 3 into 0; blocking, the default, keeps it.
  A failure, a wrong command line and a timeout still exit 1, 2 and 4.
```

You can give `--replay` more than once, one value each time.

`--fail-on-worse` is deprecated and changes nothing: `--wait` already fails the step on a Worse.

## measure

Use it on your Mac to compare two builds before you push. Nothing is uploaded.

```text
keepsnappy measure: runs a test command several times against one or two builds of your app on iOS, and writes the metrics of every run.
  Usage: keepsnappy measure --repeat N [options] -- <test command...>

  --repeat N               runs per build (required)
  --arms A=<app|bundle>,B=<app|bundle>   the two builds to compare, an .app or a bundle id each
  --arm-env 'A:KEY=VAL' ...   an environment variable for one build
  --bundle-id ID           the app's bundle id, when --arms does not give it
  --platform ios-sim|ios-device   simulator or phone
  --device UDID            the simulator or phone to use
  --device-set PATH        a custom iOS simulator set, a folder that already exists (else SIMULATOR_DEVICE_SET_PATH)
  --out DIR                the output folder
  --timeout SEC            the time limit of one run
  --ri-capture observations.ndjson   a file of render observations to read the metrics from
  --mem-window NAME        the place whose memory is measured
  --clock-offset-ms N      the clock difference between the phone and this machine
  --no-markers             turns off the local address your tests send step markers to

  Exits 0 when at least one run is valid, and 1 when none is (also when nothing was collected).
```

You can give `--arm-env` more than once, one value each time.

## farm

Use it when your tests run on BrowserStack or on a real phone, not in a simulator job.

```text
keepsnappy farm: measures your journeys on a device farm (BrowserStack) or on a phone you start yourself.
  Usage:
    keepsnappy farm run   --app APP --device NAME [options]   one whole session: open, tunnel, device, close
    keepsnappy farm open  --tokens-js FILE --state FILE [options]
    keepsnappy farm close --state FILE [options]
    keepsnappy farm close --state FILE --cancelled

  farm open starts a session and writes the tokens your flows read.
    --api URL                the KeepSnappy API address
    --journeys a,b           the journeys to run (required, also for farm run)
    --repeat 5               valid runs per journey (default 5)
    --spare 0                Appium only: extra runs per journey, used only to replace a broken run or a lost upload
                             (default: retry.failed_runs in keepsnappy.yml, 0 to 3; the flag wins, also when it is 0)
    --platform ios|android   the platform
    --device-model CODE      the phone model; with the platform set and a local phone it is read from the phone (never on browserstack)
    --device-os V            the OS version
    --device-id SERIAL|UDID  the phone
    --device-provider browserstack   the farm
    --tokens-js <file>       where to write tokens.js
    --state <file>           where to keep the session for farm close
    --branch NAME --commit SHA --base-commit SHA   as for run
    --ttl-seconds 21600      how long the session's tokens stay valid (at least 60)
    --key-env KEEPSNAPPY_KEY   the variable that holds the CI key
    --config keepsnappy.yml  the config file
    --flows <files|dirs|globs,...>   the flows; a journey's name comes from flows.paths in keepsnappy.yml, else from the flow's name: or top comment
    --completion-marker      each run sends the step run:complete at its end; a run without it is invalid
    --driver appium --journey-module FILE   runs the journeys with Appium
    --driver-version V --app-build-id ID --harness-version V --journey-version V --flag-set LABEL   describe the setup, so different setups are not compared
    --plant JSON             a slowdown this build adds on purpose, stored with the session: [{ place, kind, factor, unit: budget|MB }]
    --sdk-args k=v&...       SDK settings over the defaults profile=1 diag=1, passed in the activation link
    --no-notify              a quiet session (also KEEPSNAPPY_NOTIFY=off): the result is stored and shown, and Slack hears nothing, not even a failure

  farm close finishes the runs, closes the session and uploads it. Running it twice is safe.
    --wait [--wait-timeout MINUTES]   as for run, with the same exit codes
    --bs-build browserstack.ios.json  the BrowserStack build file, to report its status
    --settle-seconds 60      closes once the runs have sent nothing new for this long
    --max-wait-seconds 300   the longest it waits for that
    --out DIR                the output folder
    --cancelled              the session was cancelled: closes it at once as "Cancelled · never ran", waits for nothing, tells Slack nothing, exits 0

  farm run does open, tunnel, device and close in one command.
    --app <eas:ID|file.ipa|file.apk|bs://ID|custom_id:ID>   the app build
    --device "iPhone 15 Pro-17"   the farm's device
    --driver maestro|appium  the test tool (default maestro)
    --tunnel-for localhost:PORT ...   opens a tunnel from the device to this port
    --env KEY=VALUE ...      for the test tool; values may use {tunnel:PORT} {run_id} {out} {tokens_js} {run_set_id}
    Maestro: --suite-dir DIR --execute FLOW [--tokens-path flows/keepsnappy/tokens.js] [--maestro-version V]
    --poll-seconds 20        Maestro: how often the farm is asked for the result
    Appium (iOS and Android): --journey-module FILE | --driver-script FILE [--driver-arg ARG ...]
    --timeout-minutes 80 --kill-after-seconds 120   Appium: stopped at the timeout, killed after the grace period
    --custom-id ID           the farm's custom id of the app build
    --run-id NAME            names the run, its tunnel and its folder (letters, digits, . _ -; default keepsnappy-<platform>-<session id>)
    --dry-run                prints the plan and starts nothing
    It also takes the API address, journeys, runs, spare runs and platform flags of farm open, and --branch, --commit, --wait, --out and --no-notify, as above.
    When it fails before a session exists, KeepSnappy records a failed session and Slack hears of it, unless --no-notify.
```

You can give `--tunnel-for`, `--env` and `--driver-arg` more than once, one value each time.

## extract

Use it to read the data of an earlier run again without running the tests.

```text
keepsnappy extract: writes metrics.csv again from the output folder of an earlier run.
  Usage: keepsnappy extract <out-dir> [--ri-capture observations.ndjson] [--mem-window NAME]
  --ri-capture and --mem-window are as for measure.
```

## aa

An A/A check: how much each metric varies between runs of one build, to choose how many runs per journey you need. It also shows the smallest change each run count can detect.

```text
keepsnappy aa: shows how much each metric varies between runs that should be identical, and the smallest change each run count can detect.
  Usage: keepsnappy aa <out-dir> [--reps N] [--boot N]
  --reps N                 simulated comparisons per run count (default 300)
  --boot N                 resamples per comparison (default 400)
```

## doctor

Use it when something does not work: each line names a step and how to fix it.

```text
keepsnappy doctor: checks one part of your setup and names what to fix.
  Usage: keepsnappy doctor [--group setup|measure|app] [options]

  Without flags, or with --group measure: the measurement tools of this machine (xcrun, booted simulators and phones, and maestro or appium,
  whichever your project uses, or both when it is unknown). Missing tools or devices do not fail this group.
  Invalid project settings or an invalid simulator-set path exit 1.

  --group app              whether this app repository is set up for KeepSnappy, read from its files. It runs in the app folder and builds nothing.
                           Steps: sdk, agent, plugin, metro, config, bundle-id, build-switch, key, and sdk-key for Android.
                           It checks the SDK dependency, the Expo plugin in app.json, the Metro wrapper, and keepsnappy.yml with its bundle id.
                           KEEPSNAPPY must be on only in the KeepSnappy workflow. A key set here must be accepted; else the CI secret must exist.
                           The bundle id is read from the first iOS app target of the Xcode project; name another one in app.bundle_id.
  --dir APP_FOLDER         with --group app: the app folder (default: the current folder)
  --local                  with --group app: allow local setup before CI. Workflow-dependent checks can pass as not needed without a workflow.
                           With a workflow, passing checks stay ok and some CI issues become WARN. A key set in this shell is still checked.
  --group setup            whether this Mac is set up to watch, notify and investigate. Steps: account, projects, repo:<app>, agent, agent-login,
                           notifications, events, preflight. keepsnappy setup fixes what is missing. No model is called.
  --preflight              also runs the preflight step, which checks out a commit and starts the agent (otherwise it reads "run the check")
  --step ID                one setup step, for example preflight or repo:myapp. Incompatible with --group app, --group measure and --preflight.
  --app SLUG ...           with --group setup: only these apps, whatever watch.apps says
  --json                   {"version":1,"steps":[{"id","group","state":"ok|missing|broken|warn","detail","fix":{"hint","command"?}}]}; both groups unless --group is given
  --device-set PATH        a custom iOS simulator set, a folder that already exists (else ios.device_set in keepsnappy.yml, else SIMULATOR_DEVICE_SET_PATH)
  --config keepsnappy.yml  the config file
  --api URL --key-env NAME the KeepSnappy API and the variable that holds the key

  A step that could not be checked, or is not done yet, is WARN and does not change the exit code.
  Exit codes: --group app exits 1 when a step is missing or broken; --group setup exits 1 unless account, projects and events are ok;
  --step exits 1 unless the step is ok.
```

You can give `--app` more than once, one value each time.

## sourcemaps

Use it in the job that builds your app, so that places name your source files.

```text
keepsnappy sourcemaps: uploads the source maps of an app build, so that places name your source files.
  Usage: keepsnappy sourcemaps upload --build <full commit sha|build id> --platform ios|android [options] <map files...>
         keepsnappy sourcemaps upload --eas
  --eas                    in an EAS build for e2e: finds the build, platform, map and kind itself; skips what is missing and never fails the build
  --build <full commit sha|build id>   the build the maps belong to
  --platform ios|android   the platform
  --kind hermes|packager   the kind of source map
  --flavour NAME           the build's flavour (e2e with --eas)
  --project-root PATH      your app's root folder
  --components-config ID   which component configuration to use, when the project has more than one
  --api URL | --ingest-url URL   the KeepSnappy API address
  --key-env KEEPSNAPPY_KEY the variable that holds the key
```

## Read commands

Use these to read results in a terminal or a script. They share one help block, `keepsnappy findings --help`; each command’s own lines are under its name below. Each takes `--json`.

```text
keepsnappy findings, status and the other read commands: read results from KeepSnappy in a terminal or a script.
  Usage: keepsnappy <command> [options]. Every command takes --json.

  --short                  what decides, without the evidence (findings, status, problems, finding, history, places, main, trend); --json is unchanged
  --verbose                adds source files and raw names to the text; --json is unchanged
  --page N | --all         places and compare: one page of components, or every stored component and place; --top-components sets the page size
  --detail                 places: adds the recorded detail of each run (also with --verbose or --page)
  --place-key KEY --detail-mode full|slowest_commit --cursor CURSOR   places: one exact place, as pages of detail

  Key: KEEPSNAPPY_KEY, or the variable --key-env NAME names. API: --api URL or KEEPSNAPPY_API.
```

You can give `--window` and `--ref` more than once, one value each time.

### status

Is my pull request ok? The result for the whole branch, then the result per journey and phone model, with the worst places and dashboard links.

```text
  status   --branch NAME [--journey KEY] [--phone MODEL | --all] [--short] [--json]
           is my pull request ok? One answer (blocked, nothing blocks, or ok), then per journey and phone model the result,
           the worst places and dashboard links. Never measured and not judged are not ok.
           After a run it shows that run. --all shows every journey and phone model.
           --json is the API’s answer and ignores --journey, --phone and --all.
```

### findings

What got worse or better on a branch or on `main`, worst first.

```text
  findings [--branch NAME | --main] [--journey KEY] [--phone MODEL] [--state present|not-judged|resolved|all] [--limit N] [--offset N] [--short] [--json]
           the alarms of a branch or of main, worst first; --state present (the default) shows the ones still there
```

### finding

One alarm, by its ID, with its evidence. `--prompt` prints only the brief for a coding agent.

```text
  finding  <id> [--branch NAME] [--prompt] [--short] [--json]
           use the branch the ID came from; a bare ID reads its last occurrence
           one alarm; --prompt prints only the brief for a coding agent
```

### problems

Places over budget in the branch’s own runs, whatever `main` does. They never block.

```text
  problems --branch NAME | --main [--journey KEY] [--phone MODEL] [--limit N] [--offset N] [--short] [--json]
           places over budget ("Over budget", "Far over budget") in the branch's own runs, whatever main does; they never block
```

### main

`main`’s sessions, or with `--changes` its confirmed changes and the pull requests merged in them.

```text
  main     --journey KEY --phone MODEL [--sessions N [--cursor CURSOR] | --session ID] [--vs-previous] [--measure REF] [--limit N] [--offset N] [--short] [--json]
           main's sessions, --sessions per page (default 20), --cursor the older sessions; --vs-previous compares the newest with the one before
  main     --journey KEY --phone MODEL --changes [--limit N] [--json]
           main's confirmed changes, newest first, each with its commit range and the pull requests merged in it
```

### trend

One place over `main`’s sessions.

```text
  trend    <journey> <place words...> --phone MODEL [--window PLACE ...] [--ref REF ...] [--sessions N] [--since WHEN] [--until WHEN] [--cursor CURSOR] [--short] [--json]
           one place over main's sessions; the words after the journey are one place name, and --window adds more;
           --sessions per page (default 10), --since/--until a date or a date and time with a zone (since included, until not), --cursor the older sessions
```

### hotspots

Where to optimise on `main`: the slowest places of the newest release’s sessions.

```text
  hotspots --journey KEY --phone MODEL [--sessions 1-4] [--measure jank_ms|render_ms|commit_max_ms] [--limit N] [--offset N] [--top-components N] [--json]
           where to optimise on main: the slowest places of the newest release's sessions, how often they appear, and their top components
```

### places

Every place of one session, from its stored statistics.

```text
  places   [--run-set ID | --journey KEY [--phone MODEL] [--branch NAME]] [--measure ID] [--sort median|p90|mad] [--window TEXT] [--limit N] [--offset N] [--top-components N] [--short] [--json]
           every place of one session (default: the journey's newest finished session), from its stored statistics
```

### history

The history of one place, by its exact ID.

```text
  history  <journey> <place> [--phone MODEL] [--limit N] [--cursor CURSOR] [--short] [--json]
           the history of one place, by its exact id (for example "press:live.chat.send"); --limit valid main runs per page (default 50), --cursor the older runs
```

### compare

One run against another, without statistics.

```text
  compare  <runA> <runB> [--short] [--limit N] [--offset N] [--json]
           one run against another, by run id or external id, without statistics; --short: the places whose time moved most
```

### commits

The measured commits between two sessions or two commits.

```text
  commits  <from> [<to>] [--branch NAME] [--json]
           the measured commits between two sessions or two commits
```

### layers

How KeepSnappy decides a result, step by step.

```text
  layers   [--json]
           how KeepSnappy decides a result, step by step
```

### hypotheses

What `keepsnappy investigate` found about an alarm, and the tokens and cost of each investigation.

```text
  hypotheses <finding-id> [--json]   what keepsnappy investigate found about an alarm, and the investigation runs with their tokens and cost on an API key
```

### fixes

The draft pull requests `keepsnappy fix` opened, and what each did to the places it was for.

```text
  fixes    [<pr|branch> | --branch NAME | --pr N] [--limit N] [--offset N] [--json]
           the draft pull requests keepsnappy fix opened, and what each did to its places: Fixed, No change, Worse, or Waiting for the fix branch.
           --branch takes the pull request's branch or the fix branch; --pr the pull request or the draft.
           Newest first, 20 per page (--limit up to 50). --offset N skips the N newest; the output says which offset comes next.
```

## investigate

Use it to ask your own AI agent why an alarm happened. KeepSnappy receives only its hypotheses.

```text
keepsnappy investigate: lets your own claude or codex look for the cause of one alarm, read-only, and stores its hypotheses in KeepSnappy.
  Usage: keepsnappy investigate <finding-id> [options]
         keepsnappy investigate --followup RUN_ID --message-file FILE --client-id ID [--message-file FILE --client-id ID …]
  <finding-id> is the alarm's id (f_…); --finding f_… is the same. The agent works in a separate worktree of your repository, at the measured commit.
  KeepSnappy checks its hypotheses before it stores them.

  --branch NAME            the pull request to read the alarm from (default: the one it was seen on last)
  --repo PATH              your app's git checkout (default: investigate.repos.<app> in keepsnappy.yml)
  --agent claude|codex     the AI agent (default: investigate.agent, else claude)
  --model NAME             the model of every call, recorded with the run (default: the account's own; ANTHROPIC_MODEL is not passed on)
  --codex-model NAME       codex's model (investigate.codexModel); without it, the run has no cost estimate. --model wins
  --claude-path FILE       the claude executable (investigate.claudePath)
  --codex-path FILE        the codex executable (investigate.codexPath)
  --claude-config-dir DIR  runs claude on another account, as CLAUDE_CONFIG_DIR (investigate.claudeConfigDir); the folder must exist
  --codex-home DIR         runs codex on another account, as CODEX_HOME (investigate.codexHome); the folder must exist
  --max-turns N            the turn budget (investigate.max_turns, default 26)
  --max-minutes N          the time budget (investigate.max_minutes, default 15)
  --save                   keeps the agent, its path and its account folder of this run in your config file
  --dry-run                does everything except storing the hypotheses
  --preflight              checks everything up to the agent's start, with no model call; ends with KEEPSNAPPY-STATUS preflight-ok
  --json                   prints the result as JSON, with the tokens by kind as "usage"
  --run-id ID              names the run (inv-run-<finding-id>-<ms>-<6 hex>)
  --keep-session           claude only: keeps the session for a reply (below)
  --config keepsnappy.yml  the config file

  Level-by-level search, with --prompt-version investigate-v10 (the default is investigate-v9, one search; act uses v10):
  --prompt-version investigate-v9|investigate-v10
  --level-models l1=MODEL,…   the model of a level (default claude-sonnet-5-5 for levels 1 and 2, claude-opus-5-5 for 3 and 4;
                           codex: its own default, then gpt-5.6-terra); not with --model
  --max-level 1..4         stops after that level (Haiku on level 1 only: --level-models l1=claude-haiku-5-5 --max-level 1)
  --haiku-first            act's models: claude-haiku-5-5 on levels 1 and 2, claude-sonnet-5-5 on 3, claude-opus-5-5 on 4
                           (codex: gpt-5.6-luna or --codex-model, then gpt-5.6-terra); not with --model
  --second-opinion         with --haiku-first and claude: two cheap answers at levels 1 and 2, and a cheap check of a held answer before level 4.
                           It reuses no stored answer
  --hop-rank               shows the files nearest the components that grew first, by how much they grew, cut at 60 KB:
                           a file past the cut is named but remains unshown. Level 2 also shows the changed files two imports away (up to 20 files, 24 KB)
  --max-usd DOLLARS        stops before a level or a retry once the cost reaches this (above 0, at most 20); stores nothing and
                           ends with KEEPSNAPPY-STATUS usd-cap. Default: no limit; act and watch pass on_alarm.max_usd_per_run

  Level 1 shows the changed code of the components that grew. Level 2 adds the code one import away.
  Level 3 shows app-wide changes: dependencies, app root, navigation, providers, stores, native and build config, flags.
  Level 4 searches freely, only for a Worse that blocks. The levels allow at most 2, 5, 8 and 12 tool calls.
  When many places on many screens moved together, the search starts at level 2 on the component they share, else at level 3.
  A rejected, refused or low-confidence answer at level 1 or 2 is asked once more with the level 3 model.
  A low-confidence answer never ends the search as a cause. Where level 4 cannot run (an alarm that does not block, or --max-level 3),
  the run ends "not sure what caused it" and stores nothing.
  A level that fails after a held low-confidence answer fails the run (exit 1) and stores nothing.
  A low-confidence answer proposes no false alarm, and act makes no fix from it.
  An answer that this area did not change is refused while a changed file within 2 imports of a grown component was not shown.
  A stored cause of medium or high confidence for the same changes and places is reused without a model call.
  --json reports each level, its model, turns, tokens and cost, and why it moved on ("ladder").

  Settings: a flag wins over keepsnappy.yml (or --config), which wins over your config file, then claude or codex on PATH.
  For example: keepsnappy config set investigate.claudePath ~/.local/bin/claude. The agent's path must be an executable file.
  At the end it prints one line such as "used 68k tokens (~$0.06)": what the agent used, and its cost on an API key.
  KeepSnappy records every run that started the agent, also a failed one (not with --dry-run); keepsnappy hypotheses <id> lists them.
  In GitHub Actions, the hypotheses link to the CI run that made them.
  What the agent said and did stays on this Mac, redacted, for conversations.keep_days (default 7; 0 keeps nothing).
  keepsnappy conversations lists it.

  Replies: --keep-session (claude only; not with conversations.keep_days 0) keeps the worktree and claude's transcript once the agent has answered.
  Both are removed 48 hours after the last activity, and 7 days after the start at most.
  --followup RUN_ID replies to an investigation: in the kept session, else in a new one that sees the earlier answer, redacted.
  A reply round has at most 12 turns and 8 minutes. Each reply is read from its --message-file (at most 8 KB).
  Each reply is named by its --client-id; an id already sent is not sent again.
  A revised hypotheses block in the answer is checked and stored as a new one. conversations.max_replies (default 5) limits replies per conversation.
  It ends with KEEPSNAPPY-FOLLOWUP ended <outcome>, refused <word> or duplicate.

  Key: KEEPSNAPPY_KEY, or the variable --key-env NAME names. API: --api URL or KEEPSNAPPY_API.
  Log in to the agent once first: claude login or codex login.
```

You can give `--message-file` and `--client-id` more than once, one value each time.

## review

Use it in CI after `run --wait` for an AI answer on each alarm. Your AI provider sees the diff. KeepSnappy receives only the answer per alarm, never the diff.

```text
keepsnappy review: in CI after run --wait, asks your own claude or codex whether each alarm of the session is a false alarm or real, and sends KeepSnappy the answer.
  Usage: keepsnappy review [options]
  With claude: Needs Claude Code 2.1.308 or newer (`claude --version`); an older one stops the step with exit 1 before any AI call.

  --run-set ID ...         the sessions (default: the one in <out>/keepsnappy-result.json, written by run --wait)
  --out DIR                the output folder, as for run (default: output.dir in keepsnappy.yml, else keepsnappy-out)
  --repo PATH              your app's git checkout (default: the current folder); it needs the full history (fetch-depth: 0 on actions/checkout)
  --agent claude|codex     the AI (default: investigate.agent in keepsnappy.yml, else claude)
  --model NAME             asked first (default claude-haiku-5-5, or gpt-5.6-luna for codex)
  --strong-model NAME      asked again in doubt; its answer is final (default claude-sonnet-5-5, or gpt-5.6-terra)
  --escalate-below 0..1    the confidence under which the strong model is asked (default 0.8)
  --no-escalate            never asks the strong model
  --claude-path FILE --codex-path FILE --claude-config-dir DIR --codex-home DIR   as for investigate
  --max-minutes N          the time limit of one AI call (default 5)
  --dry-run                does everything except posting
  --json                   prints the answers as JSON
  --config keepsnappy.yml  the config file
  --api URL                the KeepSnappy API (or KEEPSNAPPY_API)
  --key-env NAME           the variable that holds the key (default KEEPSNAPPY_KEY)

  The strong model is also asked when the first answer cannot be read, or calls a Worse that blocks a false alarm.
  When the strong model's answer is refused and the first one was usable, the first answer is posted, marked as such.
  A Worse that blocks is never called a false alarm that way.
  The AI key is ANTHROPIC_API_KEY (claude) or OPENAI_API_KEY / CODEX_API_KEY (codex), else the agent's own login.

  What leaves your CI: the diff goes to your AI provider, without files of secrets (.env*, keys, certificates, google-services.json) and with token shapes redacted.
  KeepSnappy receives only the answer per alarm: false alarm or real, the confidence, a redacted reason of at most 25 words, the model, the tokens used and a hash of the diff.
  The AI runs with no tools, in an empty temporary folder, without your KeepSnappy key.
  Alarms a person marked, sessions with no code change, and alarms already answered with this prompt are left alone.
  So are sessions whose change cannot have changed the app: the same bundle (source map debug id) and no dependency change, and for React Native the same native fingerprint.
  The bundle and fingerprint come from KeepSnappy; with none, the AI reviews as before. app.framework in keepsnappy.yml (react-native or web) chooses what is checked.

  Exit codes: 0 when review finishes, also when the AI or the post fails (it prints a warning, and KeepSnappy holds no AI answer for that session);
  1 when something you must fix is missing: no AI key and no login, the agent not installed, a commit not in the clone, or not a git repository; 2 for a wrong command line.
```

You can give `--run-set` more than once, one value each time.

## act

Use it in CI after `run --wait`, in place of `review`, when you also want investigations and fixes on the pull request. KeepSnappy receives only the AI answers and the hypotheses, never code.

```text
keepsnappy act: in CI after run --wait, gets an AI answer on each alarm, lets claude investigate and fix the alarms your policy names, and reports on the pull request.
  Usage: keepsnappy act [--agent claude] [options]
  Needs Claude Code 2.1.308 or newer (`claude --version`); an older one stops the step with exit 1 before any AI call.

  --run-set ID ...         the sessions (default: the one in <out>/keepsnappy-result.json, written by run --wait)
  --out DIR                the output folder, as for run
  --repo PATH              your app's git checkout, with its full history (default: the current folder)
  --config FILE            the file that holds the policy
  --agent claude           act runs only claude
  --claude-path FILE       the claude executable, as for investigate
  --claude-config-dir DIR  the claude account folder, as for investigate
  --prompt-version investigate-v9|investigate-v10   v10 (the default here) searches level by level; v9 is the single search investigate uses
  --level-models l1=MODEL,…   the model of one level; the other levels keep theirs
  --max-level 1..4         stops after that level
  --hop-rank               v10 only: shows the files nearest the slower component first, and level 2 also the changed files two imports away
  --escalate-below 0..1    the confidence under which the AI answer is asked again with a stronger model (default 0.8)
  --second-opinion         v10 only: asks two cheap answers at levels 1 and 2 and a cheap check before level 4 and a fix; the extra calls are reported
  --pr N                   the pull request (default: the pull_request event, else the one open pull request of this branch)
  --no-github              posts nothing, and prints what it would post
  --github-author LOGIN    the account act posts as (for a GitHub App token: <app-slug>[bot])
  --dispatch-workflow FILE the workflow that measures a fix branch
  --dry-run                does everything except posting and storing, and prints the calls instead
  --json                   prints the report as JSON, with each group's levels, models, tokens and cost
  --api URL                the KeepSnappy API (or KEEPSNAPPY_API)
  --key-env NAME           the variable that holds the key (default KEEPSNAPPY_READ_KEY when set, else KEEPSNAPPY_KEY)

  The policy is the on_alarm section of .keepsnappy.yml, else of keepsnappy.yml, at the root of --repo.
  act reads it from the checked-out commit, so a pull request can change its own policy.
    on_alarm:
      investigate: [worse, slightly_worse]   # alarms to investigate: worse_blocks, worse, slightly_worse
      fix: [worse_blocks]                    # alarms to fix (same words); a fix needs a cause of medium or high confidence
      fix_as: pr                             # pr (default): a draft pull request; suggestions: small one-file fixes as suggestions on the pull request
      fix_dispatch_workflow: perf.yml        # the workflow that measures a fix (default: the one running; --dispatch-workflow wins)
      agent: claude                          # --agent wins
      max_runs_per_day: 5                    # investigations per app per UTC day, across all your CI runs (default 5, at most 50)
      max_fix_prs_per_finding: 1             # open fix pull requests per alarm (default 1, at most 5, 0 for none)
      max_dispatches_per_fix: 1              # measuring runs per fix push (default 1, at most 3, 0 for none)
      max_usd_per_run: 1.00                  # the most one investigation may spend (default 1.00, at most 20); at the limit it stops and stores nothing
  Without on_alarm, act runs only the AI answers and says that investigate is off. A wrong value exits 2 and names its key.
  Each limit that is reached is said in the log and in the pull request summary.

  What act leaves alone: alarms a person marked a false alarm, sessions with no code change, and alarms outside the policy.
  An alarm that does not block and that the AI answer calls a false alarm with confidence 0.8 or more is not investigated.
  On a re-run, an AI answer stored earlier for the session counts, and an alarm already investigated for the session is skipped.

  Alarms of one session that share a changed file are investigated together, once.
  The search goes level by level, from the changed code nearest the slower component outwards.
  Levels 1 and 2 ask claude-haiku-5-5, level 3 claude-sonnet-5-5, and level 4 claude-opus-5-5, only for a Worse that blocks.
  A weak or low-confidence answer is asked once more with the level 3 model before the next level.
  An alarm that does not block and ends with a low-confidence answer is reported as "not sure what caused it", and nothing is stored.
  A low-confidence cause is never fixed and never proposes a false alarm.
  A group with the same changes and places as one already investigated gets the stored answer, without a model call.

  Fixes: each group with a cause gets one fix. The agent edits a separate worktree with edit-only tools and no token.
  act checks the change as fix does, and pushes only keepsnappy/fix-<id>-<source>, never your branch and never forced.
  It opens a draft pull request into the measured branch (main for an alarm on main), saying the change is AI-written and unreviewed.
  Then it starts your workflow on the fix branch (workflow_dispatch), so the fix is measured and its result posted on the fix pull request.
  The job needs contents: write, pull-requests: write and actions: write, and the workflow an on: workflow_dispatch: trigger.
  Without them the pull request stays, and act says what to add.
  A pull request from a fork, a read-only token or a missing GH_TOKEN fixes nothing and exits 0.
  A fix that exists for the same alarm and pull request is not made again. One cause on two phone models is one fix.
  Fixes count in the same daily limit as investigations.
  A run on a keepsnappy/fix-* branch never investigates or fixes. It posts one comment on the fix pull request: each place before → after
  (fixed, still slower, worse, or not measured yet, with the reason), and adds the result to the summary of the original pull request.

  Keys and data: the investigating agent reads the code in a separate worktree, with Read, Grep and Glob only: no shell, no web.
  It gets only the Read key (KEEPSNAPPY_READ_KEY, or the variable --key-env names) and no GitHub token.
  KEEPSNAPPY_KEY, usually the CI key that uploads, never reaches it, and --key-env KEEPSNAPPY_KEY is refused.
  With investigate on and no Read key, the AI answers still run and post, no investigation starts, and act exits 1 with "investigate needs a read key".
  Only the hypotheses reach KeepSnappy, redacted: code blocks and lines of the diff become [code].

  On a pull request, act posts with GH_TOKEN or GITHUB_TOKEN (pull-requests: write): one summary comment,
  and one comment at the cause of each group (on its lines, else on its file, else on the pull request).
  A re-run edits these comments; a cause that moved is marked superseded; nothing is deleted.
  act edits only its own comments: the account is --github-author, else what GitHub says for the token, else github-actions[bot]. If it cannot tell, it posts nothing.
  AI text is posted inside code spans, with links defanged (hxxps://) and each field cut at 1,000 characters.
  A refused token or an unreachable GitHub posts nothing, says so, prints the summary to the log and does not fail the step.
  On main, act posts nothing and prints what it would post.
  The repository is GITHUB_REPOSITORY, else the origin remote; the GitHub API is GITHUB_API_URL, else https://api.github.com.
  A group over the daily limit is skipped and said. A refused AI call says why: the key (401), a rate limit (429) or an overload (529).

  Exit codes: 0 when act finishes, also when the AI, the provider or a post fails (it prints a warning);
  1 when something you must fix is missing: no AI key and no login, claude not installed, a commit not in the clone, not a git repository,
  a refused KeepSnappy key, or investigate on without a Read key (the groups after it are not started); 2 for a wrong command line or policy.
```

You can give `--run-set` more than once, one value each time.

## compare-now

Use it when a pull request had no `main` session to compare with, and `main` has one now. It needs [the Mac app’s key](https://keepsnappy.com/docs/glossary.md#the-mac-apps-key).

```text
keepsnappy compare-now: compares a pull request's results again with main as it is now.
  Usage: keepsnappy compare-now <branch | run-set-id> [--yes] [--json] [--api URL] [--key-env NAME]
  A branch means its newest pull request result; a run-set-id is a session id. On the dashboard, use Compare with main now.
  It needs the Mac app's key in KEEPSNAPPY_KEY. A CI key is refused.

  --yes                    does it; without --yes it prints the warning and stops
  --json                   prints one line, in the shape watch --json uses for it
  --api URL --key-env NAME the KeepSnappy API and the variable that holds the key
```

## mark

The KeepSnappy Mac app uses it to record a person’s mark, with [the Mac app’s key](https://keepsnappy.com/docs/glossary.md#the-mac-apps-key). On the dashboard, use **Mark false alarm**.

```text
keepsnappy mark: marks one alarm of a session as a false alarm or real, as a person's decision, or clears the mark.
  Usage: keepsnappy mark <run-set-id> <place> false-alarm|real|clear [--reason "…"] [--phone MODEL] [--journey KEY] [--json] [--api URL] [--key-env NAME]
  <run-set-id> is the session id; <place> is the place of the alarm, as keepsnappy finding and the AI answer name it. Only Worse and Slightly worse places can be marked.
  It needs the Mac app's key in KEEPSNAPPY_KEY. A CI key is refused and changes nothing. On the dashboard, use Mark false alarm.

  --reason "…"             required for false-alarm, up to 500 characters
  --phone MODEL --journey KEY   which one, when the place is in more than one journey or phone model of the session
  --json                   prints what KeepSnappy stored
  --api URL --key-env NAME the KeepSnappy API and the variable that holds the key
```

## fix

Use it to let your own AI agent try a fix for the alarms of a pull request. You review the draft pull request it opens.

```text
keepsnappy fix: lets your own claude or codex try a fix for the alarms of a pull request, and opens it as a draft pull request.
  Usage: keepsnappy fix <pr-number|branch> [options]                every Worse and Slightly worse alarm of the pull request
         keepsnappy fix <finding-id…> | --finding f_… [--finding f_…] [options]   only these alarms (all on one pull request)
         keepsnappy fix --followup FIX_ID --message-file FILE --client-id ID [--message-file FILE --client-id ID …]   a reply to a fix

  --list                   prints the alarms that can be fixed, the most felt first, and why others cannot; runs no agent and writes nothing to git
  --branch B               the pull request's branch (the same as giving it first)
  --dry-run                keeps the fix branch local: nothing is pushed, opened or recorded
  --json                   prints one event per line (started, commit, skipped_finding, flagged, refused, ended), each with the run's fix_id
  --fix-id ID              names the run (fix-<ms>-<6 hex>)
  --agent claude|codex     the AI agent; codex runs only when its sandbox check passes
  --model NAME             the model, recorded with the run (default: the account's own); wins over --codex-model
  --codex-model NAME       codex's model
  --claude-path FILE --codex-path FILE --claude-config-dir DIR --codex-home DIR   as for investigate
  --max-turns N            the turn budget (fix.max_turns, default 60)
  --max-minutes N          the time budget (fix.max_minutes, default 30)
  --allow-path GLOB …      lets the fix change a dotfile that matches
  --repo PATH              your app's git checkout
  --remote NAME            the git remote to push to; it must push to the pull request's repository
  --new                    makes a new fix branch when one exists already
  --auto                   records the fix as started by watch on its own, not by a person
  --keep-session           claude only: keeps the session for a reply (below)
  --config keepsnappy.yml  the config file

  --list --json prints one object. Each row's ms is how much slower it is, in ms, or null when that is unknown. Those rows come last and read Slower by an unknown amount.

  How it works: fix creates keepsnappy/fix-<pr> from the pull request's head in a separate worktree, never your working copy.
  The agent edits files there with edit-only tools and a clean environment. Needs Claude Code 2.1.308 or newer.
  The run is refused when the change touches a workflow file, a lockfile, a credential, a dotfile you did not allow, a link, a deleted file or a binary,
  or more than 20 files or 600 lines (fix.max_files, fix.max_lines).
  A workflow file, .gitattributes, .npmrc, a git hook or an AI tool's config is refused even with --allow-path.
  A build or install script is allowed, and flagged in the pull request.
  fix makes one commit, checks it again, then pushes the branch with your own git and gh login.
  It opens a draft pull request into the pull request's branch, never into the default branch, and records it. A fork is refused.

  Replies: --keep-session (claude only; not with --dry-run or conversations.keep_days 0) keeps the worktree and claude's transcript after the draft pull request opens.
  Both are removed 48 hours after the last activity, and 7 days after the start at most.
  --followup FIX_ID replies to a fix: in the kept session, else in a new one at the fix branch's head that sees the earlier answer, redacted.
  A reply round has at most 20 turns and 10 minutes. Each reply is read from its --message-file (at most 8 KB) and named by its --client-id.
  A merged or closed draft pull request is refused. When the fix branch moved on and the worktree is clean, it is fast-forwarded and the agent told what arrived.
  Any other difference is refused (branch_diverged): nothing is merged, rebased or forced.
  A change gets the same checks and becomes one commit, pushed without force, and the draft pull request updates. An answer with no change commits nothing.
  conversations.max_replies (default 5) limits replies per fix. It ends with KEEPSNAPPY-FOLLOWUP ended <outcome>, refused <word> or duplicate.

  Key: KEEPSNAPPY_KEY, or the variable --key-env NAME names. API: --api URL or KEEPSNAPPY_API. gh must be logged in.
```

You can give `--finding`, `--allow-path`, `--message-file` and `--client-id` more than once, one value each time.

## conversations

Use it to see or delete what your AI runs said on this Mac. None of it is uploaded.

```text
keepsnappy conversations: lists what your AI runs (investigate, fix) said and did on this Mac, and deletes it when asked.
  Usage: keepsnappy conversations [--json] [--prune | --purge] [--config keepsnappy.yml]
  Each conversation is kept redacted in <state>/conversations/<run id>/, readable only by you, and never uploaded.
  It is kept conversations.keep_days after its last event (0 to 30, default 7; 0 keeps none), and 100 MB in all, oldest removed first.
  watch and every run remove what is past that.
  A kept session (--keep-session: claude's transcript and the worktree) is removed 48 hours after its last activity, 7 days after its start at most, and with its conversation.

  --prune                  removes now what is past the limits
  --purge                  removes every conversation that no run is writing
  --json                   prints {"type":"conversations","items":[…]}, or {"removed":[run ids]} with --prune or --purge
  --config keepsnappy.yml  the config file
  State: KEEPSNAPPY_STATE_DIR (default $XDG_STATE_HOME/keepsnappy, else ~/.local/state/keepsnappy).
```

## activation-link, flush-link and gc-link

<span id="activation-link"></span><span id="flush-link"></span><span id="gc-link"></span>Use these when your own test code opens the app and needs the links that control its KeepSnappy session.

```text
keepsnappy activation-link, flush-link and gc-link: print a link that your test code opens in the app to control its KeepSnappy session.
  Usage: keepsnappy activation-link --scheme <app://> --token <run token> [--no-diag] [--no-profile] [--set k=v ...]
         keepsnappy flush-link --scheme <app://>
         keepsnappy gc-link    --scheme <app://> [--n 1]
  activation-link starts the session; flush-link makes the app send its data; gc-link asks the app to collect garbage --n times.
  --scheme <app://>        the app's URL scheme, for example myapp://
  --token <run token>      the run's token, from tokens.js
  --no-diag --no-profile   turn off the SDK's diagnostics or profiling, which are on by default
  --set k=v ...            other SDK settings
```

You can give `--set` more than once, one value each time.

## init

Use it once per app repository to set up the SDK, `keepsnappy.yml` and a KeepSnappy workflow. It shows every change as a diff and asks before it writes.

```text
keepsnappy init: sets up your app repository for KeepSnappy, showing each change as a diff and asking before it writes.
  Usage: keepsnappy init [--yes] [--no-key] [--nightly] [--dir FOLDER] [--bundle-id ID] [--sdk-version X.Y.Z] [--agent-version X.Y.Z] [--api URL]
         keepsnappy init --detect [--json] [--dir FOLDER] [--bundle-id ID]
         keepsnappy init --key [--yes] [--dir FOLDER] [--api URL]
  Run it in your app's repository. It finds your package manager, Expo or bare React Native, your GitHub workflows,
  and your Maestro flows, Appium (wdio) tests or e2e (e2e.com) tests.

  --yes                    asks nothing and applies the changes; the key is stored only with --key
  --nightly                adds a nightly run at 02:17 UTC, which uses GitHub runner minutes (asked when interactive, default no)
  --no-key                 skips the key step
  --key                    does only the key step
  --dir FOLDER             the app's folder, in a monorepo
  --bundle-id ID           the iOS bundle id, when neither app.json nor the Xcode project gives it (the Android package when only Android runs your tests)
  --sdk-version X.Y.Z --agent-version X.Y.Z   install exact versions in place of this CLI's compatible defaults
  --detect                 writes nothing and asks nothing; prints the plan
  --json                   with --detect: {"version":1,"dir","app","runner","ci","steps":[{"id","action","path"?,"command"?,"detail"}],"problems","notes"}
  --api URL                the KeepSnappy API address

  What it writes: the SDK (@keepsnappy/react-native) and the keepsnappy command (@keepsnappy/agent, a devDependency), both at an exact version;
  the plugin in app.json; a wrapped or new metro.config.js; keepsnappy.yml; .gitignore lines; and .github/workflows/keepsnappy.yml.
  The workflow is a copy of your own end-to-end job: it builds with KEEPSNAPPY: '1' and runs your tests through keepsnappy run,
  on pull requests, on pushes to the default branch, and by hand.
  An iOS simulator job and an Android emulator job each become their own job. The Android job builds with the secret
  EXPO_PUBLIC_KEEPSNAPPY_KEY (the SDK key) and the variable KEEPSNAPPY_API.
  It never edits an existing workflow or your app's code. A second run changes nothing.
  Then it offers to store your CI key as the GitHub secret KEEPSNAPPY_KEY with gh (a hidden prompt; the key is checked first),
  and ends with keepsnappy doctor --group app.

  Journeys: with Maestro, each flow is its own journey. With a Maestro workspace (a config.yml with flows:, includeTags:, excludeTags: or executionOrder:
  in or above the flow folder), init keeps your maestro command, and the whole suite is one journey, named "e2e".
  e2e tests with AI steps (agent.act, …) that the command does not leave out are named, because their runs do not count.
  Detox is not set up by init; it works with runner: command in keepsnappy.yml.

  Questions default to no. Without a terminal to answer them, nothing is applied unless you give --yes.
  Exits 0 once the changes are made (or none were needed), and prints what doctor still lists as next steps.
  Exits 1 when it cannot go on, when an install fails, or when --key could not store the key.
  Outside an app repository, init runs keepsnappy setup instead, with a notice, for one more release.
```

## setup

Use it on a Mac that should watch results and run investigations.

```text
keepsnappy setup: sets up this Mac to watch results and investigate alarms, asking only about what is missing.
  Usage: keepsnappy setup [--yes] [--app SLUG] [--repo app=path ...] [--agent claude|codex] [--claude-path FILE] [--codex-path FILE] [--config FILE] [--api URL] [--key-env NAME]
         keepsnappy setup --detect [--json] [--app SLUG] [--config FILE] [--api URL] [--key-env NAME]
  It shows each setup step (as keepsnappy doctor --group setup does), then asks for what is missing: each app's repository folder, the agent and its path.
  Each question shows what it found on this Mac; Enter accepts it. Run it again any time.

  --yes                    asks nothing: a flag decides, else what was found. A folder that only looks right by its name is shown, not used.
  --app SLUG               only this app
  --repo app=path ...      the repository folder of an app
  --agent claude|codex     the AI agent
  --claude-path FILE --codex-path FILE   the agent's executable
  --detect                 asks and writes nothing; lists the repository folders found for each app and how each matched
                           (remote: a git remote is the app's repository; name: only the folder or a remote has the app's name)
  --json                   with --detect: {"version":1,"apps":[{"app","repo_url","candidates":[{"path","remotes","match"}]}]}
  --config FILE            where to write the settings (default: your config file, as keepsnappy config set)
  --api URL --key-env NAME the KeepSnappy API and the variable that holds the key
  The key is never written to a file: it stays in KEEPSNAPPY_KEY, or the variable --key-env names.
```

You can give `--repo` more than once, one value each time.

## skill

Use it when you want Claude Code or Codex to set KeepSnappy up in your repository. If your CLI supports `keepsnappy skill print`, it writes the setup guide bundled with that version to standard output.

```text
keepsnappy skill: copies the keepsnappy-setup skill into your project, so Claude Code or Codex can set KeepSnappy up for you.
  Usage: keepsnappy skill install --claude|--codex [--force] [--dir PROJECT]

  --claude                 copies it to .claude/skills/keepsnappy-setup/
  --codex                  copies it to .agents/skills/keepsnappy-setup/ (give both flags for both)
  --dir PROJECT            the project's root (default: the git root of the current folder, else the current folder)
  --force                  overwrites a copy you edited

  Run it again any time: a current copy is left alone, and an older one is updated. A copy you edited is kept unless you give --force.
```

## config

Use it to set your AI agent, its path and your repository folders once, for every command.

```text
keepsnappy config: reads and changes your own settings, which every keepsnappy command on this machine uses.
  Usage: keepsnappy config set <key> <value> | unset <key> | get <key> | list [--config FILE]
  The file is $XDG_CONFIG_HOME/keepsnappy/config.yml, else ~/.config/keepsnappy/config.yml. --config FILE edits another file.
  unset removes the key and leaves the rest of the file as it is; it exits 1 when the key is not set.
  keepsnappy.yml wins over this file, and a flag wins over both. Keys:
    verdict_gate             advisory or blocking; only in keepsnappy.yml: keepsnappy config get verdict_gate --config keepsnappy.yml
    retry.failed_runs        0..3 (default 0, off): spare Appium runs per journey for farm run and farm open; the command's own value wins.
                             Only in keepsnappy.yml: keepsnappy config set retry.failed_runs 1 --config keepsnappy.yml
    investigate.agent        claude or codex
    investigate.claudePath   the claude executable (default: claude on PATH), for example keepsnappy config set investigate.claudePath ~/.local/bin/claude
    investigate.codexPath    the codex executable (default: codex on PATH)
    investigate.claudeConfigDir  the claude account folder to run on (CLAUDE_CONFIG_DIR), for example ~/.config/claude
    investigate.codexHome        the codex account folder to run on (CODEX_HOME)
    investigate.repos.<app>  the app's git repository folder, for example keepsnappy config set investigate.repos.myapp ~/apps/my-app
  An agent path must be an executable file. A repository or account folder must exist, and is stored as an absolute path (a leading ~/ stays).
  Without an account folder, the agent runs on its own default account.
```

## watch

Use it on your Mac to hear about a slower pull request without opening the dashboard.

```text
keepsnappy watch: shows a Mac notification when a pull request gets slower, so you hear about it without opening the dashboard.
  Usage: keepsnappy watch [options]
  By default it watches all pull requests and main of every app your key reads.
  It notifies only a pull request that is Worse or Slightly worse, and a main result that stands out. Other results are listed only with --json.
  A notification has two buttons: [Investigate] runs keepsnappy investigate in the background and says how many hypotheses it stored; [Open verdict] opens the result.
  The first start shows nothing old. It remembers where it stopped, and a restart goes on from there.

  --app NAME ...           only these apps, for pull requests and main
  --branch GLOB            only pull request branches that match (* and ?)
  --mine                   opt-in (watch.mine: true): only pull requests whose head commit has your git user.email in the app's repository
                           (investigate.repos.<app>); an app with no repository set shows no pull request. Main is not filtered.
                           --all, every pull request, is accepted and is what happens without --mine
  --history-days N         with --json: first lists the results of the last N days, oldest first, without notifying (default 0)
  --interval SECONDS       between polls (watch.interval_seconds; default 60, at least 5)
  --notifier alerter|terminal-notifier|osascript|stdout   how to notify (default: the first of these that works)
  --once                   polls once and exits
  --config keepsnappy.yml  the config file
  --agent claude|codex     the agent an [Investigate] click runs (investigate.agent)
  --claude-path FILE --codex-path FILE --claude-config-dir DIR --codex-home DIR   as for investigate, for a click
                           (for example: keepsnappy config set investigate.claudePath ~/.local/bin/claude)

  --auto-on-worse          also investigates each Worse on its own, one at a time per app (watch.auto_on_worse; off by default).
                           It uses act's models and limits: on_alarm.max_runs_per_day (default 5) per app per UTC day, counted with act's runs,
                           and on_alarm.max_usd_per_run (default $1.00). At the limit nothing starts and the notification says so.
                           It always runs claude. A click is not limited.
  --auto-fix               also runs keepsnappy fix on a pull request once hypotheses are stored for a Worse (watch.auto_fix; off by default).
                           It needs --auto-on-worse or an earlier investigation, and runs only claude, never for main, one at a time per app,
                           once per head commit. A skipped fix says why: main, codex, busy, queued, exists or no-hypotheses.

  --json                   for the KeepSnappy Mac app: no notifications; one JSON object per line on stdout, and commands on stdin, one per line:
    {"cmd":"investigate","finding_id":"f_…"}             investigates like a click; add "branch":"<branch>" for that pull request
    {"cmd":"fix","finding_ids":["f_…"]}, {"cmd":"fix","branch":"feat/x"} or {"cmd":"fix","pr":N}   runs keepsnappy fix and streams its lines;
                                                         "new":true makes a new fix branch
    {"cmd":"followup","run_id":"inv-run-…|fix-…","text":"…","client_id":"c_…"}   replies to an investigation or a fix
    {"cmd":"followup_cancel","run_id":"…","client_id":"…"}   cancels a queued reply
    {"cmd":"stop","run_id":"…"}                           stops a run this watcher started (it is killed after 2 minutes)
    {"cmd":"conversation","run_id":"…","from_seq":N}      replays what the agent of a run said and did
    {"cmd":"conversations"}                               lists the kept conversations
    {"cmd":"refresh"}                                     polls now (at most once per 5 seconds)
  The first line, hello, lists the commands it reads. Closing stdin stops watch.
  An investigation that an earlier watch started is followed to its end ("resumed":true).
  Clicks and fixes from the app keep their session for a reply, as with --keep-session.

  Key: KEEPSNAPPY_KEY, or the variable --key-env NAME names. API: --api URL or KEEPSNAPPY_API.
  A click runs this same keepsnappy, or KEEPSNAPPY_BIN. State: KEEPSNAPPY_STATE_DIR (default $XDG_STATE_HOME/keepsnappy, else ~/.local/state/keepsnappy).
```

You can give `--app` more than once, one value each time.

## branches

Use it to see the result of every recent branch at once, in a terminal.

```text
keepsnappy branches: lists the recent branches of your app, each with its worst current result, as the dashboard's Branches page does.
  Usage: keepsnappy branches [--days N] [--sort newest|needs-look] [--app SLUG] [--json] [--config keepsnappy.yml] [--api URL] [--key-env NAME] [-h | --help]
  One line per branch, with its worst current result and its phone models. Branches still running or waiting for main come last.

  --days N                 how far back (default 30)
  --sort newest|needs-look newest result first (the default), or worst result first
  --app SLUG               the app the key must be for; a key reads one app, and another app is an error
  --json                   one JSON object: {"version":1,"app","app_name","days","sort","generated_at","more","branches":[…],"main":[…]}
                           more: there were more pushes than one answer holds, and the oldest are left out.
                           Each phone model has "finding_id" (the alarm of its result, or null) and "hypotheses" ({count, latest_submission_id, latest_at}, or null).
                           main: the newest session of each phone model that ran main, newest first:
                           phone, phone_name, scenario_name, word, state, last_run_at, url, run_set_id, finding_id, hypotheses
  --config keepsnappy.yml  accepted, and changes nothing (the Mac app passes it to every command)

  Key: KEEPSNAPPY_KEY, or the variable --key-env NAME names (a Read key or a CI key). API: --api URL or KEEPSNAPPY_API.
```

All KeepSnappy docs for agents: https://keepsnappy.com/llms.txt
