16 postslast publish 2026-10-19all systems green
overflow
← /posts

Code review: AI and code rot

Cyclomatic complexity, duplication, and churn are human-era proxies. Six metrics that would measure the thing we actually care about, none of them validated.

Cyclomatic complexity, duplication and churn are not measuring what we are doing today.

They were always proxies. They asked “how hard is this code to work with” back when the answer only mattered to a person. If the reader of code is increasingly AI, then rot is AI’s declining ability to work with the codebase, and the old proxies aren’t needed.

Claude writes low-duplication, low-complexity code that can still be architecturally rotten. It also writes clear-over-clever duplication on purpose, which scores as rot and is not. Also it will throw in a while (true) loop to get some retries in a controller action for no reason.

Six metrics that would measure the thing directly:

  1. Change amplification — for a targeted change, how many files does Claude have to touch? Up means the abstractions are not holding.
  2. Context cost per change — how much of the repo does Claude need loaded to change it safely? Up means coupling is growing.
  3. First-try success rate — given a ticket, does Claude pass on iteration 1 or iteration 7? Down means the codebase is getting harder to reason about, for AI.
  4. Defect recurrence by class — are the same bug categories coming back? Recurrence means the structure is not preventing them.
  5. Refactor tax — how clean is the PR for a repo-wide rename or a concept rewrite? Up means coupling again, from the other direction.
  6. Onboarding time for a new AI agent — fresh session, how long to first productive change? A direct read on how approachable the codebase is.

Change amplification and first-try success rate are the two cheapest to start. Run all of them next to the traditional metrics, for six months minimum, and treat every disagreement between the two families as a thing to go look at. A disagreement is the most informative.

None of these are validated

We would invent them because they match the theory of what we are trying to protect. We don’t know they work.

And that is the part that should worry you, because it is worse than it sounds. Instrumentation never ships a feature. Nobody escalates a metric that was never built. Every item on that list of six is the easiest thing in the world to quietly skip, and you will not notice you skipped it until the day you need one of them to say no.

We can write a confident phased plan with entry criteria because we have not started measuring, so nothing has come back to contradict us. Ask me whether change amplification is trending up in our repos and, today, I could not tell you. That is not a gap in the plan. That is the plan not started.

Build the instruments before you need them to say no. If you cannot measure it, you cannot understand it.