Next-Gen App & Browser Testing Cloud
Trusted by 2 Mn+ QAs & Devs to accelerate their release cycles

Can you trust AI-generated code? What security pass rates, productivity trials, and maintainability data show, plus where trust is earned and how to verify it.

Samyak Goyal
Author

Himanshu Sheth
Reviewer
Published on: August 27, 2026
You can trust AI-generated code only where you can verify it, because code security has not improved as models have become more capable. Veracode's 2026 GenAI Code Security Report puts the average security pass rate across models at 56%, with GPT-5.5, the strongest performer, still failing nearly one in three security tasks.[1]
This guide covers how reliable AI-generated code is, why it looks correct when it is not, its security risks, its effect on speed and maintainability, where trust is warranted, and how to verify it.
Key Takeaways
No. AI-generated code earns trust one task at a time, never by default. Veracode measured a 56% average security pass rate across models in 2026, so roughly two in five tasks ship a real flaw.[1]
What matters is whether a specific change can be checked before it reaches users. The expensive failure mode is a model that answers confidently and wrongly, in code that compiles and reads well.
Sonar surveyed over 1,100 developers and found 96% do not fully trust AI-generated code to be functionally correct, while only 48% always check it before committing.[2] That gap between stated distrust and actual checking is the practical risk.
Reliability tracks the task, not the model. Sonar reports AI now writes 42% of committed code, and 38% of developers say reviewing that code costs more effort than reviewing a colleague's work.[2]
Four independent measurements from 2025 and 2026 point the same way. Each one uses a different method, which is what makes the pattern worth acting on.
| Source | What was measured | Finding |
|---|---|---|
| Veracode 2026 | Security pass rate across models on generation tasks | 56% average, barely changed from 55% in the first edition |
| Sonar State of Code | Developer trust and verification behaviour, 1,100+ respondents | 96% do not fully trust output, 48% always verify it |
| METR randomised trial | Task completion time for 16 experienced developers | 19% slower with AI tools, perceived as 20% faster |
| GitClear | 211 million lines of code | Duplicated five-line blocks up eightfold, moved lines down 39.9% |
Stack Overflow's 2025 Developer Survey adds the sentiment reading. 84% of developers use or plan to use AI tools, up from 76% a year earlier.[3] Distrust in the accuracy of that output reached 46%.[4] Adoption and confidence are moving in opposite directions.
A model reproduces the surface of correct code better than the reasoning behind it. Naming, structure, and idiom are learned patterns, so plausibility arrives first and correctness is not guaranteed.
This is why review misfires. A human reviewer scans for the signals that usually indicate care: consistent naming, sensible decomposition, handled error branches. Generated code produces those signals cheaply, so the strongest heuristic a reviewer relies on is exactly the one the model satisfies best.
In the Reddit thread "Today I announced that I won't be reviewing AI generated PRs at company meeting" on r/ExperiencedDevs, an engineer stopped reviewing Claude Code changes sent to a Rails and Vue service, because the code looked plausible and its authors could not explain it. He concluded that review breaks down when the reviewer is the only person reasoning about the system.
The same asymmetry shows up in repository data. A study of 22,953 pull requests from 1,719 developers using AI assistance found that lower-experience authors submitted 2.15 times more commits per pull request and drew 4.52 times more review comments than higher-experience authors.[5] Generation got cheaper; verification did not.
The practical consequence is that reading a diff is no longer sufficient evidence. For a deeper split between the two activities, see ai code review vs verification, which separates judging how code looks from proving what it does.
Injection flaws and invented dependencies. Veracode measured 15% and 12% pass rates on cross-site scripting and log injection in 2026, against 83% on SQL injection and 87% on cryptography.[1]
That spread is the useful detail. Models handle the vulnerability classes that are heavily documented and heavily linted, and fail on the classes that depend on context the model does not have, such as which string reaches a template and which reaches a log.

