← Latest papers
💻 computer science

A Large-Scale Comprehensive Measurement of AI-Generated Code in Real-World Repositories A Large-Scale Comprehensive Measurement of AI-Generated Code in Real-World Repositories

This paper presents a large-scale empirical study that utilizes a novel heuristic filter with LLM classification to analyze the characteristics and impact of AI-generated code in real-world repositories, revealing key differences from human-written code and its influence on development practices.

Original authors: Tianhao Mao, Dongfang Zhao, Haixu Tang, Xiaofeng Wang, Hang Zhang

Published 2026-03-31
📖 5 min read🧠 Deep dive

Original authors: Tianhao Mao, Dongfang Zhao, Haixu Tang, Xiaofeng Wang, Hang Zhang

Original paper licensed under CC BY 4.0 (http://creativecommons.org/licenses/by/4.0/). This is an AI-generated explanation of the paper below. It is not written or endorsed by the authors. For technical accuracy, refer to the original paper. Read full disclaimer

Imagine you've hired a super-fast, incredibly knowledgeable robot assistant to help you write a novel. You ask it to write a chapter, and it does so in seconds. But here's the big question: Is the robot's writing actually good? Does it fit the story? And does it change how you, the human author, work?

This paper is like a massive, scientific investigation into that exact scenario, but instead of a novel, the "story" is computer code in real-world software projects. The researchers didn't just ask the robot to write code in a test tube; they looked at millions of lines of code that were actually used in real software on GitHub.

Here is the breakdown of their findings, using some everyday analogies:

1. The Detective Work: Finding the Robot's Footprints

First, the researchers had a tough job: How do you know which code was written by a human and which by an AI?

  • The Problem: Developers rarely say, "Hey, I used AI for this."
  • The Solution: They built a "digital detective" system. They looked for clues like comments saying "generated by ChatGPT," then used a second AI to double-check if those clues were real or just false alarms.
  • The Result: They built the world's largest dataset of "AI-written" code (about 20,000 files) and matched it with "Human-written" code from the same projects to make a fair comparison.

2. The Writing Style: The "Verbose" Robot vs. The "Concise" Human

When they compared the code, they found some fascinating differences in how the two "authors" write.

  • The AI is the "Over-Explainer":
    • Analogy: Imagine a human chef who knows exactly how to make a sandwich and does it in 3 steps. The AI chef, however, explains every single step in detail, listing every ingredient twice and adding extra instructions on how to hold the knife.
    • Finding: AI code is more verbose. It uses more words (tokens), more lines, and more structural "fluff" to say the same thing. It doesn't use more comments (explanations); it just writes more actual code to do the job.
  • The Human is the "Master of Shortcuts":
    • Humans tend to compress complex ideas into neat, efficient packages. They reuse old tools (code duplication) more often because they know where the "shared toolbox" is.
    • Finding: Humans write more compact code and reuse existing pieces more effectively. AI tends to build a "new tool" for every single task, even if a similar one exists nearby.

3. The Structure: The "Layered Cake" vs. The "Tight Bundle"

  • AI builds "Layered Cakes":
    • Analogy: If a human builds a house, they might put the kitchen and dining room right next to each other because it makes sense. The AI, however, might build a kitchen, then a hallway, then a dining room, then another hallway, just to get from one to the other.
    • Finding: AI code tends to be more layered and nested. It creates deeper "loops" and "if-then" structures. It's not necessarily wrong, but it's less efficient and harder to navigate because it's spread out over more layers.
  • Humans build "Tight Bundles":
    • Human code is often more interconnected and dense. It feels more "organic" and less like a rigid, step-by-step instruction manual.

4. The Security: Different Kinds of "Leaks"

  • The Findings: AI code isn't necessarily full of "critical" bugs (like a house collapsing), but it does have more medium-risk issues.
  • The Analogy:
    • Humans are more likely to leave a "password" written on a sticky note (a common, old-school mistake).
    • AI is more likely to accidentally leave a "master key" or an "API token" (a digital key to the whole system) lying around.
    • Why? The AI is trained on the internet, where it sees a lot of code with these specific types of keys, and it sometimes accidentally copies them.

5. The Workflow: The "Quick Fix" vs. The "Long Tail"

This is perhaps the most surprising part about how AI changes the process of working.

  • The "Micro-Commit":
    • Analogy: When a human works, they might tackle a whole room of a house at once. When using AI, developers tend to ask for small, specific fixes. "Fix this one button," "Change this one color."
    • Finding: AI-assisted commits are smaller and more localized. Developers use AI for quick, fine-grained tasks.
  • The "Delayed Cleanup":
    • Analogy: The robot builds a quick wall, but it's slightly crooked. The human doesn't notice immediately. But a week later, the wall starts to wobble, and now three different people have to come back to fix it.
    • Finding: AI-generated code is less likely to be changed immediately, but much more likely to be revisited, fixed, or touched by other people later on. It takes longer to "stabilize."
    • The Cost: The work isn't gone; it's just shifted. Instead of spending time writing the code, developers spend more time reviewing, refining, and fixing the AI's "rough draft" later.

The Big Takeaway

The paper concludes that AI isn't just a "magic button" that writes perfect code and saves us time.

  • It's a "Draft Generator": AI is great at getting the ball rolling and writing the first draft quickly.
  • It's a "Structural Shift": It changes the code to be more explicit and layered, which can make it harder to maintain later.
  • The Human Role Changes: The developer's job shifts from "writing every line" to "editing and refining." We are becoming more like Editors-in-Chief than just writers.

In short: AI helps you write faster, but it might make the code "messier" and require more cleanup later. The real value isn't just in the speed of writing, but in how well humans can manage and refine the AI's output.

Drowning in papers in your field?

Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.

Try Digest →