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.
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, thencommitbrief --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. For how this setup compares with hosted reviewers, see AI code review tools: CLI vs GitHub App vs IDE.
What you need
| Requirement | Detail |
|---|---|
| CommitBrief | Any install method in the installation guide; Homebrew is brew install CommitBrief/tap/commitbrief. |
| Ollama | Installed and running. 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
ollama pull qwen2.5-coder:14b
Step 2: point CommitBrief at it
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:
provider: ollama
providers:
ollama:
base_url: http://localhost:11434
model: qwen2.5-coder:14b
You can also skip the wizard for a single run:
commitbrief --provider ollama --model qwen2.5-coder:14b --staged
To check connectivity without changing any state:
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
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 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. - 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:
commitbrief --staged --timeout 15m
commitbrief config set review.timeout 15m # make it the default
See 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.
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 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.
Related reading
- Aug 4, 2026Your diff should never leave your machine: the Ollama path for air-gapped repos.
How CommitBrief runs LLM code review with zero network egress. For SOC2-restricted repos, defense work, fintech and healthcare codebases — and an honest look at the quality trade-off.
- Sep 25, 2026The v1.18.0 provider catalog: ten providers, three new model families, and defaults chosen by list price, not benchmark.
v1.18.0 adds Claude Opus 5.5 / Sonnet 5 / Fable 5.1, gpt-6-astra/sol/luna, and gemini-3.8-flash / 3.5-flash-lite, changes two provider defaults, and makes the setup wizard show list price instead of a quality claim it can't back.
- Sep 13, 2026When the model won't return valid JSON: a recovery ladder, not a blind retry.
Prompt-only models break the JSON contract in three predictable ways — fenced JSON, prose, and truncation. How CommitBrief v1.13.0 recovers each one with fence salvage, a failure-mode-specific repair prompt, and a graceful degrade.