AI Writes Half Your Code? Nobody Actually Measured That
This week's most-shared AI number didn't come from a code repository. It came from a survey asking developers what they believe.

Two numbers travelled together all last week: AI supposedly writes half of all code now, and that code fails security tests 44% of the time. Both are accurate. Only one of them is a measurement.
Fourth installment of our weekly rubric. The rule hasn't changed: the number is almost always right, it's the story wrapped around it that goes sideways. This time the press isn't to blame, which is what makes the case interesting. The slippage happened somewhere else, between two documents.
The report, and what it borrows
On July 28, Veracode published its 2026 GenAI Code Security Report. The headline finding is clean: across more than 100 models tracked over four testing rounds, the security pass rate landed at 56%, up from 55% a year earlier. Over the same stretch, syntax correctness climbed to nearly 100%.
The coverage held up. The Next Web ran the headline "AI writes half our code now. It still fails security tests 44% of the time." SD Times led on security barely budging in a year. Nobody left out the downside, not in the headlines, not in the body text.
That leaves the first half of the sentence. The report states: "In organizations that have adopted AI coding tools, AI now authors roughly half of all committed code." Veracode didn't measure that number itself. It cites it, and the link leads to DX, a vendor that builds measurement tools for engineering teams.
At DX, nobody reads the code. They ask a question
DX lays out its method plainly: "Currently, we measure the 'percentage of AI-generated code' by asking developers directly how much of their merged code they believe is written by AI." Developers are asked what they believe they delegated.
The company goes even further with the caveats. It describes the resulting data as "estimates of the proportion of coding workload delegated to AI tools, rather than literal measures of code output." A workload estimate, in other words, not an output measurement.
It flags bias running both ways too: undercounting when agents work unsupervised, and overcounting "when developers treat AI use as a performance signal." At a company where using AI looks good, people tend to claim a little more credit for it.
Estimating how much code AI writes by asking developers is a bit like estimating gym attendance by asking members how many times they think they showed up. The result says something real. It just doesn't say what everyone assumes it says.
Because that's exactly where the slippage happens. DX talks about estimated delegated workload and is explicit that this isn't a measure of code output. The report, for its part, takes away that AI now writes half of all committed code. The caveat didn't survive the trip, and the whole distortion lives in that gap: not a badly worded headline, but one document citing another.
A number that doubled in one quarter
DX's own trend line is worth a look. In Q4 2025, developers self-reported 22%. In Q1 2026, that jumped to 27.4%, across more than 500 organizations. In Q2 2026, it hit 51.9% on average, across more than 400 companies.
A codebase doesn't flip that fast. The millions of lines already written don't evaporate because a new tool showed up on the team. What can double in a quarter, though, is how people perceive their own work.
The panel matters too: these are companies already running AI tooling, customers of a platform built to measure engineering team performance.
Two numbers that don't multiply
The 44% figure is a real measurement. The question is what it measures. Veracode ran its models through code-generation tasks built around known vulnerability families, under standardized conditions and, crucially, "with no security-specific prompting." No security instructions were given to the model: what's being observed is its default instinct on an exercise where a flaw is possible.
That's a different thing from asking what share of shipped production code is actually vulnerable, and nothing in the report measures that. The back-of-envelope math the sentence invites (half the code, 44% flawed, so roughly a fifth of the codebase needs fixing) doesn't hold up, because the two percentages don't share a denominator.
An average of two opposite worlds
The breakdown by vulnerability type is even more awkward. Models score 87% on cryptographic algorithms and 83% on SQL injection. Then they drop to 15% on cross-site scripting and 12% on log injection.
These aren't variations around a mean. They're two opposite situations dumped into the same bucket. On two of the most common vulnerability families, models have gotten genuinely solid. On two others, they fail almost every time.
A 44% rate that averages 87 and 12 doesn't describe anyone in particular. It's the kind of statistic that lumps a quiet neighborhood in with one that's on fire and reports that the city is doing so-so. The same gap shows up across languages: 63% pass rate in Python, 30% in Java.
What's still true
None of this undoes Veracode's actual finding, which holds up. Over a year, models improved on nearly everything except security, which stayed exactly where it started. Chris Wysopal, Veracode's co-founder, puts it this way: "models may be almost syntactically perfect, but they are still failing on nearly half of all tasks where security is needed. That number should be a red flag for any organization."
Code that compiles flawlessly and protects poorly is the same story we covered back in April with the correctness illusion. That time, we ran with volume numbers that were circulating without checking how they were built. Done now.
As for the actual share of code written by AI, it remains unknown, and not for lack of trying. The largest published census to date combed through more than 180 million repositories (Khosravani and Mockus, 2026). It produces counts, never a proportion. It also explains why: tracking agents through the one signal most adoption studies rely on recovers only 3.3% of them, thirty times less than what cross-referenced detection turns up.
A separate team, which built an AI-code detector trained on public repositories, hits the same wall: AI involvement is almost never declared, and no dataset at scale exists to establish it.
Code written by a machine carries no watermark. That's exactly why the only number available on its scale comes out of a survey, and why it only took two citations to turn it into a measurement.
Topics covered:
Frequently asked questions
Where does the 'AI writes half the code' number come from?
Is the 44% security test failure rate reliable?
Can you multiply the two numbers to estimate the risk?
Is there an objective measurement of how much code AI actually writes?
Did the press distort Veracode's report?

Alexandre Noto
Co-founder & Tech Expert
Alexandre has been in tech for over 20 years. Entrepreneur, software architect and AI enthusiast, he translates complex concepts into accessible explanations. At Declic Media, he is the technical voice that makes AI understandable for everyone.
All articles by Alexandre →