AI Coding Assistants

AI Coding Assistant Code Review

Use AI coding assistants as a first-pass reviewer, not a final judge. This workflow shows how to turn pull-request diffs into structured review prompts, catch the common failure modes, and still keep human reviewers in charge.

FreeLast tested: 2026-08-24Audience: Engineering leads / senior ICs

Why AI review is a lane, not a replacement

Human code review remains the source of truth for architecture, security, and product judgment. AI coding assistants are useful for pattern-level passes: naming consistency, obvious test gaps, repeated boilerplate, and diff sprawl. The goal is to reduce reviewer fatigue, not to remove the reviewer.

The practical split is:

For a fuller workflow on structuring AI-assisted work, see AI workflow productization for team handoff. For prompt design patterns, see Prompt engineering for structured outputs.

Prompt pattern for diff review

The most reliable input is a unified diff with file context. Do not paste whole files when a diff will do. Include the issue or pull-request description, the changed files, and the success criteria for the change.

Base prompt

You are reviewing a pull request. Rules: - Do not rewrite the code. - Return findings only as a concise review comment. - Prioritize: security, correctness, performance regression, test coverage, naming. - If nothing is wrong, say "No blocking findings."

Diff input

Context: {{issue_or_pr_title}} Success criteria: {{success_criteria}} Diff: ```diff {{unified_diff_or_selected_hunks}} ```

Keep the diff short. Models degrade after a few thousand tokens of patch content. If the change is large, split it into logical hunks and review each hunk separately.

Review checklist the model can enforce

Use this checklist to build repeatable prompts or a lightweight automation step:

CheckWhat to look for
Input validationMissing null / empty checks after a new parameter or endpoint
Error path coverageNew branch has no exception or fallback handling
State mutationShared mutable state modified without locking or immutability
IdempotencyRetryable operation not safe to call twice
Logging and observabilityNew behavior has no log line or metric

These checks are language-agnostic and map well to prompt rules. They also reduce reviewer load by surfacing low-quality diffs before human attention.

Failure modes

AI coding assistants fail in predictable ways during review. Knowing them prevents false confidence:

  1. Hallucinated APIs: The model references functions that do not exist in the current codebase. Always ground review in the provided diff.
  2. Style policing instead of substance: The model bikesheds formatting while missing a logic error. Put security and correctness first in the prompt.
  3. Context blindness: The model treats a helper as a duplicate because it cannot see callers outside the diff. Add call-site snippets when the helper is new.
  4. Overly polite summaries: The model says "looks good" instead of listing findings. Require a findings list or an explicit "no blocking findings" statement.

These modes appear across assistants. Cursor, Copilot, and chat-based review tools all benefit from stricter output contracts.

Practical workflow

A repeatable review loop keeps quality high without blocking merges:

  1. Run the AI first pass on each PR diff with the base prompt above.
  2. Require findings as bullet points, not prose summaries.
  3. Have a human review only the flagged items, not the whole diff.
  4. Track recurring failure modes and add them to the prompt template.
  5. Update the checklist quarterly as the codebase and review standards evolve.

The output should be a short review comment, not a rewritten patch. Rewrites hide the reviewer's reasoning and make it harder to accept or reject a finding.

Limits and notes

This workflow works best for small to medium diffs under a few hundred lines. Large architectural changes should still receive full human review. AI review is most valuable when it catches the same class of mistake repeatedly; if the model never flags anything, tighten the prompt or sample more historical findings.