Agentic & generative AI

Reviewing AI-written code: a review pipeline for teams using Cursor, Claude Code and Copilot

Saket ShuklaSaket Shukla11 min read

The short answer

Review AI-written code with a pipeline, not a single reviewer. Put deterministic checks first (tests, static analysis, secret and dependency scanning), add an AI reviewer such as Copilot code review, Cursor Bugbot or Claude Code’s security review to widen coverage, and reserve human attention for the changes that carry risk: authentication, data access, payments, infrastructure and anything the author cannot explain. AI reviewers catch more than they used to, but none of them should be the gate that decides a merge.

Teams using Cursor, Claude Code and GitHub Copilot now produce more code than their reviewers can read line by line. The answer is not to read faster. It is to design review so that machines check what machines check well, and people spend their time where judgement matters. This guide sets out that pipeline, the tools that fit each stage, and a workflow file you can copy.

Three rules for reviewing AI-written code

  1. Automate the objective checks. Every pull request passes tests, static application security testing (SAST), secret scanning and dependency review before a person looks at it.
  2. Treat AI reviewers as a second opinion, not an approver. They leave comments; a named human still approves.
  3. Review by risk, not by line count. A change to login or billing gets a deep review; a copy change gets a glance.

Why AI-written code needs a different review

By the numbers

  • 1.7× as many issues per pull request in AI-co-authored code (10.83 versus 6.45) across 470 open-source pull requests, with logic and correctness issues 75% more common and security issues up to 2.74× higher (CodeRabbit, December 2025).
  • 38% of AI coding tasks still produced code with a security flaw in Veracode’s October 2026 testing (Veracode).
  • 205,474 unique fake package names invented by 16 code-generating models across 576,000 samples; at least 5.2% of suggested packages from commercial models and 21.7% from open-source models did not exist (USENIX Security 2025).
  • ~2× the baseline rate of leaked secrets in AI-assisted commits during 2025 (GitGuardian).
  • 46% of developers distrust the accuracy of AI tools, up from 31% a year earlier (Stack Overflow, 2025).

The numbers point to a specific shift, not a general decline in quality. AI-written code tends to look clean: consistent formatting, plausible names, confident comments. That polish is the problem. Reviewers relax when code reads well, and the defects that remain are the ones that need context to spot: a missing authorisation check, an edge case the prompt never mentioned, a dependency that does not exist. Fake package names create a new supply-chain risk known as slopsquatting: an attacker registers a name that models tend to invent, and waits for someone to install it.

Volume compounds the issue. Google’s 2024 DORA report associated a 25% increase in AI adoption with an estimated 7.2% fall in delivery stability, even as code review speed rose 3.1%. Faster review of more code is not the same as better review.

What AI-written code gets wrong, and what catches it

Each failure mode has a cheapest reliable check. The table maps the common ones to the stage of the pipeline that should catch them.

Failure modeWhat it looks likeCheapest reliable check
Invented or risky dependenciesAn import of a package that does not exist, or a little-known package with a near-miss name.Dependency review in CI and an allowlist or registry proxy for new packages.
Missing authorisationAn endpoint that checks the user is logged in but not that they own the record. CodeRabbit lists insecure object references among the top AI security patterns.Human review of every change to data access, plus tests that try another user’s ID.
Logic and edge casesCorrect for the example in the prompt; wrong for empty lists, time zones, retries or concurrent requests.Tests written from the requirement, not from the implementation; AI reviewer comments.
Secrets in codeAPI keys pasted into configuration or test files by the assistant or the developer.Secret scanning with push protection.
Known vulnerability patternsInjection, cross-site scripting, unsafe deserialisation, weak password handling.SAST such as CodeQL or Semgrep, plus an AI security reviewer.
Oversized, sprawling changesOne prompt touches twenty files, including some nobody asked it to change.A pull-request size limit and a rule that each change has one purpose.
Tests that prove nothingGenerated tests that assert whatever the code currently does, or mock away the logic under test.Human review of tests for critical paths; mutation testing where it matters.

The five-gate review pipeline

Think of review as a series of gates, each cheaper and more objective than the next. A change should fail fast at the earliest gate that can catch its problem, so human reviewers only see code that has already passed the mechanical checks.

