# AI code review workflow: what AI checks and what engineers decide

URL: https://pixelactstudio.com/blog/ai-code-review-workflow

> An AI code review workflow where engineers approve: what AI catches and misses, eight steps, guardrails for secrets and permissions, and how to measure it.

By Dev Talan. Published 2026-11-01. Updated 2026-11-01. Type: AI workflow.

## Key takeaways

- Start the AI review only after types, lint, tests, a secret scanner, and a dependency audit pass, so the model doesn't spend comments on problems a tool already reported.
- Have the author fix or dismiss every AI comment with a one-line reason. Those answers are the data you use to judge the AI step a month later.
- Give the review bot `contents: read` and `pull-requests: write` and nothing more, leave Copilot approvals off, and put the review instructions and sensitive paths under `CODEOWNERS`.
- Build the model's input from the branch diff with environment files, private keys, and fixtures excluded, and run the secret scanner on that same diff first.
- After four to six weeks, compare against a month of baseline. Switch off comment categories your team rarely acts on, and if human comments fall while escaped defects rise, the team is approving on the model's word.

An AI code review workflow is a pull request process where a model drafts the first round of review comments and an engineer reads the diff and decides what merges. AI is good at pattern checks, missing tests, and obvious bugs. It misses business rules, architecture, and security context, so human approval stays required.

