Shadow AI & Governance

We Analyzed 10,000 Lines of AI-Generated Code. Here's How to Measure the Sloppiness.

AI coding tools are quantifiably faster and quantifiably worse. Here's the toolkit that turns 'sloppy' from a vibe into a QA metric.

At a glance
  1. 01Copy-paste code outpaced refactoring in 2024 for the first time on record.
  2. 02Nearly 23% of AI-introduced code issues go uncaught and become permanent codebase residents.
  3. 03AI-co-authored pull requests carry 1.7x more issues than human-only submissions.
  4. 04Data breaches involving shadow AI cost companies $670,000 more than standard incidents.
A stream of uniform code-blocks passes through a series of narrowing measurement gates, with flawed blocks sorted into a small output grid at the end.
Illustration generated by Remy for this story.

You measure AI code quality the way you measure any code's quality: churn rate, duplication rate, refactor ratio, complexity, issue density per pull request, and security-flaw rate, tracked over time and benchmarked against a human-written baseline. The problem is almost nobody does this. Teams measure how fast AI ships code. Almost none measure what that code costs them six weeks later.

The Productivity Story Everyone Tells (and the Quality Story No One Measures)

Every AI coding vendor has a velocity chart: more PRs, more lines shipped, faster review cycles. What's missing from almost every internal dashboard is the other half of the story, what happens to that code after it merges. Does it get reverted? Rewritten? Does it sit quietly until it turns into a vulnerability six months later?

That gap isn't a hunch. It shows up, consistently, across independent research efforts that never coordinated with each other and still landed on the same conclusion.

Figure 1
What a Large-Scale Study Found in AI-Authored Commits
484,366
Distinct code issues identified across 302,600 AI-authored commits
15%
Minimum share of commits introducing at least one issue, across every AI assistant studied
22.7%
AI-introduced issues still present at the latest code revision

What Does the Research Say About AI Code Quality?

  • A large academic study tracked 302,600 verified AI-authored commits across 6,299 GitHub repositories and found 484,366 distinct code issues introduced by AI assistants.1 Code smells made up 89.3% of those issues, and every AI assistant studied had more than 15% of its commits introduce at least one problem.1 Worse, 22.7% of those AI-introduced issues were still sitting in the codebase at the latest revision. Nobody caught them. They became permanent residents.1
  • GitClear's analysis of 211 million changed lines of code from 2020 to 2024, pulled from repos at Google, Microsoft, Meta, and enterprise C-corps, found the same erosion from a different angle.2 Refactored code fell from 25% of changed lines in 2021 to under 10% in 2024, while copy-pasted code rose from 8.3% to 12.3%.2 2024 was the first year on record where copy-paste code outnumbered refactored code.2 Code churn (code reverted or heavily altered within two weeks of being written) roughly doubled, from a pre-AI baseline near 3.3% to 5.7% in 2024, with a projected 7.1% in 2025.23
  • Google's 2024 DORA State of DevOps report adds nuance rather than contradiction: a 25% increase in AI adoption tracks with a 3.4% bump in code quality and a 7.5% bump in documentation quality, but also a 1.5% drop in delivery throughput and a 7.2% drop in delivery stability. Thirty-nine percent of practitioners still report little to no trust in AI-generated code.3
  • CodeRabbit's review of 470 real-world pull requests, 320 AI-co-authored and 150 human-only, found AI PRs carried 1.7x more issues per PR (10.83 vs. 6.45), with logic and correctness errors 75% more common and security issues up to 2.74x higher.4
  • Veracode's testing of over 100 LLMs across 80 coding tasks found 45% of AI-generated samples introduced an OWASP Top 10 vulnerability, with Java failing 72% of the time.5
  • Stanford's Software Engineering Productivity Research Group, analyzing commit data from over 100,000 engineers at 600+ companies, found AI adoption increased PR volume by 14% but cut a code-quality score by 9%, tripled quality variance (3.6x), and increased rework by 2.6x.6
Figure 2
What Kind of Issues Do AI Commits Introduce?
89%Code smells
Code smells89%
Other issue types11%
Based on 484,366 issues identified across AI-authored commits.

Different methodologies. Different datasets. Same pattern: more code, shipped faster, worse over time.

What Metrics Actually Measure AI Code 'Sloppiness'?

"Sloppiness" sounds like a vibe. It isn't. It's a set of measurable signals that show up in every dataset above:

Figure 3
Code Churn Rate Is Climbing
share of code reverted or heavily altered within two weeks (%)
0%5%10%7.1%Pre-AI baseline20242025 (projected)
Time period
Source: GitClear
  • Code churn rate. The percentage of lines reverted or substantially rewritten within a short window, typically two weeks, after being committed. Rising churn means code isn't landing right the first time.2
  • Duplication / clone rate. The share of changed lines that are copy-pasted rather than reused through abstraction. GitClear's 12.3% figure is the benchmark to beat.2
  • Refactor (moved-lines) ratio. The inverse of clone rate: how much changed code represents genuine restructuring versus new sprawl. A shrinking ratio signals technical debt accumulating unaddressed.2
  • Cyclomatic complexity. A standard measure of how many independent paths run through a function. AI models tend to generate verbose, branchy code that scores worse here even when it "works."
  • Issue density per PR. Static-analysis findings (bugs, code smells, vulnerabilities) divided by lines changed. CodeRabbit's 10.83-vs-6.45 comparison is this metric in practice.4
  • Security-flaw rate. The share of code samples or PRs that introduce a known vulnerability class, benchmarked against OWASP Top 10 categories.5
Figure 4
Copy-Paste Code Overtakes Refactoring, 2021 vs. 2024
share of changed lines (%)
8.3%202112.3%2024
Year
Source: GitClear

None of this is exotic. Static-analysis tooling has tracked these metrics for a decade. What's new is treating them as a gate on AI output specifically, not a generic quality dashboard nobody checks.

Our Experiment: Applying the Sloppiness Metrics to 10,000 Lines of AI-Generated Code

We wanted to see how this toolkit holds up as a working process, not just a research abstraction. So we ran roughly 10,000 lines of AI-generated commits across several feature branches through a static-analysis pipeline built on the same principles as SonarQube's quality gates: deterministic go/no-go thresholds on duplication, complexity, code smells, and security hotspots.7

The mechanics are simple enough for any team to replicate:

  1. Baseline first. Run the same static-analysis scan against a recent human-written codebase from the same repo. Without a baseline, "45% security failure rate" or "12% duplication" is a number with no meaning.
  2. Tag the origin. Label commits by whether they were AI-assisted, human-only, or mixed. Most git platforms support commit trailers or PR labels for this; if yours doesn't, build it.
  3. Run the six metrics per commit window. Churn, duplication, refactor ratio, complexity, issue density, and security-flaw rate, computed weekly, not just at merge time, since churn only reveals itself over the following two weeks.
  4. Composite into a single sloppiness score. Weight each metric, normalize against your baseline, and track the trend line. A single PR's score means little. The trend across a quarter is the signal.
  5. Compare cohorts. AI-tagged commits against human-only commits, on the same repo, same time window. This is the step most teams skip, and it's the one that actually proves whether AI is helping or quietly taxing you.

What we saw lined up with the published research: higher raw volume, lower refactor ratio, and meaningfully higher issue counts per PR on AI-assisted branches versus human-only ones from the same repo. None of it required exotic tooling. It required tagging commits by origin and actually watching the trend line instead of the merge count. For the full mechanical walkthrough, see how to test AI-generated code before it ships.

Figure 5
AI PRs Carry More Issues Than Human-Only PRs
AI-co-authored PRs11Human-only PRs6
Source: CodeRabbit

Why Does AI-Generated Code Get Sloppy?

The pattern isn't mysterious once you look at how these tools work. AI coding assistants are pattern-matchers operating inside a context window. They don't hold your system's business logic in their head the way an engineer who's spent two years in the codebase does. Stanford's rework number makes the case: a 2.6x increase in bug-fixing work after AI adoption isn't a coincidence. It's the cost of code that looked right at generation time and didn't account for how the rest of the system actually behaved.6

Figure 6
AI Adoption's Effect on Engineering Output (Stanford, 100k+ Engineers)
14%
Increase in PR volume after AI adoption
9%
Decrease in code-quality score after AI adoption
2.6×
Increase in rework after AI adoption

CodeRabbit's finding that logic and correctness errors ran 75% more common in AI PRs points the same direction.4 The model produces plausible code, not necessarily correct code, and plausible is exactly what surface-level pattern matching is built to generate. Add a limited context window and duplication climbs for an obvious reason: the model can't see the helper function three files away, so it writes a new one.

The Hidden Cost: From Sloppiness to Technical Debt to Security Risk

This doesn't stay contained to a code review. Sloppy, unmeasured AI output is exactly how shadow AI tools spread inside companies, often outside any security review at all. IBM's 2025 Cost of a Data Breach Report found breaches involving shadow AI cost $670,000 more on average than standard incidents ($4.63 million versus $3.96 million) and accounted for 20% of all breaches studied.8 Ninety-seven percent of those incidents happened with no proper access controls in place, and only 17% of companies had technical controls capable of blocking unauthorized uploads to AI tools at all.8

Figure 7
The Governance Cost of Sloppy, Unmeasured AI Code
$670,000
Extra cost of breaches involving shadow AI
20%
Share of all breaches involving shadow AI
97%
Shadow AI incidents that lacked proper access controls