Five-gate review pipeline for AI-written codeFive gates in sequence: 1 author self-check, 2 automated checks in CI, 3 AI reviewer, 4 human review by risk, 5 safe release and monitoring. GATE 1AuthorRules filesLocal testsSelf-reviewSmall PR GATE 2AutomatedTests, types, lintSASTSecretsDependencies GATE 3AI reviewerCopilot reviewCursor BugbotClaude securityComments only GATE 4HumanDepth by riskCode ownersApproves mergeOwns outcome GATE 5ReleaseStagingFeature flagsMonitoringRollback CHEAP AND OBJECTIVE → EXPENSIVE AND JUDGEMENT-BASED
Each gate filters what the next one has to look at. Only gate 4 approves a merge.
  1. Author self-check. The developer who prompted the code owns it. Shared rules files (.cursor/rules, CLAUDE.md, AGENTS.md, .github/copilot-instructions.md) set the standards the assistant follows. Before opening a pull request, the author runs the tests, reads the diff and can explain every line. Claude Code users can run /security-review on pending changes from the terminal (Anthropic).
  2. Automated checks in CI. Tests, type checks, linting, SAST, dependency review and secret scanning run on every pull request and block the merge if they fail. These are deterministic: the same code gets the same answer every time.
  3. AI reviewer. An AI reviewer reads the diff in context and comments on logic, security and readability. It finds things rule-based tools cannot express, but its output varies from run to run, so it informs the human reviewer rather than deciding.
  4. Human review by risk. A named reviewer approves, with depth set by what the change touches (see the risk tiers below). Code owners route sensitive paths to the people who know them.
  5. Safe release. Staging, feature flags, monitoring and a tested rollback limit the damage of whatever the first four gates missed.

Choosing an AI reviewer: Copilot, Bugbot or Claude Code

All three reviewers read pull-request diffs and leave comments. They differ in where they run, how you steer them and how they interact with merge rules.

GitHub Copilot code reviewCursor BugbotClaude Code security review
FocusGeneral review: bugs, readability, suggested changesBugs and logic errors in the diffSecurity: injection, cross-site scripting, authentication and authorisation flaws, insecure data handling, dependency issues
How it runsRequested on a pull request, or set to review all pull requests automaticallyAutomatically on each pull-request update, or on demand by commenting cursor review/security-review in the terminal, or a GitHub Action on every pull request
How you steer it.github/copilot-instructions.md and path-specific instruction files.cursor/BUGBOT.md files; Cursor’s editor rules do not apply to BugbotCustom filtering rules in the Action to cut false positives
Effect on mergingBy default it leaves a “Comment” review that does not count toward required approvalsIts check reports neutral by default, so it does not block merges on its ownPosts comments; blocking depends on how you configure the workflow
Watch out forIt may repeat comments you have dismissedBilling is usage-based; check your planNot hardened against prompt injection: run it only on trusted pull requests
DocsGitHub DocsCursor DocsGitHub repository

A practical combination for most teams: one general reviewer (Copilot or Bugbot, depending on which tool the team already pays for) plus a security-focused reviewer on repositories that handle customer data. Running two general reviewers mostly doubles the comments, not the findings.

The prompt-injection warning deserves emphasis. An AI reviewer reads the code it reviews, so a malicious pull request can contain text that tries to instruct the reviewer. Prompt injection is the reason to require approval before workflows run on pull requests from outside contributors.

Copy this: a pull-request workflow

The workflow below implements gates 2 and 3 on GitHub for a JavaScript or TypeScript repository. Adapt the build commands to your stack. On private repositories, dependency review and CodeQL need a GitHub Advanced Security licence; Semgrep and open-source dependency scanners are alternatives. Turn on secret scanning with push protection in the repository settings: it is not a workflow step.

# .github/workflows/pr-review.yml
name: PR review gates
on:
  pull_request:

permissions:
  contents: read
  pull-requests: write
  security-events: write

jobs:
  tests:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v7
      - uses: actions/setup-node@v7
        with:
          node-version: 22
      - run: npm ci
      - run: npm run lint
      - run: npm test

  dependencies:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v7
      - uses: actions/dependency-review-action@v5
        with:
          fail-on-severity: high

  codeql:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v7
      - uses: github/codeql-action/init@v4
        with:
          languages: javascript-typescript
      - uses: github/codeql-action/analyze@v4

  ai-security-review:
    # Trusted pull requests only: the action is not hardened
    # against prompt injection. Pin to a commit SHA in production.
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v7
        with:
          ref: ${{ github.event.pull_request.head.sha || github.sha }}
          fetch-depth: 2
      - uses: anthropics/claude-code-security-review@main
        with:
          comment-pr: true
          claude-api-key: ${{ secrets.CLAUDE_API_KEY }}

Then make tests, dependencies and codeql required status checks in a branch ruleset, require at least one human approval, and require review from code owners for sensitive paths. Leave the AI review jobs as advisory until you have a month of data on their false-positive rate.

Add a short checklist to your pull-request template so the author does gate 1 explicitly:

## Author checklist
- [ ] I can explain every line of this change
- [ ] This PR does one thing (under ~400 changed lines)
- [ ] New dependencies are listed and checked to exist
- [ ] Tests cover the requirement, not just the implementation
- [ ] No secrets, keys or customer data in code or tests
- [ ] AI tool used: ______  Risk tier: low / medium / high

Human review: set the depth by risk

Human attention is the scarce resource, so spend it where a defect is expensive. Classify each pull request by what it touches, not by how much code it adds.

