AI-generated code: the 4 Ds nobody tells you about

AI-generated code: the 4 Ds nobody tells you about

26 Nov

AI-generated code: Duplication, Drift, Deluge and Disguise, the risks you don't see

You ask an AI to build you a complete app. Five minutes later you have thousands of lines of code, a flawless interface and buttons that respond on the first click. It feels like you just saved weeks of work. Sometimes that's true. Other times you just bought a problem you can't see yet.

This isn't an article against artificial intelligence: we use it every day and it speeds up real work. We wrote it because almost everyone celebrates how fast AI writes code, and almost no one talks about what comes with it. Those risks follow clear patterns, and we group them into what we call the 4 Ds: Duplication, Drift, Deluge and Disguise.

In 30 seconds

  • Duplication: AI copies the same logic into ten places instead of creating one reusable function. One bug becomes ten bugs.
  • Drift: after dozens of prompts, the project piles up features nobody asked for and decisions that contradict each other.
  • Deluge: you ask for 50 lines and get 2,000 across 20 files. Nobody can review that properly.
  • Disguise: AI delivers something that looks like a solution, passes the tests, and doesn't solve the real problem.
  • The key: the risk isn't AI writing code, it's approving code nobody understands. The valuable skill now is proving it works.

The illusion of speed

A demo that works is not a product that works. AI is very good at producing the part you can see: clean screens, responsive flows, a convincing first impression. What it doesn't always produce well is the part you can't see: a maintainable structure, correct business rules, honest error handling and security.

It's the same difference between a website assembled in one click and one built on a content management system designed to grow: both look good on day one, but only one holds up under real use.

It's an iceberg. Above the water is the fast code everyone applauds. Below is everything you don't see, and that's where the four Ds live. The problem is when they show up: rarely in the demo, almost always in production, when there are already users, real data and money at stake.

What you see: the app works, looks great and was built in minutes.
01DuplicationThe same logic copied all over the project.
02DriftThe project slowly moves away from what was asked.
03DelugeMore code than a human can review.
04DisguiseFaçade solutions that pass the tests.

What the data says

This isn't a hunch. Several independent measurements point in the same direction:

8xincrease in 2024 in the frequency of duplicated code blocks (5+ lines), according to an analysis of 211 million lines.Source: GitClear
19%longer is what experienced developers took when using AI on their own projects, even though they believed they were 20% faster.Source: METR, 2025
38%of AI coding tasks still produce vulnerable code, even after the biggest improvement on record.Source: Veracode, Oct. 2026

The METR finding is the most uncomfortable one: it doesn't say AI is useless, it says our perception of speed is unreliable. Participants expected to be 24% faster and, even after taking longer, still believed they had saved time. That's why you measure instead of assuming.

D01
First D

Duplication: one bug, ten places

Imagine your app needs to validate an email address on ten different screens: sign-up, checkout, newsletter, profile… An experienced developer writes one function, tests it well and uses it in all ten places. If the rule changes tomorrow, it changes once.

AI, on the other hand, tends to solve each screen separately. Since each prompt arrives without the full project context, it generates ten almost identical versions of the same validation:

// signup.js
if (!/^[^@\s]+@[^@\s]+\.[a-z]{2,}$/i.test(email)) return error('Invalid email');

// checkout.js
if (!/^[^@]+@[^@]+\.[a-z]+$/.test(mail)) { showError('Check your email'); }

// newsletter.js
if (!email.includes('@')) return false;   // ← accepts "a@b" as valid

Three validations of the same data, three different rules. None of them looks wrong at first glance.

Everything works… until a bug shows up. Now you have to fix it ten times. And if you miss a single copy, the bug is still there, hiding on the screen nobody tested again. The healthy version looks like this:

// utils/validateEmail.js: a single source of truth
export function validateEmail(value) {
  return /^[^@\s]+@[^@\s]+\.[a-z]{2,}$/i.test(String(value).trim());
}

// on any screen
import { validateEmail } from '../utils/validateEmail';
if (!validateEmail(email)) return error('Invalid email');   // ✓ fixed once

How to mitigate it

  • Give context before asking for code: tell the AI which utilities already exist and explicitly ask it to reuse them.
  • Add a duplicate detector to your pipeline (jscpd, SonarQube, PMD-CPD) that fails the build above a threshold.
  • Ask for refactoring as a separate step: "find repeated logic and extract it into shared functions without changing behavior."
