Back/Engineering/Cursor/Claude
IntermediateEngineering

How to Systematically Reduce Technical Debt Using AI Agents

Capture a noisy test run, have Claude group warnings by type and worst offending files, save the result as a tiered migration checklist, and let Cursor or Devin take the next bounded task whenever capacity opens.

How to Systematically Reduce Technical Debt Using AI Agents

Zach pipes a frontend test run to a log, asks Claude to quantify roughly 1,200 noisy lines, stores the ranked cleanup tasks under agents/migrations, and assigns the next tier to Cursor.

Before you start

What you need

  • A repeatable test command
  • A captured test log
  • Claude Code or another analysis model
  • Cursor, Devin, or another coding agent

What you’ll make

A tiered Markdown migration checklist with quantified warning categories, affected files, and small tasks agents can complete independently.

Tools used

Step by step

The workflow

Follow the sequence once, then adapt the prompts, checks, and handoffs to your own setup.

5 steps

Step01

Identify Problem Areas

Run the normal test command and capture both standard output and errors to a dated log. Record the test count, failures, and total log lines so later work has a baseline.

Step02

Analyze Logs with AI

Give the log to Claude and ask it to group repeated warnings, quantify each category, identify the worst files, and distinguish legitimate defects from harmless but distracting output.

Example prompt
Analyze this test log as a technical debt inventory. Count repeated warning signatures, group them by root cause, identify the worst offending files, and separate likely correctness problems from cleanup noise. Cite representative log lines. Return a tiered Markdown checklist where each task has scope, affected files, expected line reduction, and a validation command.
Step03

Create a Prioritized Task List

Save the analysis under a migration directory in the repository. Keep the instructions and checklist together so any coding agent can choose one unchecked task and understand the baseline and validation.

Step04

Assign Tasks to AI Agents

Assign one tier or one small task to Cursor or Devin. Require the agent to fix the cause, keep the diff within the named files, run the relevant tests, and report the before and after warning count.

Example prompt
Take the next unchecked task in `agents/migrations/test-noise.md`. Fix the underlying cause without blanket warning suppression. Keep the change within the listed scope, run the documented validation command, update the before and after count, and check off the item only if the tests pass.
Step05

Review and Merge Changes

Review the focused change, compare test counts and warning output with the baseline, and merge it through the normal path. Keep the checklist updated so another agent can take the next item without repeating analysis.

What good looks like

  • The baseline records total noise and warning categories.
  • Each checklist task names files and a measurable expected reduction.
  • One agent can complete a task without taking the entire migration.
  • The test log shrinks while tests continue to pass.

Build your next product with ChatPRD

Turn an idea into a PRD, user stories, and a plan.

Try ChatPRD free

After the steps

Runbook notes

How to recover when the loop fails and where human judgment helps.

Recover

If it goes sideways

The log is too large for one model request
Have the agent process the file in chunks, aggregate counts by warning signature, and cite sample lines and affected files in the final analysis.
The agent hides warnings instead of fixing causes
Forbid blanket suppression and require the task to explain the root cause and before or after count.
A cleanup task touches too many files
Split it by warning type or small file group and run the test command after each branch.
Noise drops because tests stopped exercising behavior
Compare test counts and failures with the baseline, and inspect any deleted assertion, mock, or setup code.

Start shipping
better products.

Join 100,000+ product managers who use ChatPRD to write better docs, align teams faster, and build products users love.

Free to start
No credit card
SOC 2 certified
Enterprise ready