technical debt

How to Reduce Technical Debt: 7 Steps, and What AI Changes

By Zest | Updated | 9 min read
A laptop showing code with the words Reduce Tech Debt on the screen, beside an hourglass

To reduce technical debt, ask your engineers where it slows them down, write each item where you plan work, and pay down the code that changes most often first. Do it in small pull requests with tests around the code, and stop new debt at the review.

When agents do the paydown, Zest shows which coding-agent sessions and models each cleanup pull request took, and what they cost. Start freeGet started

In Stack Overflow’s 2024 survey, technical debt was the top frustration at work for professional developers, named by 63% (Stack Overflow, 2024). Coding agents change both sides of the problem: they make a change cheap to write, so debt can build faster, and they make the dull part of paying it back cheap too.

What is technical debt?

Technical debt is the extra effort a codebase costs you every time you change it, because of shortcuts and designs that no longer fit. Ward Cunningham coined the metaphor in 1992: “Shipping first time code is like going into debt. A little debt speeds development so long as it is paid back promptly with a rewrite” (OOPSLA '92 experience report).

Martin Fowler’s version is the one to plan with. He calls the debt “cruft”, deficiencies in internal quality that make a system harder to change, and the interest is the extra effort each new feature costs. If a feature would take four days in a clean module and takes six with the cruft, “the two day difference is the interest on the debt” (Martin Fowler).

Debt is not a bug. A bug is behavior that’s wrong today. Debt is code that works and is expensive to change, and code smells are how it shows up in a file: duplicated logic, a dependency several versions behind, a module nobody dares to touch without a manual test pass, a migration left half done.

What are the four types of technical debt?

The four types come from Fowler’s technical debt quadrant: debt is either reckless or prudent, and either deliberate or inadvertent (Martin Fowler, 2009).

Deliberate Inadvertent
Reckless The team knows better and goes “quick and dirty” anyway The team doesn’t know the design practice it is skipping
Prudent A conscious trade: ship for the release now, pay it back after Found by learning: once the code ships, the team sees what the design should have been

In Fowler’s words, “the useful distinction isn’t between debt or non-debt, but between prudent and reckless debt.” Prudent debt in a rarely touched part of the codebase may never be worth paying back, because its interest is small.

How to reduce technical debt in 7 steps

1. Ask the engineers where it hurts

Start with the people who pay the interest. Google tested 117 metrics for three kinds of debt against what its engineers reported, and found that “no single metric predicted reports of technical debt from engineers” (Ciera Jaspan and Collin Green, “Defining, Measuring, and Managing Technical Debt”, IEEE Software, 2023). So it keeps asking: since 2018 its quarterly engineering survey has asked engineers how far they are “hindered by unnecessary complexity and technical debt”.

The paper’s ten categories make a good checklist for your own survey or retro: a migration needed or in progress, missing project and API documentation, testing, code quality, dead or abandoned code, code degradation, expertise the team lacks, dependencies, a migration done badly or abandoned, and the release process.

A static analyzer covers the code-level part. SonarQube, for example, adds up the minutes it estimates each maintainability issue would take to fix (SonarQube docs). It won’t see a stalled migration or a release that needs three people.

2. Write each item where you plan work

Debt nobody can see doesn’t get scheduled. Write each item as a ticket next to feature work: where it lives, what it costs today (“every change to billing needs a manual test pass”) and what done looks like. Atlassian, which sells Jira, suggests creating issue types for technical debt and including them “in your regular sprint planning process” (Atlassian).

3. Rank it by how often the code changes

You only pay interest when someone touches the code. Fowler again: “crufty but stable areas of code can be left alone. In contrast, areas of high activity need a zero-tolerance attitude to cruft.” So rank items by how often their code changes and how much each change costs, not by how ugly they look.

Git already knows the first part. This lists the 20 files changed in the most commits over the last six months (git log docs). Lockfiles and generated files will top it; skip them.

git log --since="6 months ago" --name-only --pretty=format: | grep -v '^$' | sort | uniq -c | sort -rn | head -20

A file near the top of that list that also shows up in your survey answers is where to start.

4. Give it a fixed slot in every sprint

Debt competes with features and loses unless it has its own time. Agree on a recurring slot with whoever owns the roadmap, a share of each sprint or a cleanup week each quarter, and spend it from the top of the ranked list. Report what it bought in the terms the roadmap owner cares about: “billing changes no longer need a manual test pass” lands better than “refactored the billing module”.

5. Pay it down in small pull requests, with tests first

Put tests around the code before you change it, then refactor in small steps that keep them passing (the clean code and refactoring practice). Size matters more than it sounds. This is how often the first pass of our AI code reviewer (IonWarp, our sister product) flagged a should-fix issue, by size, across 1,232 pull requests merged in our two main repositories from August 12 to October 4, 2026 (what 866 agent-written pull requests show):

Lines changed Pull requests Flagged with a should-fix issue
Under 100 298 11%
100–299 277 23%
300–999 334 45%
1,000–2,999 185 57%
3,000 and more 138 51%

A big cleanup is also the hardest kind of change to review well. Above 3,000 lines our flag rate stopped climbing, partly because the reviewer reads a capped slice of a very large diff. Split the paydown so each pull request can be read in one sitting.

6. Hand the mechanical part to a coding agent

Renames, dependency upgrades, dead code, duplicated helpers and missing tests are good agent work, as long as the tests can tell the agent when it broke something. Claude Code’s docs give a four-step refactor recipe: find deprecated API usage, ask for a suggested refactor, refactor “while maintaining the same behavior”, then run the tests. Their tip is to “do refactoring in small, testable increments” (Claude Code docs).

For a larger refactor, OpenAI’s Codex prompting guide has the agent plan first, with the constraints in the prompt:

$plan We need to refactor the auth subsystem to:
- split responsibilities (token parsing vs session loading vs permissions)
- reduce circular imports
- improve testability
Constraints:
- No user-visible behavior changes
- Keep public APIs stable
- Include a step-by-step migration plan

You review the plan, then ask for one milestone at a time. Refactors were 11% of our agents’ pull requests (50 of the 456 that named a task type), and tests stayed in the loop: 86% of the 866 that carried our Session Analytics block (a summary the agent writes into the pull request) touched a test file (source).

7. Stop new debt at the review

Paying down old debt is wasted effort if new debt arrives faster. Move the rules a reviewer keeps repeating into the linter, CI and the agent’s instructions file: CLAUDE.md for Claude Code (docs), AGENTS.md for Codex (docs).

Then watch what happens to review findings. In the 30 days to October 4, 2026, our coding agents answered 2,273 findings from the reviewer: they fixed 80%, declined 18% and handed 1.6% to a person. A decline isn’t proof the finding was wrong. But when it was right, that’s deliberate debt someone just took on, and it belongs on the list from step 2.

Does AI-generated code create technical debt?

It can, and the early data leans that way, though none of it settles the question.

  • Less refactoring, more copying. GitClear, which sells engineering analytics, studied 623 million code changes from 2023 to 2026. Moved code, its marker for refactoring, fell from 21% of changed lines in 2022 to 3.8% so far in 2026, while copy/pasted lines rose from 9.4% in 2022 to 15.7% in the first half of 2026 (GitClear, 2026).
  • Less stable delivery. Google’s 2024 DORA report estimated a 7.2% drop in delivery stability for every 25% increase in AI adoption, while for the same 25% it linked AI to 3.4% better code quality and 1.8% less code complexity (DORA 2024). The 2025 report found AI now improves throughput but “still increases delivery instability” (DORA 2025).
  • Size is the lever you control. In our data the size of a pull request predicted review findings far better than the model that wrote it. Agents will write a very large diff if you let them; the table in step 5 is the case for not letting them.

For where agents fit in the rest of the lifecycle, see AI software development.

How do you measure technical debt?

No single number works, so read three together:

  • What engineers report. A quarterly survey question like Google’s, with its categories as answers.
  • What an analyzer estimates. SonarQube’s technical debt is “the sum of the maintainability issue remediation costs”, in minutes. Its debt ratio divides that by the estimated cost of writing the code (30 minutes a line by default), and rates a codebase A at 5% or less, down to E at 50% or more.
  • What the backlog shows. How many debt tickets are open, how old they are, and how many close each sprint.

Debt also shows up in delivery numbers, as changes that take longer and deploys that fail more often. Developer productivity metrics covers which of those to track.

Zest is ours, and it doesn’t measure technical debt: it collects no code diffs and runs no analyzer. It records each engineer’s coding-agent sessions and links each one to the GitHub pull request it led to, so when agents do the paydown you can see which sessions and models it took and what they cost. Keep SonarQube or your linter for the code itself.

Frequently asked questions

Is all technical debt bad?

No. Cunningham’s original point was that a little debt speeds development if you pay it back promptly. A shortcut taken on purpose to hit a release can be a good trade. The debt that hurts is the kind nobody chose and nobody tracks.

How much time should a team spend on technical debt?

There is no standard share. Fowler’s rule is about where, not how much: messy code that rarely changes can wait, and code that changes every week deserves zero tolerance. Start with a fixed slot each sprint, rank by how often the code changes, and adjust when the survey answers move.

Can AI coding agents fix technical debt?

They can do much of the mechanical work: renames, upgrades, dead code and missing tests. They need tests to check themselves against, and a person to decide what’s worth fixing. Keep each change small, as Claude Code’s own docs advise.

What is the difference between technical debt and a bug?

A bug is behavior that’s wrong today. Technical debt is code that behaves correctly but makes the next change slower or riskier. Debt often turns into bugs, because code nobody understands is easy to break.

Zest is AI coding analytics for engineering teams: it shows which coding agents, models and skills each engineer uses, what they cost, and which sessions end in merged pull requests. See how Zest works.