Package hallucination is the one that scales into a supply-chain attack. The invented names repeat across runs, so an attacker can register a hallucinated package and wait for the next developer to install it. A dependency allowlist and a lockfile review close this route; a code reviewer reading for logic will not.
Not reliably. METR's randomised controlled trial found 16 experienced developers took 19% longer to close issues on their own repositories, while estimating they had gone 20% faster.[8]
The design is what gives the result its weight. Each of 246 real issues was randomly assigned to allow or forbid AI, on repositories the developers already maintained, averaging over 22,000 stars and a million lines of code.[8] These were experts working in code they knew well, which is the condition where AI assistance should look best.
Google's 2025 DORA report surveyed nearly 5,000 technology professionals and records 90% AI adoption. Trust splits underneath that number: 24% report a great deal or a lot of trust in AI, and 30% trust it a little or not at all.[9] Adoption is nearly universal; confidence is not.
Stop treating perceived speed as a measurement. Baseline your team's cycle time and escaped-defect rate before adopting an agent, then compare the same two numbers afterwards. Self-reported velocity was wrong by 39 percentage points in a controlled trial.
Note: Verify AI-written changes in a real browser before they merge with TestMu AI. Try free!
AI-generated code trades refactoring for duplication. GitClear's analysis of 211 million lines found blocks of five or more duplicated lines rose eightfold in 2024, while moved lines fell 39.9%.[10]
2024 was also the first year on record where copied lines outnumbered moved lines.[10] That inversion is the maintainability signal, because moving code means a developer understood two call sites well enough to unify them, and copying means nobody did.
The mechanism is straightforward. An agent given a narrow instruction produces a local solution, and duplicating an existing block is the lowest-risk way to satisfy that instruction. Refactoring requires reasoning about code the agent was never asked to change, so it does not happen unless somebody asks for it.
This debt is invisible at merge time and expensive at change time. A duplicated validation rule passes every test until the rule changes and only three of its five copies get updated.
Trust AI-generated code where the task is narrow, the correct answer is already known, and a cheap check can prove it. Withhold trust on authentication, payments, data deletion, and schema migrations.
Two properties decide the call: whether you can state the correct outcome in advance, and whether verifying it costs less than writing the code yourself. When both hold, accepting generated code is rational. When either fails, you are approving something you cannot evaluate.

Blast radius is the tiebreaker. A wrong colour token is cheap to discover and cheap to fix, so generated code is a good trade there. A wrong row-level security policy is neither, which is precisely the shape of CVE-2025-48757. Controls that run before the agent acts are covered in pre action checks ai coding agents.
Run the application and observe it. Unit tests, type checks, and linters read the same text the model wrote, so they miss broken redirects, dead buttons, and forms that never validate.
This is a structural limit rather than a tooling gap. An AI coding agent reads source, writes source, and reasons about source, and every verification primitive it reaches for operates on that same closed surface. When the agent reports "passed", it is reporting on the code, not on the rendered result a user would meet.
Teams hitting this gap need a verifier that does not share the agent's blind spot. TestMu AI's Kane CLI drives a real Chrome browser from a natural-language objective and reports what it observed, so the check runs on the rendered application rather than on the source. Capabilities that matter for reviewing generated changes:
The kane cli getting started guide covers installation, authentication, and a first run.
The demo below shows the pattern end to end: Lovable generates a live waitlist landing page, and Kane CLI verifies it in a browser with no test script written by hand.
Kane CLI does not review code and does not replace unit tests, which stay the cheapest way to pin logic at function level. It covers the layer those tests structurally cannot reach. For wiring this into a merge gate, see continuous verification ai code, and for the limits of agent self-checking, can coding agents test their own code.
Start by picking one user-facing flow your team changed with an agent last week and running it in a browser to confirm it still behaves. The answer to whether you can trust AI-generated code is decided by that check, not by the model on the other end of the prompt.
The measurements agree across methods. Security has stayed flat at a 56% pass rate while capability climbed.[1] Duplication rose as refactoring fell, and a controlled trial found experienced developers slower even as they felt faster. None of that argues for abandoning AI assistance, and all of it argues for a verification step that does not depend on the same interpretation that wrote the code.
Teams comparing assistants on how checkable their output is will find that in ai code assistants for testing, and the review practices themselves in code review.
Author
Samyak Goyal is a Senior Member of Technical Staff at TestMu AI engineering Kane CLI, the command-line tool that runs browser automation from the terminal, where a flow described in natural language executes in a real Chrome browser and returns pass or fail with shareable proof. He is a backend engineer with 4+ years of experience, previously an SDE at Innovaccer, where he built APIs, introduced Kafka, and cut deployment from weeks to hours. Samyak also builds multi-agent systems, skill-orchestration frameworks, and a personal copilot that indexes 200+ microservice repositories.
Reviewer
Himanshu Sheth is the Director of Marketing (Technical Content) at TestMu AI, with over 8 years of hands-on experience in Selenium, Cypress, and other test automation frameworks. He has authored more than 130 technical blogs for TestMu AI, covering software testing, automation strategy, and CI/CD. At TestMu AI, he leads the technical content efforts across blogs, YouTube, and social media, while closely collaborating with contributors to enhance content quality and product feedback loops. He has done his graduation with a B.E. in Computer Engineering from Mumbai University. Before TestMu AI, Himanshu led engineering teams in embedded software domains at companies like Samsung Research, Motorola, and NXP Semiconductors. He is a core member of DZone and has been a speaker at several unconferences focused on technical writing and software quality.
Did you find this page helpful?
More Related Blogs
TestMu AI forEnterprise
Get access to solutions built on Enterprise
grade security, privacy, & compliance