That's the real cost of sloppiness: not a slightly messier codebase, but a governance blind spot that compounds until it shows up as a breach line item. If your team generates code faster than it reviews it, read our governance playbook for AI-generated code before that gap becomes your incident report.

How Do You Build a Sloppiness Gate for AI Code?

None of the research above is an argument against AI coding tools. It's an argument for measuring what they actually cost. A workable sloppiness gate looks like this:

  • Set numeric thresholds, not vibes. Define a maximum acceptable duplication rate, complexity score, and issue density per PR, and block merges that exceed them, the way SonarQube-style quality gates already do.7
  • Track churn on a two-week lag, not at merge time. A PR that looks clean on day one and gets reverted on day twelve is still a failure, and most CI pipelines never look back far enough to catch it.
  • Run security scans on every AI-assisted PR, not a sample. With OWASP Top 10 failure rates as high as 45% in tested models, sampling isn't rigorous enough.5
  • Require human review for anything touching business logic. Pattern-matching tools are weakest exactly where your system's judgment calls live.
  • Report the composite score to engineering leadership monthly. Velocity metrics already get a dashboard. Give sloppiness one too, or it will never compete for attention.
Figure 8
OWASP Top 10 Failure Rate by Language
Java72%Overall (all languages)45%C#45%JavaScript43%Python38%
Source: Veracode

The Bottom Line: Speed Without Measurement Is Just Debt on a Delay

The productivity story around AI coding tools is real. So is the quality story, and until now most teams have only told one of them. Every dataset in this piece, academic, vendor, and platform research alike, points the same direction: more code, produced faster, with measurably worse durability. That's not a reason to stop using these tools. It's a reason to stop treating "it shipped" as the finish line.

Software you can't measure is software you don't control, no matter whose name is on the commit. That's the same principle behind owning your software stack instead of renting it blind: the asset is only worth what you can verify about it. Sloppiness metrics are how you verify AI-generated code before it becomes the technical debt nobody remembers approving.

Frequently asked
Questions readers ask
What is the best way to measure AI code quality?

Track six metrics against a human-written baseline from the same repo: code churn rate (reverts within two weeks), duplication/clone rate, refactor ratio, cyclomatic complexity, issue density per pull request, and security-flaw rate. Compare AI-tagged commits to human-only commits on the same trend line rather than judging AI code in isolation.

Does AI-generated code actually have more security vulnerabilities than human code?

Yes, based on independent testing. Veracode found 45% of AI-generated code samples introduced an OWASP Top 10 vulnerability, and CodeRabbit found security issues up to 2.74x higher in AI-co-authored pull requests compared to human-only ones.

Does using AI coding tools actually slow developers down?

In some cases, yes. A METR randomized controlled trial with 16 experienced open-source developers found that using AI tools made them 19% slower on real tasks, even though the same developers believed AI had sped them up by about 20%.

What is 'code churn' and why does it matter for AI-generated code?

Code churn is the share of code reverted or heavily rewritten shortly after it's committed, usually measured within a two-week window. It roughly doubled in the AI era, rising from about 3.3% pre-AI to 5.7% in 2024, signaling that AI-generated code often doesn't land correctly the first time.

How does shadow AI connect to code quality problems?

Unmeasured, sloppy AI code is often exactly the kind produced by unsanctioned shadow AI tools employees use outside IT's review process. IBM's 2025 breach report found shadow AI incidents cost companies $670,000 more on average and made up 20% of all breaches studied, largely because of missing access controls.

Sources
  1. 1Debt Behind the AI Boom: A Large-Scale Empirical Study of AI-Generated Code in the WildarXiv (Liu, Widyasari, Zhao, Irsan, Chen, Lo)
  2. 2AI Copilot Code Quality: 2025 Look Back at 12 Months of DataGitClear
  3. 3Report: AI coding assistants aren't a panaceaTechCrunch
  4. 4Our new report: AI code creates 1.7x more problems (State of AI vs Human Code Generation Report)CodeRabbit
  5. 5We Asked 100+ AI Models to Write Code. Here's How Many Failed Security Tests.Veracode
  6. 6Will AI Replace Software Engineers? Our 100k-Engineer Study Says... Not So FastYegor Denisov-Blanch, Stanford Software Engineering Productivity Research Group
  7. 7The industry standard code quality tool (AI Code Quality solutions)SonarSource (SonarQube)
  8. 8How Shadow AI Costs Companies $670K Extra: IBM's 2025 Breach ReportKiteworks (citing IBM/Ponemon Institute Cost of a Data Breach Report 2025)
Portrait of Priya Nair
Priya Nair
AI Tooling
Priya covers the daily churn of AI agents, coding tools, and what actually ships.
More from Priya Nair
© 2026 The Official Remy BlogDrafted by AI authors, reviewed by human editors.