How to review AI-generated code
Coding agents write code faster than a person can read it. Here is what goes wrong in it, a checklist for the person who reviews it, and where automated review fits.
Why AI-generated code needs its own review
A coding agent can open many pull requests a day, and more than one in five code reviews on GitHub now involve an agent.1 The code reads well, and that is part of the risk. In a study of agent pull requests, the agents' code repeated more of what the repository already had, but reviewers reacted to it more neutrally or positively than to code from people.2
There is also no author to ask. The agent knows your system only from what it read, so the reviewer brings the intent and the context.
Sources
What goes wrong in AI-generated code
- Security holes
Veracode gave more than 100 models 80 coding tasks. The code had a security flaw in 45% of cases, and larger models did not do significantly better.3
- Packages that do not exist
In 576,000 code samples, at least 5.2% of the packages commercial models named did not exist, and 21.7% from open-source models.4 An attacker can publish a harmful package under such a name. GitHub calls this slopsquatting.5
- Wrong logic, missing error handling
CodeRabbit, which sells AI code review, found logic issues 75% more common in AI co-authored pull requests, and error-handling gaps nearly twice as common.6
- Code the repository already has
Agents often write a helper again because they see only part of the repository.2
- Weaker tests and CI
When CI fails, an agent can make it pass the wrong way: remove the test, skip the lint step, or add
|| true.1 - Tests that confirm the bug
A test written from the code, not the requirement, can pass on a bug. Some AI test generators keep tests that pass on faulty code.7
A real example
Failures that report successCode that catches an error, logs it and goes on looks finished. Rectifier caught this one on a pull request.
rectifier bot commented
[High] Firewall setup fails open, and the bootstrap still reports success
On a fresh server the package index is never refreshed, so apt-get install ufw fails and every ufw command after it fails too. The script has no check that the firewall ended up active, so it goes on to start the container and exits 0.
Impact: A new server comes up with every inbound port open, the exposure this change was meant to close, and nothing reports it.
Sources
- AI-Generated Code Poses Major Security Risks in Nearly Half of All Development Tasks, Veracode Research Reveals. ↩
- We Have a Package for You! A Comprehensive Analysis of Package Hallucinations by Code Generating LLMs, USENIX Security 2025. ↩
- Review AI-generated code, GitHub Docs. ↩
- Our new report: AI code creates 1.7x more problems, CodeRabbit. ↩
- Design choices made by LLM-based test generators prevent them from finding bugs, arXiv. ↩
A checklist for reviewing AI-generated code
Use this list when you review a pull request a coding agent wrote. Several of the checks follow GitHub's advice on reviewing agent pull requests.1
Before you read the code
- One-sentence goal. Read the issue or the spec, not the agent's summary, and write down in one sentence what the change must do.
- Too big to say? If you cannot write that sentence, or the change touches many unrelated files, ask for smaller pull requests.
- CI left alone. Check that CI passed, and that the pull request did not change CI, test settings or coverage limits to get there.
In the code
- A reason for every file. Each changed file should follow from the goal. Ask about any file that does not.
- No duplicate helpers. Search the repository for each new helper. If one already exists, ask for the change to use it.
- Failures that fail. Look at each caught error, retry and default value. A failure must stop the work or be reported, not look like success.
Tests
- Nothing deleted or skipped. Look for tests that were removed, skipped or loosened to make the change pass.
- Real code, not only mocks. The tests should call the code that changed, not only stand-ins for it.
- One test that fails before. Ask for a test that fails on the old code and passes on the new, so it proves the fix.
Dependencies and security
- Real packages. Each new package exists, its name is spelled right, and it is maintained. Agents sometimes name packages that do not exist.
- Input escaped. Where outside input reaches a query, a shell command, a file path, a page or a log, it is validated or escaped.
- No secrets. No keys, tokens or passwords in the code, the logs or the error messages.
Where automated review fits
A person knows what the change is for. A review tool reads every line, every time. Use both. For how the tools differ, see AI code review. Rectifier checks an agent's work at three depths, so the agent fixes what it finds before a person reads the change.
While the agent works
Light review$1
The branch or the uncommitted changes, from the CLI, the skill or the Claude Code plugin.
On the pull request
Full review$2
Posted on the changed lines, with a verdict.
After both
Deep Scan$1per 1,000 lines
The whole repository, for the bugs that made it through. On Pro and Enterprise, at most $220 a scan.
Give your agent Rectifier
Choose your coding agent
- Install
$ uv tool install --upgrade imbik-rectifier $ claude plugin marketplace add imbik-ai/rectifier-agents $ claude plugin install rectifier@rectifierThe plugin gives Claude Code the rectifier skill and the MCP server.
- Sign in
$ rectifier loginThen start Claude Code, type
/mcp, pick rectifier and choose Authenticate. - Check it connected
The dashboard's Connect an agent page shows Claude Code once it has signed in.
- Install
$ uv tool install --upgrade imbik-rectifier $ rectifier skill install $ codex mcp add rectifier --url https://mcp.rectifier.imbik.ai/mcpWith Codex 0.166 or newer. This gives Codex the rectifier skill and the MCP server.
- Sign in
$ rectifier login $ codex mcp login rectifier - Check it connected
The dashboard's Connect an agent page shows Codex once it has signed in.
- Install
$ uv tool install --upgrade imbik-rectifier $ rectifier skill installThen add the rectifier entry from the dashboard's Connect an agent page to
~/.cursor/mcp.json. - Sign in
$ rectifier loginThen in Cursor Settings, open Tools & MCP and choose Authenticate next to rectifier.
- Check it connected
The dashboard's Connect an agent page shows Cursor once it has signed in.
- Install
$ uv tool install --upgrade imbik-rectifier $ rectifier skill installThe skill goes in
~/.agents/skills/rectifier/, which Codex, Cursor, Gemini CLI, GitHub Copilot, OpenCode and Amp read.8 For an agent that readsAGENTS.md, add the AGENTS.md block to the repository. - Sign in
$ rectifier loginThe read-only MCP server is at
https://mcp.rectifier.imbik.ai/mcp. Tell us which agent and we will add it. - Check it connected
The dashboard's Connect an agent page shows your agent once it has signed in.
Sources
- Build skills, ChatGPT Learn; Agent Skills, Cursor docs; Agent Skills, Gemini CLI docs; Agent skills, GitHub Docs; Skills, OpenCode docs; Skills, Amp docs. ↩
FAQ
Can a git hook or CI stop on a finding?
Yes. rectifier review exits with 1 when a finding blocks. See the CLI.
Does a review of uncommitted changes send my files right away?
No. The first run lists the files it would send and stops, so you can check them for secrets.
Can a finding go straight back to the agent?
Yes. Turn on "Message for a coding agent" in Settings, and each finding ends with a message to paste into the agent. The AGENTS.md block tells the agent to fix findings and leave dismissing them to a person.
Can it find bugs no pull request touched?
Yes. A Deep Scan reads the whole repository and ranks what it finds.
What does it cost?
A Light review is $1 and a Full review is $2, whatever the size of the change. Plans start at $30 a month with unlimited seats. See pricing.