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

# AI help with alarms

> Four ways to have your own Claude or Codex look at a KeepSnappy alarm, in CI, on your Mac or in your coding agent. Pick one.

An [alarm](https://keepsnappy.com/docs/glossary.md#alarm) is what KeepSnappy raises when a place gets **Worse** or **Slightly worse** on your pull request. This page is for anyone who wants an AI to look at one. Pick the route that fits where you work. Every route uses your own Claude or Codex, on your own account or AI key, and all of them are optional.

| Route | Where it runs | What you get |
|---|---|---|
| [Review in CI](https://keepsnappy.com/docs/ai-review.md) | `keepsnappy review`, in your KeepSnappy job | An AI answer next to each alarm it thinks is a false alarm. |
| [Investigation in CI](https://keepsnappy.com/docs/ai-act.md#what-act-investigates) | `keepsnappy act`, in your KeepSnappy job | The same review, then the likely cause of the alarms your [policy](https://keepsnappy.com/docs/ai-act.md#set-the-policy) (the `on_alarm` settings) selects, as comments on the pull request. It can also propose a fix. |
| [On your Mac](#on-your-mac) | `keepsnappy investigate`, in your checkout | The likely cause of one alarm, shown on the dashboard. |
| [In your coding agent](#in-your-coding-agent) | the KeepSnappy MCP server | Claude Code or another coding agent reads your results while you work. |

In every route, your AI provider receives the code it reads. KeepSnappy receives the AI's answers as text ([what leaves your CI](https://keepsnappy.com/docs/ai-in-ci.md#what-leaves-your-ci)).

## On your Mac

`investigate` runs your own `claude` or `codex` on one alarm. It checks out the measured commit in a separate worktree of your app repo and runs the agent there, read-only. What it finds shows on the alarm in the dashboard.

You need:

- your app repo on your Mac, with its dependencies installed, so that `npx --no-install keepsnappy` runs;
- `claude` 2.1.308 or newer, or `codex`, installed and logged in once;
- no symlink in the repo that points outside it, or `investigate` starts nothing;
- a read key in `KEEPSNAPPY_KEY`, for example the one from [In your coding agent](#in-your-coding-agent).

In your app repo, `keepsnappy findings` lists your branch's alarms. Copy the id of one: each id starts with `f_`. Check the setup without calling a model, then run it:

```sh
npx --no-install keepsnappy findings --branch my-feature
npx --no-install keepsnappy investigate f_… --branch my-feature --repo . --preflight
npx --no-install keepsnappy investigate f_… --branch my-feature --repo .
```

The run ends with one line: the tokens it used and what they would cost on an API key. By default it stops after 26 turns (steps of the agent) or 15 minutes. Every flag is in the [CLI reference](https://keepsnappy.com/docs/reference/cli.md#investigate).

## In your coding agent

The KeepSnappy MCP server lets a coding agent ask what got slower on a branch, where and why. It reads results and never starts a measurement. It also stores an AI's hypotheses about an alarm, or an answer that an alarm is a false alarm, shown next to the unchanged result. Its tools are in the [MCP reference](https://keepsnappy.com/docs/reference/mcp.md).

1. On **Setup** in the dashboard, choose **Connect a coding agent**. Name it, and copy its read key. You see it once.
2. Put the key in your shell, not in the repo, for example in `~/.zshenv`:

```sh
export KEEPSNAPPY_KEY=<the read key>
```

`~/.zshenv` sets `KEEPSNAPPY_KEY` for every shell. If it holds a read key, `keepsnappy run --upload` fails: the API refuses the key with `insufficient_scope`. Set the CI key with `export` in the one shell where you measure ([Keys](https://keepsnappy.com/docs/keys.md#read-key)).

3. Add `.mcp.json` at the root of your app repo:

```json
{
  "mcpServers": {
    "keepsnappy": {
      "command": "npx",
      "args": ["-y", "@keepsnappy/mcp"],
      "env": {
        "KEEPSNAPPY_KEY": "${KEEPSNAPPY_KEY}"
      }
    }
  }
}
```

Claude Code fills in `${KEEPSNAPPY_KEY}` from your shell. Then ask it, for example, whether your branch is ok. Another coding agent takes the same command, arguments and `KEEPSNAPPY_KEY` in its own MCP settings.

The MCP server calls no AI of its own, so the cost is your coding agent's usual use. To stop it, choose **Disconnect** on the agent, on **Setup**.

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