Technical debt backlog items a coding agent can finish

Stefan-Iulian Tesoi · · 6 min read

An opened watch movement on a dark workbench with a screwdriver and tweezers beside it, a mechanism taken apart to be repaired without changing what it does.

Give the item an end state you can measure and a rule that behaviour does not change. "Clean up the billing module" never finishes, and an agent keeps refactoring for as long as it is allowed to. "Remove the three direct database calls from BillingController, with the existing billing tests passing unedited" finishes, and a reviewer can check it.

Most of a technical debt backlog is written as complaints rather than work: "refactor auth", "tidy up the API layer", "tech debt: payments". Those titles were reminders for a person who knew what they meant. A coding agent reads only the item, and an item with no finish line invites it to change everything nearby. Debt items are where a backlog an agent can read is usually furthest away.

Why do technical debt backlog items never close?

Because nothing in them says when to stop. A feature item ends when the behaviour exists. A debt item describes a quality, and "cleaner" and "simpler" have no last commit.

Ward Cunningham coined the debt metaphor in 1992, and Martin Fowler's technical debt quadrant of 2009 sorted it along two axes: deliberate or inadvertent, reckless or prudent. Both describe how the debt arrived. Neither says what paying it off looks like, and that is the part the item has to supply.

Refactoring tickets fail in three recognisable ways:

What makes a debt item finishable?

An end state someone can check by running a command, rather than by reading the code and forming an opinion. A finishable item answers four questions, and the answers double as its acceptance criteria.

PartVagueFinishable
End stateClean up the billing moduleNo file in billing/ imports the database client directly
MeasureMake the image smallerProduction image under 720 MB, measured on the built image
BehaviourDo not break anythingExisting billing tests pass with no test file edited
BoundaryRefactor as neededChanges limited to billing/ and its tests

A measurable end state also answers how to track technical debt between sprints: count what the items count. Direct database imports, files over 500 lines, dependencies two major versions behind. A number that falls each sprint is debt being paid; a list of titles is not.

The rest of an executable item still applies, from context to constraints, and how to write a backlog item an agent can execute covers it. Debt items differ in one way: their most important criterion is about what must not change.

How do you prove behaviour did not change?

With tests that describe what the code does today, written before the change and left alone by it. Michael Feathers named these characterisation tests in Working Effectively with Legacy Code: call the code, record what it returns, and assert exactly that, even where the current answer looks wrong.

For a pure refactor the rule is short. The characterisation tests pass before, pass after, and nobody edits them. An agent that edits a test to make it pass has changed behaviour and hidden it, so write "no existing test edited or deleted" into the criteria in so many words. Writing those tests first is often an item of its own, and coding agents on legacy code walks through it.

A green suite proves the tests pass. It does not prove they still test anything.

Our own backend showed why the wording matters. In November 2026 a coding agent removed about 7,600 lines of dead code across 159 files. Trimming statements out of tests left some assertions checking nothing, because they had relied on a side effect of the removed code, and the suite stayed green. One file a checker had reported as unused turned out to be imported, and the full build caught it, not the review.

Three debt items rewritten

Each pair is the same piece of debt, first as it usually sits in a backlog, then as an item an agent can finish:

  1. "Refactor the payment service" becomes: move the three payment-provider calls in PaymentController into PaymentGateway. Done when PaymentController makes no direct provider call, the existing payment tests pass with no test edited, and no file outside payments/ changes.
  2. "Shrink the Docker image" becomes: production image under 720 MB, with every route answering as before. Ours went from 847 MB to 705 MB as one item with that number in it. Checking the routes turned up a PDF export that had failed on every request in production, because the image shipped the PDF library without the browser it drives.
  3. "Remove dead code" becomes: delete every file and export no entry point reaches, from a static import scan attached to the item. Done when the build and full test suite pass, with code reachable only from a feature someone might still want listed for a decision rather than deleted. In ours, that list included a switch that had lost its only entry point a week earlier.

The third criterion matters most. Whether a feature is dead is a product decision, and an agent asked to decide it will guess.

How much debt work belongs in each sprint?

A share decided in advance and compared with what actually finished. Many teams reserve about 20% of capacity for debt. With agents, the capacity that counts is specified items and review time, so the share is of items handed to agents, not of engineer hours.

Managing technical debt with agents changes which part is expensive. Building a debt item is cheap; reviewing its diff is not. A 7,600-line deletion can be reviewed in an afternoon because it only deletes. A restructure of the same size cannot, which is why splitting stories for coding agents applies to debt as much as to features.

Debt also arrives faster once something looks for it. Our weekly code audit files at most five new findings per repository per run, so the intake stays at a rate reviewers can absorb. In Laimonade, debt items carry acceptance criteria like any other item, and a coding agent hands finished work back to In Review with its evidence; it cannot close its own item.

Frequently asked questions

Should an agent refactor code it was not asked to touch?

No. Tidying neighbouring code turns a reviewable change into one nobody can check, and mixes intended changes with incidental ones. Put the boundary in the item, by directory or file list, and have the agent file what it noticed as a new item. What an agent should never be able to do sets the hard limits; scope belongs in the item.

Do characterisation tests need to exist before the work starts?

For a refactor, yes, or the first item writes them. Without them nothing distinguishes a refactor from a behaviour change, and a green suite only proves the existing tests pass. Writing them suits an agent well as a separate item: no production code changes, and every new test must pass against the current code.

Who decides which debt is worth paying down?

The product owner, using the tech lead's estimate of what the debt costs. Debt is worth paying when it slows work the roadmap needs next or keeps producing defects. The tech lead names the cost concretely, such as minutes added to every build or a module that every third bug touches, and the product owner ranks it against features.