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

# AI review and investigation in CI

> What keepsnappy review and keepsnappy act do in your KeepSnappy job, what they cost, how to turn them on, what leaves your CI, and their exit codes.

When a pull request reads **Worse** or **Slightly worse** at a place, KeepSnappy raises an [alarm](https://keepsnappy.com/docs/glossary.md#alarm), and an AI can say in CI whether the code change explains it. Its answer shows next to the result. It answers the open alarms: not those a person marked, those it already answered, or those of a session whose code didn't change ([details](https://keepsnappy.com/docs/ai-review.md#the-ai-answer-next-to-the-result)). `act` can also look for the cause.

Two commands do this. Both are opt-in, and both run in your CI with your own AI key. KeepSnappy makes no AI call and holds no AI key of yours.

## The two commands

<span id="the-ai-answer-next-to-the-result"></span><span id="where-the-answer-shows"></span><span id="app-change-inputs"></span>`keepsnappy review` asks Claude or Codex whether the code change can explain the alarms it reviews. [AI review in CI](https://keepsnappy.com/docs/ai-review.md) has its step, [where its answer shows](https://keepsnappy.com/docs/ai-review.md#the-ai-answer-next-to-the-result), and [when it skips the AI](https://keepsnappy.com/docs/ai-review.md#app-change-inputs) because the app did not change.

<span id="set-the-policy"></span><span id="the-policy"></span><span id="what-a-pull-request-can-change"></span><span id="the-daily-limit"></span><span id="what-act-investigates"></span><span id="what-the-agent-can-do"></span><span id="fix-mode"></span><span id="as-a-draft-pull-request-fix_as-pr"></span><span id="what-act-posts-on-a-pull-request"></span>`keepsnappy act` works with Claude only. It runs the same review, then Claude looks for the cause of the alarms your policy names. It can also propose a fix. [AI investigation and fixes in CI](https://keepsnappy.com/docs/ai-act.md) has its step, [the policy](https://keepsnappy.com/docs/ai-act.md#set-the-policy), [what act investigates](https://keepsnappy.com/docs/ai-act.md#what-act-investigates), [fix mode](https://keepsnappy.com/docs/ai-act.md#fix-mode) and [what act posts on a pull request](https://keepsnappy.com/docs/ai-act.md#what-act-posts-on-a-pull-request).

## What review and act share

<span id="add-a-step-to-your-workflow"></span><span id="add-it-to-your-workflow"></span>Each command's page has its step: [`review`](https://keepsnappy.com/docs/ai-review.md#add-the-review-step), and [`act`](https://keepsnappy.com/docs/ai-act.md#add-the-act-step), which also needs a [read key](https://keepsnappy.com/docs/glossary.md#read-key) and a GitHub token.

In CI, `review` and `act` don't take three things from the pull request's `keepsnappy.yml`: the AI program to run, its login folder, and any looser limits (number of AI turns, time, files, lines). These come from a flag or your own `~/.config/keepsnappy/config.yml`. The log names each setting it left out.

Both commands also run on your Mac, in your app's checkout. Run `keepsnappy review --run-set ID --dry-run`, or the same with `act`, to preview the results. The ID is the session's [run set](https://keepsnappy.com/docs/glossary.md#run-set) ID, from `keepsnappy-result.json` or the dashboard link. Dry-run skips posting and storing answers and publishing fixes. It still reads the session using your KeepSnappy key and can send the diff or other code from your checkout to the configured AI provider.

## Models and cost

<span id="cost"></span>Each step ends with one line per model: calls, tokens, and their price on an API key. At the defaults, `act` makes at most 5 investigation and fix runs a day, and each investigation stops at $1. The review isn't counted.

<span id="which-model-answers"></span>The models each command asks are on [AI review in CI](https://keepsnappy.com/docs/ai-review.md#which-model-answers) and [AI investigation and fixes in CI](https://keepsnappy.com/docs/ai-act.md#which-models-it-asks).

## What leaves your CI

Your AI provider receives the diff and the measured facts, with your key. KeepSnappy receives no diff.

Before the AI sees the diff, files that hold secrets are dropped, such as `.env*`, keys, certificates and `google-services.json`. Token shapes in the rest are redacted. The review's AI runs with no tools, in an empty folder, without your KeepSnappy key.

KeepSnappy receives:

- From the review, for each alarm: `false_alarm` or `real`, the confidence, a reason of at most 25 words, the model, the token usage and a hash of the diff.
- From `act`, each hypothesis (likely cause) as text: the claim, the file paths and lines, the evidence, the expected change and the risks.
- On GitHub Actions, the address of the workflow run, for a link on the dashboard.

That text is redacted first. Code blocks in the AI's text, and any diff line it quotes, become `[code]`. Keys, tokens and secret shapes are removed. A name or a short piece of code the AI writes in its own words can remain.

## Exit codes

| Code | Meaning |
|---|---|
| `0` | The step finished. This includes a failed AI call, post or push: a warning line says so. A provider outage never fails your build. |
| `1` | Something you must fix (see below). |
| `2` | The command line or the policy is wrong, or there is no session: no `--run-set`, and no `keepsnappy-result.json` from `keepsnappy run --wait`. |
| `130` | The step was interrupted. |

For exit code `1`, check for:

- No AI key and no login.
- Claude Code missing or too old, or Codex for the review.
- A commit missing from the clone (set `fetch-depth: 0`).
- A folder that is not a git repository.
- A refused key.
- Investigation on without a read key.

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

Next: add the review with [AI review in CI](https://keepsnappy.com/docs/ai-review.md), or the investigation and fixes with [AI investigation and fixes in CI](https://keepsnappy.com/docs/ai-act.md).

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