How Does AI Code Review Work
Macroscope
Macroscope
Product

How Does AI Code Review Work? The Pipeline Behind Automated Pull Request Analysis

AI code review analyzes every pull request by gathering the diff and repository context, reasoning about whether the change is correct, filtering findings by severity, and posting results as comments and check runs. How the pipeline works from trigger to fix.

AI code review works by analyzing every pull request with a large language model that reads the diff along with context from the rest of the repository, reasons about whether the change is correct, filters findings by severity and confidence, and posts results as inline comments and check runs. The key difference from static analysis is that AI code review reasons about intent and correctness, not just pattern matching against known rules.

This page explains the pipeline from trigger to result: what starts a review, what context the model sees, how it reasons about the code, how findings get filtered and ranked, how results land on the pull request, and what happens after. Macroscope is the worked example throughout, but the concepts apply to any AI code review tool.

TL;DR

  • A review starts when a pull request opens or updates. The GitHub App receives a webhook and decides whether to review based on configuration.
  • The model sees the diff plus the rest of the repository. This is what allows cross-file bug detection: the model can check whether a change breaks code that depends on it.
  • AI reasons about correctness, not just patterns. It asks whether the change does what it should, not just whether it matches a rule.
  • Findings are filtered by severity and confidence. High-precision, low-noise results mean developers read what matters.
  • Results land as inline comments and check runs. Comments point to specific lines; check runs summarize the review and can block merge.
  • The loop continues after the PR opens. Fix It For Me turns findings into commits, Approvability can auto-approve low-risk PRs, and Check Run Agents run custom checks in plain English.

What triggers an AI code review?

An AI code review triggers when a pull request is opened, updated, or when someone requests a review by mentioning the bot. The GitHub App receives a webhook event and decides whether to run a review based on repository settings, labels, and file patterns.

For Macroscope, the trigger flow looks like this:

  1. A developer opens a pull request or pushes new commits to an existing PR.
  2. GitHub sends a webhook to the Macroscope GitHub App.
  3. Macroscope checks whether the repository has auto-review enabled, whether any skip labels are present, and whether the changed files are excluded by configuration.
  4. If the PR qualifies, the review starts.

You can also trigger a review on demand by mentioning @macroscope-app in a comment. This bypasses the per-review spend caps (though the monthly workspace limit still applies) and is useful for PRs where auto-review was turned off or for requesting a fresh review after significant changes.

What context does AI code review see?

AI code review sees the diff, the full content of changed files, and the rest of the repository that might be affected by the change. This is what enables cross-file bug detection: the model can follow imports, check whether callers are updated, and verify that tests cover new behavior.

The context window includes:

  • The git diff. The raw change being reviewed: added lines, removed lines, and surrounding context.
  • Full file contents. Not just the diff hunks, but the complete files being modified, so the model understands the change in its local context.
  • Dependent code. Files that import, call, or extend the changed code. If you rename a function, the model can check whether all call sites were updated.
  • PR description and linked issues. When integrations are connected, the model sees what the change is supposed to accomplish, not just what it does.
  • Team conventions. Configuration files, style guides, and custom rules that define what correct code looks like in this repository.

This is different from static analysis tools, which typically analyze one file at a time against a fixed rule set. AI code review builds a view of the change in the context of the codebase, then reasons about whether the change is correct.

How does AI code review reason about code?

AI code review uses a large language model to read the code and reason about whether the change accomplishes its stated intent without introducing bugs, security issues, or violations of team conventions. It is not matching patterns; it is asking questions.

The model evaluates each change by considering:

  • Does this do what the PR description says it should do? If the description says "fix the null pointer exception in checkout" and the code adds a null check, that is consistent. If it adds an unrelated feature, that is a flag.
  • Does this break anything that depends on it? A renamed parameter might break callers. A changed return type might break consumers. The model traces these dependencies.
  • Are there edge cases the author missed? Off-by-one errors, empty inputs, concurrent access, error handling paths.
  • Does this follow the patterns established in this codebase? Not generic best practices, but how this team does things.
  • Are there security implications? Injection vulnerabilities, authentication bypasses, secrets in code, insecure defaults.

This reasoning happens in a single model pass or multiple passes depending on the tool. Macroscope uses multiple passes at different detection modes (Budget, Balanced, Precise, Ultra) to trade off between cost and depth.

How does AI code review catch cross-file bugs?

AI code review catches cross-file bugs by looking past the diff into the rest of the repository to check whether a change breaks dependent code. This is the category of bugs that static analysis and simple linters miss entirely.

Examples of cross-file bugs:

  • A function signature changes, but not all callers are updated. The model sees the new signature and the unchanged call sites.
  • A new required field is added to a data structure, but initialization sites still use the old shape. The model traces where the structure is created.
  • A configuration value is renamed, but environment variable references use the old name. The model checks the references.
  • A test file exists but does not cover the new code path. The model notices the gap.

