---
title: "Local agent swarm"
description: "Review code from your terminal with 25 agents, your model and your MiniRouter key."
canonical_url: "https://minirouter.sh/docs/guides/local-agent-swarm"
markdown_url: "https://minirouter.sh/docs/guides/local-agent-swarm.md"
last_updated: "2026-09-26"
---

# Local agent swarm

Review code from your terminal with 25 agents, your model and your MiniRouter key.

[Get a key](https://minirouter.sh/key)

## Run locally

Use Node.js 24 or later and Git. The CLI runs locally and sends code to models through MiniRouter. Only committed code is reviewed.

Create a dedicated [review key](https://minirouter.sh/dashboard/keys) with a [spend cap](https://minirouter.sh/docs/rate-limits). Set `MINIROUTER_API_KEY` in your environment, then run from your Git repository.

**Swarm**

```sh
npx @minirouter/code-review swarm \
  --base origin/main --head HEAD \
  --agents 25 --budget 5
```

20 reviewers cover logic, security, data, performance and API behavior across file slices. Four verifiers re-read the source, then one judge consolidates findings. At most eight agents run at once.

**Review**

```sh
npx @minirouter/code-review review \
  --base origin/main --head HEAD \
  --budget 2
```

Review committed changes with three agents by default: one reviewer, one verifier and one judge.

**Audit**

```sh
npx @minirouter/code-review audit \
  --head HEAD --budget 2
```

Review the committed head snapshot with three agents by default. No base revision is needed.

Reports are saved in `.minirouter-review`: `review.md`, `review.json` and `review.sarif`.

## Choose your model

The default is `minirouter/auto`. Pass a [model ID](https://minirouter.sh/models) or a [preset](https://minirouter.sh/docs/presets) with `--model`.

**Model**

```sh
npx @minirouter/code-review swarm \
  --base origin/main --head HEAD \
  --model minirouter/auto --budget 5
```

**Preset**

```sh
npx @minirouter/code-review swarm \
  --base origin/main --head HEAD \
  --model @preset/code-review --budget 5
```

Create a preset with the slug `code-review`, then change its model from your dashboard without editing the command.

## CLI options

### Options and GitHub posting

| Option | Behavior |
| --- | --- |
| `--base / --head` | Committed revisions. Review and swarm default to `HEAD~1` and `HEAD`; audit uses the head snapshot. |
| `--model` | `minirouter/auto` by default. Also accepts a model ID or `@preset/slug`. |
| `--agents` | 3 for review and audit; 25 for swarm. Choose 3–25. |
| `--budget` | Reported cost limit in USD. Default: 2. |
| `--out` | Report directory. Default: `.minirouter-review`. Writes Markdown, JSON and SARIF. |
| `--post` | Post using `GITHUB_TOKEN` and `GITHUB_REPOSITORY`. Review and swarm also need `GITHUB_PR_NUMBER`. Audits update a tracking issue. |
| `--fail-on` | `none` by default. Use `P1`, `P2` or `P3` to exit with code 1 for findings at that priority or higher. |
| `--timeout-ms` | Per-call timeout. Default: 120000 ms. |
| `--deadline-ms` | Overall review deadline. Default: 900000 ms. |
| `--base-url` | API base URL. Default: `https://api.minirouter.sh/v1`. |

## Cost and incomplete reviews

The budget stops new calls once reported cost reaches the limit. Calls already in flight can exceed it; use a [per-key spend cap](https://minirouter.sh/docs/rate-limits) as the hard limit. See requests in [Activity](https://minirouter.sh/dashboard/activity).

Timeouts, missing cost reports, exhausted credits and unrepaired model responses produce an incomplete review. Reports preserve completed work and explain the stop.

Incomplete runs exit with code 2 even with `--fail-on none`. Exit codes:

- `0` — Review completed; findings did not trigger the severity gate.
- `1` — Review completed; findings meet `--fail-on`.
- `2` — Incomplete run or error.

## Related guides

- [Automatic code review](https://minirouter.sh/docs/guides/code-review): Review pull requests with the GitHub Action.
- [Presets](https://minirouter.sh/docs/presets): Change the model from your dashboard.