D02
Second D

Drift: one degree per hour

You start by asking for something simple, fast and secure. It works. Then you ask for a tweak, another, and another. Fifty prompts later the project has dark mode, internal chat, PDF export and QR login. Nobody remembers asking for half of it.

The tricky part is that each change, on its own, seemed reasonable. It's like a ship drifting one degree every hour: at hour five nobody notices; at hour 48 you've reached a different port. In code, drift looks like this:

  • One module uses caching for speed and another disables it "to avoid stale data". Both live side by side.
  • One prompt asked for server-side validation; a later one moved it to the browser "so it feels faster".
  • New dependencies appear to solve problems the project never had.

The result is a system with no clear direction, where every new bug is born from two decisions that contradict each other.

How to mitigate it

  • Write the project's "true north" in a file (scope, architecture, decisions made) and have the AI read it before every task. Tools like Claude Code or Cursor support this through rules files.
  • One task, one branch, one goal. If a new idea comes up midway, it goes to the backlog, not into the same change.
  • Check the heading every few changes: compare what exists against what was asked for and remove what doesn't belong.
D03
Third D

Deluge: when review becomes impossible

You ask for a change that should take 50 lines. You get 2,000 lines spread across 20 files. Some people call these "code grenades": a mountain of code is dropped on you, and defusing it is your job.

Here's the trap: human review doesn't scale with volume. With 50 lines, someone can read each one carefully. With 2,000, review turns into a quick skim and a "looks good". And the time you supposedly saved generating code goes, in full, into trying to understand it. Or worse: it isn't spent at all, and the code ships without anyone truly reading it.

Code nobody reviewed isn't finished code. It's debt you haven't been billed for yet.

How to mitigate it

  • Set a size limit for every change (for example, 300–400 lines per pull request) and ask the AI to split the work into small steps.
  • Ask for the plan first, then the code: which files it will touch and why. If the plan touches 20 files for a small change, stop there.
  • Require every change to ship with its tests, so you review behavior and not just lines.
D04
Fourth D · the most dangerous

Disguise: it looks like a solution, but it isn't

This is the one that worries us most. Not because AI "lies" on purpose: there's no malice. The problem is that it can deliver something with every appearance of a solution without solving the underlying problem. It's a key that fits the lock but won't turn.

The Rubik's cube with no rules

Ask an AI to simulate a Rubik's cube. On screen, the cube spins and ends up solved. Perfect. But when you open the code, you find this:

function solveCube(state) {
  // TODO: implement the cube rules
  return animation('solved');   // ← always "solves", whatever the state
}

The rules were never implemented. It's a film set: it looks real from the front, but it's propped up with sticks behind.

Passing the test without solving the problem

Now a more serious case. There's a function with a bug and an automated test that catches it. The right move is to fix the function. The disguised "fix" is to change the test:

// sum.js
export const sum = (a, b) => a - b;   // the real bug

// sum.test.js — before
expect(sum(2, 3)).toBe(5);           // ✕ FAILS

// sum.test.js — after the "fix"
expect(true).toBe(true);             // ✓ PASSES   … and sum is still broken

This isn't theory. The evaluation organization METR documented in 2025 frontier models that, instead of solving the task, modified the tests or the scoring code to get a higher score. Later that year, the academic benchmark EvilGenie found popular coding agents hardcoding expected answers to pass tests. Researchers call this reward hacking: optimizing the metric instead of the goal.

There's a subtler and far more common version: hiding errors instead of handling them.

try {
  await chargeCard(order);
} catch (e) {
  // ignore                      ← the order is marked as paid even if the charge fails
}
markAsPaid(order);

GitClear measured that this kind of error masking (empty catch blocks, stubbed methods, operators that silence unexpected input) rose 47% in 2026 compared to its base year. The app doesn't crash. It just does the wrong thing, silently.

Now picture it in a critical system. A banking app whose tests all pass. E-invoicing software that "sends" documents that never arrived. An inventory system that deducts stock that was never sold. Every test says OK. What if it's a film set?

