AI Code Review: What Works, What Doesn't, and How to Set It Up
How to use AI for code review effectively: what it catches, where it fails, prompts that reduce noise, CI integration and how to keep humans in the loop.
· 6 min read
Contents
- What AI reviewers catch well
- What they miss or get wrong
- Getting signal instead of noise
- 1. Tell it what to focus on
- 2. Require a failure scenario
- 3. Rank by severity
- 4. Let linters do linting
- 5. Give it project context
- Where to run AI review
- In your editor, before pushing
- In CI on every pull request
- As a self-review checklist for authors
- A team workflow that works
- Measuring whether it helps
- Pairing review with tests
- FAQ
- Can AI replace human code review?
- Is it safe to send company code to an AI review service?
- Why does the AI flag things that are not problems?
- Further reading
AI code review tools read a pull request and leave comments, much like a human reviewer. Used well, they catch real bugs before a teammate ever looks at the change and free human reviewers to focus on design. Used badly, they bury every PR in nitpicks that everyone learns to ignore.
This guide covers what AI review is actually good at, how to get useful findings instead of noise, and how to fit it into a team workflow.
What AI reviewers catch well
In practice, AI reviewers are strongest on problems visible in the diff and its immediate context:
- Logic errors: off-by-one mistakes, inverted conditions, wrong variable used, missing
await, unreachable branches. - Missing error handling: unchecked
None/null, ignored return values, exceptions swallowed silently. - Common security issues: SQL built with string concatenation, unescaped output, secrets in code, missing authorization checks on a new endpoint.
- Resource problems: files or connections not closed, queries inside loops (N+1), unbounded memory growth.
- Inconsistencies: a function renamed in one place but not another, docs or tests that no longer match the code.
- Readability: confusing names, overly complex functions, dead code.
They are also fast and tireless: every PR gets a review within minutes, including the Friday-evening ones.
What they miss or get wrong
- Business intent: the AI does not know that "free users" must never see the export button, unless that rule is written down somewhere it can read.
- System-level design: whether this feature should exist, whether it belongs in this service, how it affects other teams.
- Context outside the diff: unless the tool can explore the repository, it may not know how a changed function is used elsewhere.
- Runtime behavior: performance under real load, race conditions that depend on timing, configuration in production.
- Confidence calibration: AI reviewers can state a non-issue as confidently as a real bug. Every finding needs a human judgment.
The practical conclusion: AI review is a first pass, not an approval. Keep a human reviewer on every change that matters.
Getting signal instead of noise
The biggest complaint about AI review is noise. These practices fix most of it.
1. Tell it what to focus on
A focused prompt or configuration produces fewer, better comments:
Review this diff. Report only:
1. Correctness bugs (wrong results, crashes, data loss)
2. Security issues
3. Missing error handling at system boundaries (network, files, user input)
Ignore formatting, naming preferences and style — linters handle those.
For each finding: file and line, what goes wrong, a concrete failing scenario,
and a suggested fix. If you find nothing important, say so.
The last line matters: give the model explicit permission to find nothing, or it will invent something.
2. Require a failure scenario
Asking "what input or state makes this go wrong?" filters out vague findings. "This could be a problem" is not actionable; "if items is empty, line 42 raises IndexError" is.
3. Rank by severity
Ask for findings ordered from most to least severe, and read the top ones first. Configure the tool to post only high-severity findings as comments if it supports that.
4. Let linters do linting
Formatting, import order and simple style rules belong to deterministic tools (Prettier, ESLint, Ruff, gofmt) that run in CI. An AI reviewer that repeats them adds noise and costs tokens.
5. Give it project context
Many tools read a configuration or guidelines file from the repository. Write down the rules a new teammate would need: "all database access goes through repositories/", "money is stored as integer cents", "endpoints under /admin require require_admin". The AI can only enforce rules it can see.
Where to run AI review
In your editor, before pushing
Ask your coding assistant to review the staged diff:
git diff --staged > /tmp/change.diff
…then paste or attach it with the focused prompt above. Many assistants that work inside the repository can run the review directly. Catching issues before the PR exists is the cheapest place to fix them.
In CI on every pull request
Most AI review products and several open-source actions integrate with GitHub, GitLab or Bitbucket, posting inline comments on the PR. When setting one up:
- Run it on PR open and on new pushes, not on every commit to every branch.
- Skip generated and vendored files (lockfiles, build output, migrations generated by tools) to save cost and noise.
- Limit comment volume — a cap per PR keeps reviews readable.
- Store API keys as CI secrets, never in the workflow file. See how to use .env files safely.
- Check the data policy: make sure the provider's terms on code retention and training meet your company's requirements before sending proprietary code.
As a self-review checklist for authors
Even without tooling, authors can ask an assistant "what would a strict reviewer say about this change?" before requesting human review. It shortens review cycles noticeably.
A team workflow that works
- Author self-reviews with an AI assistant and fixes obvious problems.
- CI runs tests, linters and the AI reviewer.
- The author responds to each AI finding: fix it, or reply briefly why it does not apply. Resolving with a reason builds a record of false positives you can use to tune the configuration.
- A human reviewer focuses on design, intent, naming at the API level and anything the AI flagged as uncertain.
- Periodically review the reviewer: sample AI comments monthly. If most are dismissed, tighten the focus; if real bugs slip through, add rules to the project guidelines.
Measuring whether it helps
Track a few simple numbers before and after adoption:
| Metric | What it tells you |
|---|---|
| Share of AI findings that lead to a code change | Signal-to-noise ratio |
| Time from PR open to first review | Review latency |
| Review rounds per PR | Whether issues are caught earlier |
| Bugs found after merge | Whether quality actually improved |
If the first number is low, developers will start ignoring the tool — fix the noise before rolling it out further.
Pairing review with tests
The strongest combination is AI review plus good tests. Ask the reviewer to point out behavior the tests do not cover, then use the workflow in using AI to write unit tests to fill the gaps.
FAQ
Can AI replace human code review?
Not for changes that matter. It is an excellent first pass that catches mechanical and common mistakes, but humans are still needed for intent, design and accountability.
Is it safe to send company code to an AI review service?
It depends on the provider's terms (retention, training on your data, where it is processed) and your company's policies. Many providers offer business plans with stricter data handling — check before enabling it on private repositories.
Why does the AI flag things that are not problems?
Language models are trained to be helpful and will often find something to say. Explicit focus areas, a requirement for concrete failure scenarios and permission to report nothing reduce false positives significantly.
Further reading
Keep reading
How to Write Better Prompts for AI Coding Assistants
A practical framework for prompting AI coding assistants: give context, set constraints, ask for a plan first and verify the output. With before-and-after examples.
Using AI to Write Unit Tests: A Practical Workflow That Works
A step-by-step workflow for generating useful unit tests with AI assistants: list behaviors first, generate, run, mutate and review — with pytest examples.
How to Run a Local LLM on Your Own PC (Beginner's Guide)
Run large language models on your own computer: hardware requirements, quantization explained, setup with Ollama, using the local API from code, and realistic expectations.