Risk tierTypical changesHuman review
HighAuthentication, permissions and database access rules; payments; personal data; infrastructure, CI and deployment; rules files and tool configuration for AI assistantsCode owner approval. Read every line, check the tests against the requirement, try the failure cases. Two reviewers for payments and access control.
MediumNew features and API endpoints, schema migrations, new dependenciesOne reviewer who knows the area. Focus on behaviour, data flow and the dependency list; skim formatting.
LowCopy, styling, documentation, internal tooling with no data accessA quick read once automated checks pass.

For high-risk changes, ask the author to walk through the change rather than reading it cold. If the author cannot explain why the code is written the way it is, the change is not ready, regardless of which tool wrote it. For apps on Supabase, our guide to Row Level Security for Lovable and Bolt apps shows how to test data access rules directly.

Measure whether the pipeline works

Review is working when defects stop reaching production, not when comment counts rise. Track four measures monthly:

  • Change failure rate: the share of deployments that cause an incident or need a fix, one of DORA’s software delivery metrics. It is the clearest signal that review is or is not catching problems.
  • Escaped defects by gate: for each production bug, which gate should have caught it. This tells you where to invest.
  • Time to first review and pull-request size: large, slow pull requests get shallow reviews.
  • AI reviewer precision: the share of AI comments that led to a change. Low precision trains reviewers to ignore the tool; tune its rules or switch it off.

Expect the first month to be noisy: rules files, missing tests and AI reviewer instructions usually need adjusting before the numbers settle.

Frequently asked questions

How should teams review AI-generated code?

Use a pipeline with five gates: the author checks and explains their own change, automated checks run in CI (tests, static analysis, secret and dependency scanning), an AI reviewer comments, a human approves with depth set by risk, and releases go through staging and monitoring. Only the human approves the merge.

Can an AI code reviewer replace human review?

No. AI reviewers such as Copilot code review, Cursor Bugbot and Claude Code’s security review find real issues, but their output varies between runs and they can be targeted by prompt injection. By default Copilot leaves comment-only reviews that do not count toward required approvals, and Bugbot’s check does not block merges on its own. Use them to widen coverage, and keep a named human accountable.

What are the most common problems in AI-written code?

Logic errors on edge cases, missing authorisation checks, invented or risky dependencies, hard-coded secrets and known vulnerability patterns such as injection. CodeRabbit’s December 2025 analysis of 470 pull requests found 1.7 times as many issues in AI-co-authored code, with security issues up to 2.74 times higher.

How do I stop AI tools from adding fake or malicious packages?

Run dependency review on every pull request, require new dependencies to be listed in the pull request, and route installs through an allowlist or registry proxy. Research presented at USENIX Security 2025 found that at least 5.2% of packages suggested by commercial models, and 21.7% by open-source models, did not exist, which attackers can exploit by registering those names.

Which is better for code review: Copilot, Cursor Bugbot or Claude Code?

It depends on the tools your team already uses. Copilot code review and Bugbot are general reviewers; Claude Code’s security review focuses on vulnerabilities. Many teams run one general reviewer plus a security reviewer on repositories with customer data, rather than two general reviewers.

How big should a pull request be when using AI coding tools?

Small enough that a reviewer can understand it in one sitting, and limited to one purpose. AI assistants make large changes easy to generate, so set a size limit in your pull-request template and split work that touches many unrelated files.

How do we know if our code review process is working?

Track change failure rate, which escaped defects each gate should have caught, time to first review with pull-request size, and the share of AI reviewer comments that led to a change. If change failure rate rises as AI adoption grows, the review pipeline needs strengthening.

How Assystant can help

We set up review pipelines for engineering teams that build with Cursor, Claude Code and Copilot: rules files, CI gates, AI reviewer configuration and risk tiers that fit your codebase. If AI-written code is already in production and you are not sure what it contains, our rescue service for Cursor and Claude Code projects starts with a fixed-price audit of security, secrets and test coverage. For the policy side, read our one-page AI coding policy template or talk to our AI consulting and governance team.

Book a free 20-minute review and we will tell you which gate your team should add first.

Keep reading

Related articles

All articles

Agentic & generative AI22 October 2026

What is agentic AI? Definition, use cases and how to start

Agentic AI refers to AI systems that pursue a goal by planning steps, using tools and acting with limited supervision. Learn how it works, where it pays off and how to adopt it safely.

Agentic & generative AI7 April 2023

What does it cost to build your own GPT solution?

What drives the cost of building a custom GPT or LLM solution – approach, data, integration, usage fees, security and maintenance – and how to keep it under control.

Get in touch

Have a question about AI in your business?

Tell us what you’re working on. A senior consultant will answer your questions and recommend where to start.

During Indian working hours, we usually reply within a couple of hours.

Schedule a free consultation

A short call with a senior consultant. No obligation.

Required. We use your details only to reply to your request. Privacy policy

What you get

  • An NDA from the first conversation
  • You own the IP in what we build for you
  • A senior team you can reach
  • 100+ projects delivered since 2014
  • Clients in 20+ countries
  • A start within a month at the latest

What happens next

  1. 01We call you at a time that suits you
  2. 02We look at your workflow and find where AI pays off
  3. 03You get a proposal with the business case