How to pay down technical debt with AI coding agents
Every codebase carries a list of fixes everyone agrees on and nobody ever gets to. The module with three naming conventions. The four slow tests that make CI take twenty minutes. The dependency pinned two major versions back "temporarily," eighteen months ago.
Technical debt doesn't survive because it's hard to fix. It survives because cleanup never wins the fight for your time: there's always a feature, a bug, a deadline that matters more. AI coding agents quietly change that math. When a cleanup costs a well-written task and a five-minute review instead of a lost afternoon, the "someday" backlog finally becomes affordable.
The economics of debt just changed
Debt work has always been importance without urgency. Renaming a confusing module makes every future change easier, but it never has to happen today, so it never happens. The blocker was never willpower. It was that every hour of cleanup was an hour taken from something with a deadline.
Agents break that trade-off. Claude Code, Codex or Gemini will happily grind through removing dead code, tightening types, or migrating a deprecated API while you do something else. The cost of the work drops to the cost of describing it and checking it. Suddenly the question isn't "can we afford to fix this?" but "why is this still on the list?"
The honest part: agents create debt too
Let's not pretend AI is a one-way ratchet toward cleanliness. Unreviewed agent code is how you get debt at machine speed: duplicated helpers, plausible abstractions nobody asked for, tests that assert nothing. If you're going to use agents to pay down debt, the same discipline applies as everywhere else: small tasks, and review every diff like a stranger wrote it.
That discipline matters double for refactors, because the acceptance criterion is unusual: behavior must not change. Say so explicitly in the task. "Extract the duplicated retry logic into one helper. No behavior changes. The existing tests must pass unmodified." An agent with that brief is a careful janitor; an agent told to "clean up the codebase" is a wrecking ball.
Turn "someday" into cards an agent can own
Vague debt never gets fixed, by humans or machines. So spend twenty minutes turning the mental list into concrete, scoped tasks, each one small enough that its diff reviews in minutes:
- Delete dead code: unused exports, commented-out blocks, feature flags that fully shipped a year ago.
- Fix every deprecation warning, one dependency at a time.
- Add types or tests to one module: not "the codebase," one module.
- Extract the duplication you've copy-pasted three times.
- Upgrade one pinned dependency and prove the suite still passes.
In SanuDesk (a desktop workspace for coding agents), that list lives on a Kanban board right next to your feature work. Each debt item is a card with a title, notes on intent, and acceptance criteria. When you're ready, you deploy the card to a fresh agent session and it moves across the board as the work happens. No ceremony, no separate tracker to keep in sync.
Pay it down in the gaps, not instead of features
Here's where the workflow gets fun. Debt is the perfect background job: low-urgency, well-scoped, and fine to run unattended. While one agent builds the feature you actually planned today, deploy two or three debt cards to sessions running alongside it, the same pattern as running multiple agents at once, just pointed at cleanup.
SanuDesk tiles those sessions in one grid, so the cleanup crew works in your peripheral vision instead of in forgotten terminal windows. Each finished card lands in the review lane with a note on what changed and how to test it. A solo developer with a fleet can retire more debt in a week than most teams manage in a quarter, one honest review at a time.
Put maintenance on a schedule
The last step is making sure the pile never grows back. Some debt is recurring by nature: dependencies drift, lint violations accumulate, TODOs rot. That's what Loops are for: agent runs that repeat on a schedule you set. A weekly loop that bumps minor dependency versions and runs the test suite. A nightly sweep that flags new dead code and stale TODOs. Every run is journaled, so you skim the results and only step in when something needs a human.
Debt stops being a dreaded quarterly project and becomes ambient maintenance, handled continuously, in the background, at the cost of a review.
Start with one card
You don't need a "refactoring sprint." Pick the one cleanup you've been muttering about for months, write it as a small task with a no-behavior-change guardrail, and hand it to an agent tonight. Review the diff over coffee tomorrow.
SanuDesk gives that workflow a home: tiled Claude Code, Codex and Gemini sessions, a board your agents work from, and Loops for the maintenance that never ends. You bring your own agent accounts or models, and it's free to start.
Download SanuDesk and put your first debt card on the board, or see how the pieces fit together on the features page.