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
- 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.
- Treat AI reviewers as a second opinion, not an approver. They leave comments; a named human still approves.
- 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 mode | What it looks like | Cheapest reliable check |
|---|---|---|
| Invented or risky dependencies | An 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 authorisation | An 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 cases | Correct 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 code | API keys pasted into configuration or test files by the assistant or the developer. | Secret scanning with push protection. |
| Known vulnerability patterns | Injection, cross-site scripting, unsafe deserialisation, weak password handling. | SAST such as CodeQL or Semgrep, plus an AI security reviewer. |
| Oversized, sprawling changes | One 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 nothing | Generated 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.
- 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-reviewon pending changes from the terminal (Anthropic). - 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.
- 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.
- 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.
- 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 review | Cursor Bugbot | Claude Code security review | |
|---|---|---|---|
| Focus | General review: bugs, readability, suggested changes | Bugs and logic errors in the diff | Security: injection, cross-site scripting, authentication and authorisation flaws, insecure data handling, dependency issues |
| How it runs | Requested on a pull request, or set to review all pull requests automatically | Automatically 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 Bugbot | Custom filtering rules in the Action to cut false positives |
| Effect on merging | By default it leaves a “Comment” review that does not count toward required approvals | Its check reports neutral by default, so it does not block merges on its own | Posts comments; blocking depends on how you configure the workflow |
| Watch out for | It may repeat comments you have dismissed | Billing is usage-based; check your plan | Not hardened against prompt injection: run it only on trusted pull requests |
| Docs | GitHub Docs | Cursor Docs | GitHub 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 tier | Typical changes | Human review |
|---|---|---|
| High | Authentication, permissions and database access rules; payments; personal data; infrastructure, CI and deployment; rules files and tool configuration for AI assistants | Code owner approval. Read every line, check the tests against the requirement, try the failure cases. Two reviewers for payments and access control. |
| Medium | New features and API endpoints, schema migrations, new dependencies | One reviewer who knows the area. Focus on behaviour, data flow and the dependency list; skim formatting. |
| Low | Copy, styling, documentation, internal tooling with no data access | A 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.
Sources
- CodeRabbit, State of AI vs human code generation report, 17 December 2025.
- Veracode, AI code security update, October 2026.
- Spracklen et al., We Have a Package for You! A comprehensive analysis of package hallucinations by code generating LLMs, USENIX Security 2025.
- GitGuardian, State of Secrets Sprawl 2026, 17 March 2026.
- Stack Overflow, 2025 Developer Survey, 29 July 2025.
- Google Cloud, Announcing the 2024 DORA report, 22 October 2024.
- GitHub Docs: Using Copilot code review, Secret scanning, Dependency review, Code owners.
- Cursor, Bugbot documentation.
- Anthropic, Automate security reviews with Claude Code, 6 August 2025, and claude-code-security-review.
- Socket, Slopsquatting; OWASP, LLM01 Prompt Injection.
Saket Shukla