Short answer: Use AI-generated code for well-specified, testable work like CRUD screens, glue code and tests, where review is cheap and fast feedback matters. Keep humans writing, or closely owning, security-critical logic, unclear business rules and changes in large legacy code. Studies from 2025 and 2026 show AI code carries more defects and security issues.

You lead a team where half the pull requests now start with an agent. Some engineers say the code is fine. Others say they spend their days cleaning it up. Both groups are partly right, and the data is finally good enough to settle some of it. This page pulls together the main studies, then turns them into rules you can use in review.
In this guide, you'll learn:
- Definitions
- What the studies found
- When to choose AI-generated code
- When to choose human-written code
- Where an AI software factory fits
Each claim below links to the study behind it.
Definitions
AI-generated code is code an AI model or agent writes, from a completion in your editor to a whole pull request opened by a cloud agent. A person may prompt, edit or approve it, but the first draft comes from the model.
Human-written code is code a developer writes, even if they look things up or copy patterns. In practice most teams now mix both, which is why studies have trouble labeling it. CodeRabbit, for example, had to infer AI co-authorship from signals in pull requests and said it "cannot guarantee" every PR labeled human was written only by humans (CodeRabbit, Dec 2025).
Vendors don't hide the risk. GitHub warns that Copilot "can produce incorrect or suboptimal code, including code that contains security vulnerabilities" (GitHub Docs). Lovable says its security scans "support secure development but do not guarantee it" (Lovable FAQ). Anthropic notes that a Claude Code review with no findings "doesn't mean your code is error-free or secure" (Claude Code Review).
What the studies found
| Question | AI-generated code | Human-written code | Source |
|---|---|---|---|
| Issues per pull request | 10.83 on average (about 1.7x) | 6.45 on average | CodeRabbit, 470 PRs |
| Logic and correctness | 75% more common | Baseline | CodeRabbit |
| Readability issues | More than 3x higher | Baseline | CodeRabbit |
| Security issues | Up to 2.74x higher; "more high-risk security vulnerabilities" | Fewer high-risk findings in Python and Java | CodeRabbit; Cotroneo et al., 2025 |
| Typical defects | Unused constructs, hardcoded debugging artifacts, repeated boilerplate | Maintainability issues typical of mature code | Cotroneo et al., 2025; Improta et al., 2026 |
| Size and complexity | Smaller, simpler, "structurally compressed and stylistically templated" | About 1.6x to 1.8x the cyclomatic complexity | Improta et al., 2026 |
| Security pass rate on test tasks | About 56%, flat year over year; syntax passes almost always | Not measured | Veracode via SD Times, Jul 2026 |
| Speed for experienced developers | 19% longer with AI tools in one trial | Baseline | METR via InfoWorld, Jul 2025 |
A few notes on reading this table:
- The CodeRabbit study looked at 470 open-source GitHub pull requests: 320 AI co-authored and 150 human-only. It found more critical and major findings in AI PRs (roughly 1.4x to 1.7x), nearly twice the error-handling gaps, and excessive I/O about 8 times as often. No issue category was unique to AI. CodeRabbit sells an AI review tool, so read it as vendor research.
- The academic studies come from the same research group. The 2025 paper compared over 500,000 Python and Java samples from three models. The 2026 follow-up compared 787,562 matched function pairs in Python, Java and C. It found that security results depend on language: models produced more and more severe findings in Python and Java, but in C humans had more high-severity memory-safety findings. AI code scored higher on a maintainability index, which the authors say mostly reflects its smaller size, not better quality.
- Veracode's 2026 report found an average security pass rate of 56%, with the best model at 68% and Java the weakest language at 30%. In short: AI code compiles, but nearly half of security tasks fail.
- METR's trial had 16 experienced developers do 246 real tasks on large, mature repositories. They expected AI to cut their time by 24%. They took 19% longer, and afterwards still believed AI had sped them up by 20%.
The pattern: AI code is shorter, more uniform and more often wrong in ways that pass a quick read. Human code is longer and more complex, and its problems look like the problems of an old codebase.
When to choose AI-generated code
- The task is well specified and easy to test. Forms, CRUD screens, API clients, data migrations with clear rules and test scaffolding.
- You have tests that would catch a wrong answer. AI code's main risk is logic that looks right. Tests that click through the user journey catch that.
- The pattern already exists in your codebase. AI is good at repeating a pattern; give it a good one to copy.
- You need a prototype to react to. A rough first version helps people agree on what they want before anyone polishes it.
- The reviewer knows the area. Readability issues were more than three times as common in AI PRs, so review needs someone who can spot what is missing.
When to choose human-written code
- Authentication, permissions and payments. CodeRabbit's most common AI security patterns were improper password handling and insecure object references.
- Rules nobody has written down. If the spec lives in someone's head, a model will guess. A person should write it, or at least write the spec first.
- Large, old codebases. The METR slowdown came from mature repos averaging over a million lines. Context matters more than typing speed there.
- Performance-critical paths. Excessive I/O was about eight times as common in AI PRs.
- Code you must defend in an audit. You need to explain why each line exists; that is easier when a person made the choices.
How to review AI-generated code
- Label it. Mark agent-authored commits or PRs so you can target review and track defect rates.
- Review the plan before the diff. A wrong approach is cheaper to reject than a wrong pull request.
- Check what the change touches. Ask which callers, APIs and screens depend on the code that changed.
- Run tests that act like a user. Unit tests miss broken journeys; end-to-end tests that click through the screens catch them.
- Scan for security issues every time, and treat a clean scan as a minimum, not a pass.
Where an AI software factory fits
The studies don't say "stop using AI." They say AI code needs a stricter process around it than a single agent in an editor provides. That is the job of an AI software factory.
Coding agents automate the developer. Devfab automates the development lifecycle. Three parts of Devfab map directly to the risks above:
- Research and an approved plan before code. Devfab's Researcher maps the domain (key terms, best practices, competitors) before the Planner writes the plan, and a person approves the plan. For a school portal, that means rules about guardians, report access and term dates are written down before an agent guesses.
- ChainFlow for impact. Devfab's code-intelligence layer maps which functions and APIs call each other and what is deployed, so dev agents see the effect of a change and don't break connected features.
- A QA agent that acts like a user. It runs UI and flow tests (screens, buttons and user journeys clicked end to end) plus logic tests, the checks that catch code which looks right but isn't.
Code lives in your own GitHub account, and cost is logged after each run, per task and per project. Devfab is in Beta, has a smaller community and fewer integrations than mature tools, and is not an editor for hands-on coding. Read more in AI code review vs a QA agent and What is an AI software factory?.
FAQ
Is AI-generated code worse than human-written code?
On average it carries different and often more problems. A CodeRabbit study of 470 pull requests found about 1.7 times as many issues in AI co-authored PRs, and an academic study found more high-risk vulnerabilities in AI code. Human code showed more maintainability issues and more complexity.
Is AI-generated code secure?
Not by default. Veracode's 2026 report says models pass security checks on about 56% of tasks, while syntax passes almost always. That means the code compiles and runs but often still has security flaws. Treat every AI change as untrusted until it is scanned and reviewed.
Does AI make developers faster?
It depends on the task and the developer. In METR's 2025 randomized trial, 16 experienced open-source developers took 19% longer on real tasks with AI tools, yet believed AI had sped them up by 20%. Measure your own team rather than relying on how it feels.
Should we label AI-generated code in our repo?
It helps. Studies had to infer authorship from signals, which shows how hard it is to tell later. Recording which changes an agent made, in commit messages or PR labels, lets you target review and compare defect rates over time.
Who owns AI-generated code?
Ownership depends on your tool's terms and your contracts, so check both. Several vendors state they do not own the generated code; for example, Vercel says it does not own code generated by v0. Keep the code in a repository your organization controls.
Read next
- What is an AI software factory?
- AI code review vs a QA agent
- Security questions to ask about AI-built software
- Unit tests vs end-to-end tests for AI-generated code
- Best AI testing tools for AI-generated code
Want AI-written code that comes with a plan, impact map and user-journey tests? Try Beta
Sources (checked November 2026): CodeRabbit: State of AI vs human code generation report (Dec 17, 2025); Cotroneo, Improta, Liguori: Human-Written vs. AI-Generated Code (arXiv, Aug 2025); Improta, Liguori, Cotroneo: Benchmarking the Quality Gap Between Human-Written and AI-Generated Code (arXiv, Sep 2026); SD Times: Veracode finds AI-generated code security has barely improved (Jul 28, 2026); InfoWorld: AI coding tools can slow down seasoned developers (Jul 11, 2025); GitHub Docs: About Copilot cloud agent; Lovable FAQ; Claude Code Review docs; v0 FAQ.
Frequently asked questions
Is AI-generated code worse than human-written code?
On average it carries different and often more problems. A CodeRabbit study of 470 pull requests found about 1.7 times as many issues in AI co-authored PRs, and an academic study found more high-risk vulnerabilities in AI code. Human code showed more maintainability issues and more complexity.
Is AI-generated code secure?
Not by default. Veracode's 2026 report says models pass security checks on about 56% of tasks, while syntax passes almost always. That means the code compiles and runs but often still has security flaws. Treat every AI change as untrusted until it is scanned and reviewed.
Does AI make developers faster?
It depends on the task and the developer. In METR's 2025 randomized trial, 16 experienced open-source developers took 19% longer on real tasks with AI tools, yet believed AI had sped them up by 20%. Measure your own team rather than relying on how it feels.
Should we label AI-generated code in our repo?
It helps. Studies had to infer authorship from signals, which shows how hard it is to tell later. Recording which changes an agent made, in commit messages or PR labels, lets you target review and compare defect rates over time.
Who owns AI-generated code?
Ownership depends on your tool's terms and your contracts, so check both. Several vendors state they do not own the generated code; for example, Vercel says it does not own code generated by v0. Keep the code in a repository your organization controls.




