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

# AI review in CI

> Add keepsnappy review to your KeepSnappy job, to have Claude or Codex say whether the code change explains a pull request's alarms. Where its answer shows, when it skips the AI, and which model answers.

`keepsnappy review` asks Claude or Codex whether the code change can explain the alarms it reviews. It runs in your CI with your own AI key, after the measuring step. What the AI steps cost and what leaves your CI are on [AI review and investigation in CI](https://keepsnappy.com/docs/ai-in-ci.md).

Every flag is in the CLI reference, under [review](https://keepsnappy.com/docs/reference/cli.md#review).

## Add the review step

Add the two `if:` steps below after the measuring step of your KeepSnappy job ([the complete workflow](https://keepsnappy.com/docs/ci.md#a-complete-workflow)). For the review alone, the job needs only `contents: read`, and your CI key in `KEEPSNAPPY_KEY` is enough:

```yaml
jobs:
  keepsnappy:
    permissions:
      contents: read
    steps:
      - uses: actions/checkout@v4
        with:
          ref: ${{ github.event.pull_request.head.sha || github.sha }}
          fetch-depth: 0
      # the measuring step of your KeepSnappy job
      - if: ${{ !cancelled() }}
        run: npm install --global @anthropic-ai/claude-code
      - if: ${{ !cancelled() }}
        run: npx --no-install keepsnappy review
        env:
          KEEPSNAPPY_KEY: ${{ secrets.KEEPSNAPPY_KEY }}
          ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
```

- `if: ${{ !cancelled() }}` runs the AI steps even when the measuring step fails, for example when the result doesn't arrive in time.
- `fetch-depth: 0` fetches the commits the comparison needs.

Claude Code (`claude`) must be 2.1.308 or newer. An older one stops the step before any AI call.

To review with Codex, install `@openai/codex`, pass `OPENAI_API_KEY`, and run `keepsnappy review --agent codex`.

To preview the review on your Mac, run `keepsnappy review --run-set ID --dry-run` in your app's checkout, with the session's run set ID from `keepsnappy-result.json` or the dashboard link. It posts and stores nothing, but still sends the diff to your AI provider.

## The AI answer next to the result

<span id="where-the-answer-shows"></span>The review's answer shows as soon as KeepSnappy stores it, on the dashboard and in `keepsnappy status`. Nobody accepts it first. The result, the KeepSnappy check and the counts stay as measured, so a **Worse** that blocks still blocks, and a person's mark wins over the AI's answer. [The AI's answer](https://keepsnappy.com/docs/false-alarms.md#the-ais-answer) shows where it appears and what it looks like.

The review skips alarms a person marked, alarms it already answered (until its prompt changes), and sessions whose code didn't change since `main`. A failed AI call can leave the session with no AI answers. If a session ran on the same commit as the `main` sessions it is compared with, KeepSnappy answers itself and the AI is not asked ([Same commit as the baseline](https://keepsnappy.com/docs/false-alarms.md#same-commit-as-the-baseline)). One review answers at most 20 alarms per journey and phone model, **Worse** first.

## When it skips the AI

<span id="app-change-inputs"></span>When KeepSnappy can show that both builds are the same app (the same JS bundle, no dependency change and, for React Native, the same native fingerprint), the review skips the AI. You set nothing for this. When it can't tell, the AI runs as usual.

## Which model answers

The review asks `claude-haiku-5-5` first, or `gpt-5.6-luna` with Codex. It asks `claude-sonnet-5-5` (`gpt-5.6-terra`) when the confidence is under 0.8, the answer can't be read, or it calls a blocking **Worse** a false alarm.

## Exit codes

| Code | Meaning |
|---|---|
| `0` | Finished, also when the AI call or the post failed (a warning says so). |
| `1` | Something you must fix: no AI key and no login, the review's Claude Code or Codex missing or too old, a commit missing from the clone, or not a git repository. |
| `2` | The command line is wrong, or there is no session. |
| `130` | Interrupted. |

Next: to have Claude also look for the cause of an alarm and propose a fix, see [AI investigation and fixes in CI](https://keepsnappy.com/docs/ai-act.md).

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