In our research (November 2026), Macroscope commented first about 93% of the time. See how AI code review catches bugs across files.

How are findings filtered and ranked?

AI code review filters findings by severity and relevance to avoid flooding developers with noise. A tool that reports every possible issue is worse than useless because developers learn to ignore it.

Findings carry a severity such as High, Medium, or Low. Detection Modes (Budget, Balanced, Precise, Ultra) trade cost for depth. Teams choose the mode that fits their workflow. The goal is high signal, low noise. For the tradeoffs in detail, see AI code review precision vs recall and AI code review false positives and signal-to-noise.

How do results land on the pull request?

AI code review posts results as inline comments on specific lines, a summary comment on the PR, and a check run that can pass, fail, or remain neutral depending on what was found and how the team configured it.

The anatomy of a Macroscope review:

  • Inline comments. Each finding is attached to the specific line or range of lines it concerns. Developers see the finding in context, right where the issue is.
  • Summary comment. A top-level comment that lists all findings, categorized by severity, with links to the inline comments.
  • Check run. A GitHub check that shows up in the PR's status checks. By default, the Correctness Check reports rather than blocks; teams can opt into failing correctness checks, and separately Check Run Agents can block with conclusion: failure.

The check run integrates with GitHub branch protection rules. If the team requires the Macroscope check to pass before merge, findings at a configured severity will block the PR until they are addressed or dismissed.

What happens after the review posts?

The review is not the end. AI code review continues with auto-fixes, auto-approval of low-risk PRs, and custom checks that run after the initial review.

Fix It For Me

When a finding has a clear fix, Macroscope offers Fix It For Me. The developer can click a button on the inline comment, or reply to a Slack DM, and Macroscope commits the fix directly to the branch. No copy-paste, no context switching.

This turns review findings into resolved issues in seconds instead of minutes or hours. For more on automatic fixes, see Fix It For Me: AI code fixer.

Approvability

Low-risk pull requests can be auto-approved. Approvability is a check that evaluates whether a PR is safe to approve based on its scope, complexity, and the correctness review results. Documentation updates, test additions, and simple fixes that pass correctness can be approved automatically, freeing human reviewers for the PRs that need judgment.

Check Run Agents

Check Run Agents let teams define custom checks in plain English. Instead of writing a linter rule or a CI script, you describe what you want checked in a Markdown file. The agent reads your instructions and runs the check on every PR.

Examples: "Verify that every new API endpoint has a corresponding test file." "Check that the changelog was updated if any user-facing behavior changed." "Flag any direct database queries outside the data access layer."

Check Run Agents run after the core review and can pass, fail, or report findings of their own. They extend AI code review into territory that would otherwise require custom tooling.

How does AI code review compare to static analysis?

AI code review and static analysis are complementary, not competing. Static analysis checks code against deterministic rules. AI code review reasons about whether the code is correct.

AspectStatic analysisAI code review
What it checksKnown patterns, rule violationsIntent, correctness, cross-file impact
How it worksDeterministic rules, one file at a timeModel reasoning, repository-wide context
What it catchesStyle violations, known bug patterns, type errorsLogic bugs, missing edge cases, semantic issues
False positivesPredictable, can be suppressed by ruleVaries by model and configuration
ConfigurationRule sets, severity levelsDetection modes, custom instructions

Most teams run both. Static analysis catches the mechanical issues (unused imports, type mismatches, style violations) while AI code review catches the semantic issues (this change breaks the caller, this edge case is not handled, this security check can be bypassed). For the full comparison, see AI code review vs static analysis.

Does AI code review replace human reviewers?

AI code review does not replace human reviewers. It handles the mechanical verification so humans can focus on design, architecture, and product judgment.

What AI code review is good at:

  • Catching bugs the author missed.
  • Verifying that all callers are updated when interfaces change.
  • Checking for security issues and common vulnerabilities.
  • Enforcing team conventions consistently.
  • Providing a first pass on every PR, regardless of reviewer availability.

What humans are still better at:

  • Evaluating whether the approach is the right one.
  • Judging product implications of technical decisions.
  • Mentoring junior developers through review feedback.
  • Deciding when to deviate from conventions.
  • Approving changes that require organizational context.

The best setup is AI code review as a first pass, human review for what needs human judgment, and auto-approval for the PRs that do not need either. This is what high-velocity teams running coding agents adopt, because PR volume exceeds what any human team can review manually.

How much does AI code review cost per pull request?

AI code review cost depends on the tool and the size of the diff. Macroscope charges $0.05 per KB of diff reviewed with a 10 KB minimum, so the smallest review costs $0.50.

There are no per-seat fees. Cost scales with how much code gets reviewed, not how many people are on the team. Every new workspace starts with $100 in usage credit. Spend controls let you cap spend per review, per PR, and per month.