This guide is for CTOs and engineering leads whose team now writes code with AI tools faster than reviewers can read it. More code each week means more pull requests per reviewer, and the easy response, approving faster, is where defects slip through. Below: what to hand to the AI, what to keep for people, the workflow step by step, the guardrails, and how to tell after a month whether it helps. If much of your codebase was drafted with AI tools before review was in place, start with [the risks of AI-generated code in production](https://pixelactstudio.com/blog/ai-generated-code-risks), because review guards new changes and does nothing for code that already merged.

## What is AI good at in a code review?

AI is good at problems it can judge from the diff and a few nearby files. It gives the ninth pull request of the day the same pass as the first, which a tired reviewer can't promise. Use it to take the first, mechanical pass off a human's plate.

- **Pattern checks.** SQL built by string concatenation, a missing `await`, an error swallowed by an empty `catch`, a list query with no `limit`, an access token written to a log line.
- **Missing tests.** Behavior that changed with no test changed beside it, or a new branch in the code that no test case reaches.
- **Obvious bugs.** Inverted conditions, off-by-one ranges, an unhandled `null`, and copy-paste slips between two similar handlers.
- **Inconsistency.** A new endpoint that skips the input validation every other endpoint uses, or a second date library added next to the first.
- **Description drift.** The pull request description says one thing and the diff does another.

Deterministic tools do part of this job better. The type checker, ESLint, Semgrep rules, and a secret scanner give the same answer on every run, so run them first. The model is most useful on what a rule can't express, such as a test that asserts nothing or an error message that leaks an internal ID.

## What does AI code review miss?

AI code review misses anything that depends on knowledge outside the diff: the business rule the code is meant to implement, the reasons behind the architecture, and which data your company treats as sensitive. A model checks the code against what it was told, and most of that knowledge was never written where it can read it.

**What AI review tends to miss, and who should catch it instead**

| Area | What AI review tends to miss | Why it misses it | Who catches it |
| --- | --- | --- | --- |
| Business logic | A discount applied before tax when the contract says after, or a trial that ends a day early | The rule lives in a spec, a contract, or someone's head | The engineer who knows the feature, with the ticket open |
| Architecture | A module reading another module's tables, or a slow call made inside a web request instead of a background job | The reasons live in decision records and past discussions it never sees | The project lead |
| Security context | An endpoint that checks the user is signed in but not that the record belongs to their organization, or a field your company treats as personal data written to logs | Who may see what is a company rule, and the diff doesn't state it | A reviewer who knows the access rules, plus a security pass on sensitive paths |
| Release risk | A migration that runs in seconds on a test database and locks a large production table for minutes | It can't see production table sizes, traffic, or the deploy order | The engineer who owns releases |
| Product intent | A change that works and solves the wrong problem | It reviews the code and never sees why the change was made | Whoever owns the ticket |

> **A clean AI review is not a security review.** A wrong AI comment costs a minute to dismiss. The expensive failure is silence: a pull request the model passes because the flaw sits in a rule it was never given. Read “no findings” as “no pattern problems found”. Approval still comes from a person.

You can narrow the gap by giving the reviewer context: a review instructions file, the linked ticket, and the repository's [architecture decision records](https://pixelactstudio.com/blog/architecture-decision-records). You can't close it, because the rules that matter most change faster than anyone documents them.

## How does an AI code review workflow work, step by step?

The workflow runs cheap, certain checks first, then the AI draft, then the human decision, and it records what happened to each AI comment so you can measure the result. An AI pull request review posts comments like any other reviewer, and it never approves.

1. **Keep the pull request small.** One change, with a description of what changed, why, and how it was tested. Both the model and the person review a focused diff better than a sprawling one, and a small diff makes a missed issue easier to trace later.
2. **The author runs an AI self-review first.** Before opening the pull request, the author asks a model to review the local diff and fixes what is real. The obvious comments get handled privately, and the shared review starts cleaner.
3. **CI runs the deterministic checks.** Types, lint, tests, a secret scanner, and a dependency audit run on every push. Start the AI review only once these pass, so it doesn't spend comments on problems a tool already reported.
4. **The AI drafts review comments.** It reads the diff, the repository's review instructions, and the linked ticket. Each comment carries a label (blocking, question, or suggestion) and a file and line. The tool posts comments only.
5. **The author answers every AI comment.** Fix it, or dismiss it with a one-line reason such as “intended, see ADR 0007”. Those answers become your measurement data.
6. **An engineer reviews the full diff.** The human reviewer reads every line and uses the AI comments as a starting list. Their time goes to the business rule, the design, and the data, and they approve or request changes.
7. **Sensitive paths get a named owner.** Changes to sign-in, permissions, billing, tenant data, and migrations need approval from a code owner and get a separate security pass before merge.
8. **Merge, release, and record.** Merge only with a passing CI run and a human approval. Record the AI comments raised, fixed, and dismissed, and link any later bug or revert back to its pull request.

### What should the AI reviewer be told?

Write the review rules into a file in the repository, so the model and new engineers read the same ones. GitHub Copilot code review, for example, reads `.github/copilot-instructions.md` and a root `AGENTS.md`. Tell the reviewer what to flag, what to ignore, and how to format comments. The ignore list does as much to cut noise as the flag list.

```markdown
## Code review

Review the diff against the linked ticket and the decision records in docs/adr.

Flag as blocking:
- API routes or queries not scoped to the organization in the session
- changed behavior with no test added or changed
- secrets, tokens, or personal data in code, config, or log lines
- list queries without a limit
- migrations that drop or rename a column or table

Do not comment on formatting, import order, or naming. CI runs Prettier and ESLint.

Label every comment blocking, question, or suggestion, and cite the file and line.
If you find nothing, say so in one line.
```

## What guardrails does human-in-the-loop code review need?

Human-in-the-loop code review needs four guardrails: keep secrets and customer data out of what the model reads, make a human approval the only approval that counts, protect the reviewer's own instructions, and treat the diff as untrusted input by giving the review bot the narrowest permissions that work.

### Keep secrets and customer data out of prompts

When you run the review job yourself, send the model the diff, not the working directory, and leave out the files that hold secrets or real data. Run the secret scanner on the same diff before anything leaves CI. If a live key reaches a prompt anyway, rotate it at the provider, as our [guide to exposed API keys](https://pixelactstudio.com/blog/exposed-api-keys) explains. Also confirm in writing what your AI provider stores, for how long, and whether it trains on your code under the plan you pay for.

```bash
git fetch origin main
git diff --unified=5 origin/main...HEAD -- . \
  ':(exclude,glob)**/.env*' \
  ':(exclude,glob)**/*.pem' \
  ':(exclude,glob)**/fixtures/**' \
  > review.diff
```

### Make human approval the only approval

Protect the main branch: require a pull request, a passing CI run, and at least one approving review from a person, and dismiss stale approvals when new commits arrive. [GitHub's documentation for Copilot code review](https://docs.github.com/en/copilot/concepts/agents/code-review) states that Copilot's reviews do not count toward required approvals by default, and that Copilot approvals can be turned on in repository, organization, and enterprise settings. Leave that setting off. Whatever tool you use, its output is a comment.

### Protect the reviewer's instructions

The same GitHub page notes that Copilot reads custom instructions from the pull request's head branch, which means a pull request can change the instructions used to review it. Put instruction files, CI configuration, and sensitive paths under `CODEOWNERS`, and turn on required code owner review.

```text
/.github/              @acme/leads
/AGENTS.md             @acme/leads
/db/migrations/        @acme/leads
/src/server/auth/      @acme/security-reviewers
/src/server/billing/   @acme/billing-owners
```

### Treat the diff as untrusted input

Text inside a pull request, such as a code comment, a test string, or a vendored README, can tell the model to approve or to stay quiet. The [OWASP Top 10 for LLM applications](https://genai.owasp.org/llmrisk/llm01-prompt-injection/) calls this indirect prompt injection, under LLM01:2025 Prompt Injection, and recommends restricting the model to the minimum privileges its task needs. Give the review bot a token that can read code and post comments, and nothing else: no merge rights, no branch writes, no deploy secrets. In a GitHub Actions job, that means `contents: read` and `pull-requests: write`, with the repository setting that lets Actions create and approve pull requests left off. Don't run AI review on the `pull_request_target` event with a checkout of the pull request's code, because that puts untrusted code next to your repository's secrets.

## How do you measure whether AI code review helps?

Measure three things against a baseline: whether AI comments lead to changes, whether defects still reach production, and whether human review stayed real. Record the baseline for a month before you turn AI review on, or pull the same numbers from last quarter's pull requests, then compare after four to six weeks. Time to merge and the kinds of issues humans still catch show where to tune it.

**Metrics for an AI code review workflow**

| Metric | How to measure it | What a bad trend means |
| --- | --- | --- |
| Action rate | AI comments the author fixed, divided by all AI comments | Most comments are noise, and people will stop reading them |
| Escaped defects | Bugs, reverts, and hotfixes after merge, traced to their pull request | Approvals got faster without reviews getting better |
| Human review depth | Human comments per pull request, and approvals with no human comment | The AI review is quietly replacing the human one |
| Time to merge | Hours from pull request opened to first human review and to merge | The AI step adds a wait without removing work |
| What humans still catch | Human comments tagged as pattern issues or context issues | Pattern issues still reaching humans belong in the instructions or a lint rule |

Google's static analysis team published a useful bar. In [Lessons from Building Static Analysis Tools at Google](https://research.google/pubs/lessons-from-building-static-analysis-tools-at-google/), published in Communications of the ACM in 2018, the authors write that analysis results shown during code review may include up to 10% effective false positives, where an effective false positive is a finding developers took no positive action on. In the terms of the table above, that is an action rate of at least 90%. An AI reviewer is a looser check than a static analyzer and may not reach that bar overall, so apply it per comment category: keep the categories your team acts on and switch off the rest.

- **Action rate falls month over month.** Read the dismissed comments and add the patterns behind them to the ignore list in the review instructions.
- **Human comments fall while escaped defects rise.** The team is approving on the model's word. Restate the rule that a person reads the full diff, and check that [releases can be rolled back](https://pixelactstudio.com/blog/safe-releases-and-rollbacks) while you fix it.
- **Time to merge rises with no drop in escaped defects.** The AI step costs more than it returns. Limit it to riskier paths or turn it off.

## What should you do next?

Set the rules before you pick a tool: protect the main branch, require one human approval, put the review instructions and sensitive paths under code owners, and record what happens to every AI comment for a month.

If your product was built quickly with AI tools and review is arriving after the fact, work through the [AI-built app risk checklist](https://pixelactstudio.com/resources/ai-built-app-risk-checklist) for the code already merged. For an outside view of the code and the review workflow together, a [software audit](https://pixelactstudio.com/services/software-audits) covers both in about 3 to 5 days and ends in a written report that ranks the risks and what to fix first.

## Frequently asked questions

### Can a team with one engineer use this workflow?

Yes, with one change. GitHub doesn't let authors approve their own pull requests, so a solo engineer can't meet a required approval alone. Keep the CI checks and the AI draft, then reread the diff after a break as if someone else wrote it. For sign-in, permissions, billing, and migrations, get a second person to approve, such as an advisor, a fractional CTO, or an outside reviewer.

### Should the AI reviewer use a different model from the one that wrote the code?

It can help. A model reviewing code it drafted can share the assumptions it made while writing, and a different model or a review-specific prompt sometimes catches what the first one skipped. Neither fixes the larger gap, which is missing business and security context. Choose the reviewer by its action rate on your own pull requests. Which model wrote the code matters less.

### Is it safe to send our code to an AI review provider?

It depends on the provider's terms and your settings. Get in writing whether the plan you pay for keeps code, for how long, where it is processed, and whether the provider trains on it. Then limit what you send: build the input with the `git diff` command in the guardrails section, which leaves out `.env` files, `.pem` keys, and fixtures, and run the secret scanner on that diff first. Ask customers or partners before you send code or data that belongs to them.

### Which AI code review tool should we choose?

Choose after the rules are in place, because every tool works within them. Look for one that reads instructions from your repository, posts comments without approving, needs only permission to read code and post comments, can skip or focus on specific paths, and has data terms you can accept. Then run it on real pull requests for a month and compare action rates, rather than judging it on a demo repository.

### Should AI review comments ever block a merge?

Usually not on their own. Blocking belongs to deterministic CI checks, which give the same answer every run, and to human reviewers, who can explain a decision. An AI comment becomes blocking when a human reviewer agrees with it and requests changes. A bot that can block merges on findings that are sometimes wrong teaches the team to work around it.

### How does this work when an AI coding agent opens the pull request?

The same workflow applies, with one addition. The person who assigned the task acts as the author: they read the diff, answer the AI review comments, and must be able to explain every line. A different engineer then gives the approval, and GitHub enforces this for Copilot: whoever assigned it to the issue can't approve the pull request it raises. A named person stays accountable for everything the agent wrote.