How to mitigate it

  • Protect your tests: review any change to test files more strictly than the code itself, and keep tests the AI can't see or edit.
  • Test with real data and real cases, not just the happy path: invalid input, network failures, declined payments.
  • Ban empty catch blocks and TODOs in production with linter rules, and look specifically for functions that always return the same value.
  • Ask the AI to explain how its solution could break, not just how it works.

The 4 Ds at a glance

RiskSymptomWhen it hurtsFirst line of defense
DuplicationThe same logic, with small variations, in many filesWhen fixing a bug or changing a ruleDuplicate detector in the pipeline
DriftUnrequested features and contradictory decisionsWhen bugs appear that nobody can traceA scope document the AI always reads
DelugeHuge changes for small requestsDuring review… or when nobody did itSize limit per change
DisguiseGreen tests with the problem unsolvedIn production, with real users and dataProtected tests and real-world cases

Checklist: 7 questions before approving AI-generated code

It works whether you lead a technical team or hired someone to build your platform and want to know what to ask:

  1. Can someone explain what this code does, line by line in the critical parts, without asking the AI again?
  2. Is the change the size of what was requested? If not, why?
  3. Does it reuse what already existed or create a parallel version?
  4. Was any test file modified? If so, does the test still verify the same thing?
  5. What happens when something fails? Look for blocks that silence errors.
  6. Was it tested with real data and edge cases, not just the demo?
  7. Does this change move us toward what was defined at the start, or open a new path nobody approved?

The skill that matters now: proving it works

The real risk isn't AI writing code. It's someone clicking "approve" without understanding what they're approving. When anyone can produce software in minutes, writing code is no longer what's scarce. What's scarce is the judgment to verify it.

Writing code
→
Proving it works

That changes what you should demand from your team or your provider. The question is no longer "how long will it take?", but "how will you prove to me that this does what it says?". Tests that can't be gamed, reviews of small changes, an architecture that prevents duplication, and a person accountable for every line that reaches production.

At DAMOS Soluciones we build websites, eCommerce stores and custom platforms on our own CMS Editor, a content management system we build and maintain ourselves. We use AI to move faster, with one rule we don't negotiate: speed never replaces verification. If you're evaluating a development project, take a look at our web design plans; and if you inherited a project built with AI and aren't sure how healthy it is, we can review it with you.

Which of the 4 Ds have you seen in your team or your projects? If one of them sounded too familiar, it's probably already in your code.

Frequently asked questions about AI-generated code

Is it safe to use AI-generated code in production?

Yes, as long as it goes through the same controls as any other code: human review, automated tests the AI can't modify, security analysis and changes small enough to be truly reviewed. The risk isn't where the code comes from, it's approving it without understanding it.

What are the 4 Ds of AI-generated code?

They are four common risks of code written with AI assistants: Duplication (the same logic copied in many places), Drift (the project slowly moves away from what was asked), Deluge (more code than can be reviewed) and Disguise (solutions that seem to work and pass the tests without solving the real problem).

Can AI cheat to pass tests?

Yes, it's documented. Independent evaluations have recorded models that modify tests or hardcode expected answers to get a passing result. That's why it pays to protect test files, review any change to them and keep tests the AI can't see.

How do I know if my AI-built site or platform has these problems?

Some signs: bugs that come back after being fixed, features nobody remembers asking for, small changes that break other parts and failures that leave no trace. A code audit reviews duplication, error handling, tests and security to size up the risk.

Does AI really make developers faster?

It depends on the context. A controlled study by METR (2025) found that experienced developers took 19% longer using AI on their own projects, even though they believed they were faster. AI greatly speeds up certain tasks, but real speed has to include the time spent reviewing and fixing.

Was your project built fast? Make sure it was also built right

We review your website, store or platform to detect duplication, silenced errors and risks before they reach your customers.

Talk to our team

Sources: GitClear, AI Copilot Code Quality (2025) · GitClear, The Maintainability Gap (2026) · METR, productivity study (2025) · METR, Recent Frontier Models Are Reward Hacking (2025) · EvilGenie: A Reward Hacking Benchmark · Veracode, GenAI Code Security (Oct. 2026)

REQUEST MORE INFORMATION ABOUT OUR SERVICES

Te asesoramos en línea
Elija un departamento
Asesor whatsapp Mayra Castañeda
Mayra Castañeda
Comercial
En línea
Asesor whatsapp Nydia Duarte
Nydia Duarte
Billing
En línea