# How to run AI code review locally with Ollama.

> A step-by-step setup for reviewing your git diffs with a local Ollama model and CommitBrief: install, pull a model, configure, review, and what to tune when it is slow.

Published October 20, 2026 by CommitBrief (https://commitbrief.com)

Canonical URL: https://commitbrief.com/blog/run-ai-code-review-locally-with-ollama/
Tags: ollama, privacy, providers

---

Local AI code review is the practice of running a language model on your own machine to review a git diff, so the change never goes to a hosted API. With CommitBrief and Ollama it takes four commands, needs no API key, and costs nothing per review beyond the electricity.

> **In short:** install Ollama, pull a coder model, run `commitbrief setup --local`, then `commitbrief --staged`. The local model is weaker than a frontier cloud model, so treat the output as a first pass, not a verdict.

This is the how-to. For the argument about why a diff should stay on the machine, see [the air-gapped Ollama post](/blog/air-gapped-with-ollama). For how this setup compares with hosted reviewers, see [AI code review tools: CLI vs GitHub App vs IDE](/compare/ai-code-review-tools/).

## What you need

| Requirement | Detail |
|---|---|
| CommitBrief | Any install method in the [installation guide](/docs/1.x/installation); Homebrew is `brew install CommitBrief/tap/commitbrief`. |
| Ollama | [Installed and running](https://ollama.com/download). CommitBrief talks to its HTTP server, default `http://localhost:11434`. |
| A pulled model | At least one. The docs use `qwen2.5-coder:14b` as the example. |
| A git repo with a change | Staged, for the first run below. |

Pick the model size your hardware can serve. This post does not give timings: they depend entirely on your CPU, GPU, and model, and a number from someone else's laptop would mislead you.

## Step 1: pull a model

```sh
ollama pull qwen2.5-coder:14b
```

## Step 2: point CommitBrief at it

```sh
commitbrief setup --local
```

In the wizard, choose `ollama`. It asks for a base URL (default `http://localhost:11434`), then queries `<base_url>/api/tags` and lists the models you have pulled. Pick `qwen2.5-coder:14b`. The wizard finishes with a connection test, and a failure aborts it, so a stopped Ollama server shows up here and not on your first review.

`--local` writes the config to `<repo>/.commitbrief/config.yml` and adds the `.commitbrief/` directory to `.gitignore`. Without it the config goes to `~/.commitbrief/config.yml` and applies to every repo. The result is this:

```yaml
provider: ollama
providers:
  ollama:
    base_url: http://localhost:11434
    model: qwen2.5-coder:14b
```

You can also skip the wizard for a single run:

```sh
commitbrief --provider ollama --model qwen2.5-coder:14b --staged
```

To check connectivity without changing any state:

```sh
commitbrief providers test ollama
```

If Ollama runs on another machine, set `providers.ollama.base_url`. If `OLLAMA_HOST` is set in your environment, it always overrides `base_url`, so check your shell profile when the review goes to an unexpected host. That machine then receives your diff, so the privacy argument now depends on who controls it.

## Step 3: review a change

```sh
git add .
commitbrief --staged
```

`--staged` is the default scope, so a bare `commitbrief` does the same. The review prints as cards. Add `--json` for the structured findings, or `--fail-on=critical` to get a non-zero exit when a critical finding survives. [Review scopes](/docs/1.x/review-scopes) covers the other ranges, such as `commitbrief diff main...HEAD`.

Two properties of the Ollama provider are worth knowing:

- **No cost preflight.** Ollama reports zero pricing, so the cost check never prompts and the reported cost is `0`. Token counts are still shown. See [Safety, cost, and cache](/docs/1.x/safety-and-cost#providers-with-zero-pricing).
- **Cached re-runs.** Reviewing the same diff again with the same settings is served from the local response cache and does not call the model.

## Step 4: tune it when it is slow or noisy

**Timeouts.** Ollama's HTTP client gives up after 5 minutes. A large diff on a mid-size model can exceed that. `--timeout` raises the cap, and the value also replaces the provider's own limit:

```sh
commitbrief --staged --timeout 15m
commitbrief config set review.timeout 15m   # make it the default
```

See [Timeouts](/docs/1.x/timeouts) for the resolution order.

**Diff size.** `commitbrief dry-run --staged --verbose` runs the same pipeline without a provider call and reports estimated tokens. Use it to see whether a diff is near your model's context window before you wait on it. If it is, review a smaller range.

**Rules.** `commitbrief init` writes a `COMMITBRIEF.md` that is sent as the system prompt. The rules apply to local models like any other provider. See [Review rules](/docs/1.x/review-rules).

## What this setup does not give you

A local 14B-class model is not a frontier cloud model, and a review from one is not equivalent. Smaller models can fail to return valid JSON. CommitBrief retries once and then degrades to plain markdown. When that happens `--fail-on` is skipped by design, because failing CI on a flaky model invocation is worse than showing you the text. If you gate a pipeline on a local model, watch for the `--fail-on skipped` line on stderr. The [troubleshooting page](/docs/1.x/troubleshooting) lists the probable causes and fixes.

Intent-level problems, such as a function that answers the wrong question, remain a human reviewer's job with any model.

## One action

Run `commitbrief providers test ollama` now. If it passes, stage your next change and run `commitbrief --staged` before you commit.