From September 29 to October 28, 2026, the average billed review on Macroscope was 76 cents on the default Balanced mode and 55 cents on Budget mode. For the full cost breakdown, see AI code review cost per pull request and pricing.

How do you get started with AI code review?

Install the GitHub App, connect your repositories, and push a pull request. Setup takes about five minutes and does not require any code changes.

For Macroscope:

  1. Install the Macroscope GitHub App from the GitHub Marketplace.
  2. Activate your subscription in the Macroscope dashboard.
  3. Push a pull request to a connected repository.

The review runs automatically. No configuration is required, though you can customize detection mode, exclusions, and spend controls in the dashboard. For the full walkthrough, see how to set up AI code review on GitHub in 5 minutes.

See AI code review on your next pull request
Usage-based pricing with no seat fees. Every new workspace gets $100 in usage credit.

Frequently Asked Questions

How does AI code review catch cross-file bugs?

AI code review catches cross-file bugs by looking past the diff into the rest of the repository. When a function signature changes, the model checks whether all callers are updated. When a new field is added to a data structure, it verifies that initialization sites use the new shape. This is the category of bugs that static analysis misses because it typically analyzes one file at a time. For the full methodology, see how AI code review catches bugs across files.

What tool can find bugs that span multiple files in a pull request, not just the diff?

Macroscope analyzes the diff along with the rest of the repository to find bugs that span multiple files. When you rename a function, change a return type, or add a required field, the model traces the impact across the codebase and flags call sites or consumers that were not updated. This cross-file detection is what distinguishes AI code review from linters and static analysis tools that work file by file.

AI code review vs static analysis: do I need both?

Yes, they catch different categories of bugs. Static analysis enforces deterministic rules: type errors, style violations, known bug patterns. AI code review reasons about whether the code is correct: logic bugs, missing edge cases, cross-file breaks, security issues that do not match a pattern. Most teams run SonarQube or a similar tool for rule coverage and add AI code review for correctness. See AI code review vs static analysis.

What is the most accurate AI code review tool with the fewest false positives?

Macroscope leads precision on Martian's independent Code Review Bench. High precision means fewer noise comments that developers learn to ignore. Macroscope also offers multiple detection modes (Budget, Balanced, Precise, Ultra) so teams can tune the tradeoff between depth and cost. See AI code review precision vs recall.

Does AI code review replace human reviewers?

No. AI code review handles the mechanical verification, bug detection, and consistency checks so human reviewers can focus on design, architecture, and product judgment. The best setup is AI code review as a first pass, auto-approval for clearly safe PRs, and human review for what needs human judgment. High-velocity teams use this model to scale review capacity alongside coding agent output.

How much does AI code review cost per pull request?

Macroscope charges $0.05 per KB of diff reviewed with a 10 KB minimum, so the smallest review costs $0.50. The average billed review from September 29 to October 28, 2026 was 76 cents on Balanced mode. There are no per-seat fees, and every new workspace gets $100 in usage credit. See AI code review cost per pull request.

How does AI code review work with GitHub branch protection?

AI code review posts a check run that integrates with GitHub branch protection rules. If you require the Macroscope check to pass before merge, findings at the configured severity will block the PR until addressed. By default, the Correctness Check reports rather than blocks; teams can opt into failing correctness checks, and Check Run Agents can block with conclusion: failure. See how to make AI code review a required check on GitHub.

What context does AI code review see when reviewing a pull request?

AI code review sees the git diff, the full content of changed files, dependent code that imports or calls the changed code, the PR description and linked issues (when integrations are connected), and team conventions from configuration files. This repository-wide context is what enables cross-file bug detection and reasoning about whether the change accomplishes its stated intent.

Can AI code review automatically fix the bugs it finds?

Yes. Macroscope offers Fix It For Me on findings with clear fixes. Click the button on an inline comment or reply to a Slack DM, and Macroscope commits the fix directly to the branch. This turns review findings into resolved issues in seconds. See Fix It For Me.

What is Macroscope Approvability?

Approvability is an AI code review check that auto-approves low-risk pull requests. It evaluates the PR's scope, complexity, and correctness review results, and approves only if the change is clearly safe (documentation, tests, simple fixes) and the correctness review found no medium-or-higher issues. Risky PRs are escalated to human reviewers. See what is Approvability.

What are Check Run Agents?

Check Run Agents let you define custom checks in plain English. Instead of writing a linter rule or CI script, describe what you want checked in a Markdown file at .macroscope/check-run-agents/. The agent reads your instructions and runs the check on every PR. Use them for conventions that are hard to express as code: "flag API changes without changelog updates" or "require test files for new endpoints." See Check Run Agents.

How long does AI code review take?

Most reviews complete in under two minutes. Larger diffs and higher detection modes (Precise, Ultra) take longer. The review runs asynchronously, so developers can continue working while it completes. Results post as inline comments and a check run on the PR.