Software engineering.

§Insights · Agent-era codebase review

Duplicated logic and quiet drift: where debt sits in an agent-written codebase

Many engineering teams that adopted Claude Code, Cursor or Codex in the last year are now in the same position: more code is merged each week than anyone on the team can hold in their head. The product works, the tests pass, and the reviews are approved. Something has nonetheless changed in the codebase, and it is not where most teams look for it.

The debt does not look like debt

In an agent-written codebase, debt shows up as duplicated logic and quiet architectural drift, not as messy code. Agents write tidy functions, name them sensibly and give them tests. Read one file at a time, the code looks better than much of what it replaced.

The trouble sits between the files. An agent that cannot find an existing implementation writes a new one. If the first implementation lives inside a module the agent did not search, the agent writes the second; a month later another agent, in another package, writes the third. The fourth copy is written by an agent that found none of the first three, and no linter catches it.

The copies are rarely identical. They are written in different styles, at different times, against slightly different assumptions, so a checker that looks for identical blocks of tokens does not report them. They drift apart quietly: one rounds half-up and another half-even, one retries a request and another does not, one respects a holiday calendar and another ignores it. Each is correct by its own tests. The system as a whole no longer has one answer to the question each of them answers.

What the measurements show

GitClear’s analysis of 211 million changed lines of code, written between 2021 and 2024, found that lines classified as copied or pasted rose from 8.3% to 12.3% of changed lines, and that copied code exceeded moved code for the first time in its data.1 Moved code is what refactoring produces; copied code is what duplication produces.

The 2024 DORA report estimated that, as AI adoption increased, delivery throughput decreased by 1.5% and delivery stability by 7.2%.2 The report does not isolate duplication as the cause, and we do not claim that it does. It does indicate that writing code faster has not, by itself, made delivery more stable.

Why reviewing diffs does not catch it

Each pull request that adds a copy is locally reasonable. The reviewer sees a new helper, well named and tested, and has no reason to know that three others exist elsewhere. When pull requests run to thousands of lines and arrive faster than senior engineers can read them, review becomes a check that the code looks plausible. Plausible code is exactly what agents produce.

Diff review asks whether a change is correct. Duplication and drift are questions about the whole system: whether the change belongs where it was put, and whether it repeats something that already exists. Those questions are answered by someone reviewing architecture, not only diffs.

What catches it

Three things, in our experience of building this way ourselves:

  1. A CLAUDE.md that encodes the architecture. Agents read it. It should say where shared logic lives, which layer may call which, which module owns money, and what to do before writing a helper: search, and extend what exists rather than copy it.
  2. Guardrails in the repository. CI rules and lint configuration that fail the build when a known pattern returns: rounding outside the money module, the web layer importing the database client, ledger writes outside the ledger package. A rule that fails the build is read by every agent and every engineer, every time.
  3. Someone reviewing architecture. A person who looks at the system, not at the diff, on a regular schedule, and who writes the decisions down as decision records so that the next agent inherits them.

The rules files need the same discipline as the code. Teams that keep a .cursorrules, an AGENTS.md and several CLAUDE.md files find that they drift from one another, and that agents follow whichever one their tool happens to read. One file should be the source of truth, and the others should point to it.

What a review leaves behind

Our agent-era codebase review leaves four things in the client’s repository: a duplication and drift map, CI rules and lint configuration that fail the build, decision records for the choices that were never written down, and a CLAUDE.md that encodes the architecture. A sample report on a fictional codebase is published in full.

Read the sample duplication and drift report

The practice note on agent-era codebase review

Sources

  1. GitClear, “AI Copilot Code Quality: 2025 Look Back”, 2025. Scope: 211 million changed lines of code authored January 2020 to December 2024. gitclear.com/ai_assistant_code_quality_2025_research. Read at source 23 October 2026.
  2. Google Cloud, DORA, “Highlights from the 10th DORA report”, 22 October 2024. Scope: the DORA 2024 survey; the estimate is stated per increase in AI adoption. cloud.google.com/blog/products/devops-sre/announcing-the-2024-dora-report. Read at source 23 October 2026.