Continuous Modernization: agent pays off debt in background
Tech debt stops being a project that competes with features: an agent works the inventory continuously, and the payoff is now measurable in tokens rather than argued for on principle.
- Continuous modernization: agents work on tech debt reduction in background (non-blocking to feature work)
- Library version bumps and dependency upgrades are automated via agent PRs
- OpenRewrite + agent combination is used for systematic refactoring campaigns
- Agent tech debt PRs follow the same review process as feature PRs
- Dependency freshness score is tracked (% of dependencies within N versions of latest)
- Agent-authored tech debt reduction PRs in git history
- Automated dependency upgrade configuration (Renovate + agent, Dependabot + agent)
- OpenRewrite recipe configuration with agent integration
- Development L2 (Coding Agent Usage) - agents must be operational for agent-driven modernization
- Delivery L2 (CI/CD Pipeline) - CI must be fast enough for agent refactoring iteration
What It Is
Continuous modernization is the L3 shift from treating tech debt reduction as a project - something that competes with features for engineering time - to treating it as infrastructure that runs in the background, continuously, without consuming primary engineering capacity. At L3, an AI agent is configured to work through the prioritized debt inventory on an ongoing basis, producing PRs that engineers review rather than write.
The operational model is: the debt inventory (built at L2) serves as the agent's work queue. The agent takes items from the queue, executes the appropriate transformation (running an OpenRewrite recipe, updating a dependency version, replacing deprecated API usage), runs the test suite to validate the change, and opens a PR for human review. The engineer's role is to review and merge, not to write the migration code. The agent works asynchronously - it can run migrations overnight, on weekends, or during low-activity periods, consuming no engineering time during execution.
This is a fundamental economic shift. At L2, a migration that takes two weeks of engineering time consumes two weeks of capacity that cannot be used for features. At L3, the same migration produces a PR that takes two hours to review. The engineering cost of migration drops by an order of magnitude, and the migration backlog that seemed infinite at L1 becomes tractable. An organization running continuous modernization can address its entire multi-year backlog in months rather than years.
The "background" framing is important. Continuous modernization does not require a dedicated migration sprint, a separate migration team, or a freeze on feature development. It runs in parallel with normal feature work, using the same CI infrastructure and PR review process. The only additional capacity required is the review time - and review is inherently lighter than writing.
What changed in 2026 is that the payoff stopped being an argument from principle and became a number on an invoice. Giles Edwards-Alexander's "The Economic Benefit of Refactoring" (martinfowler.com, July 30) ran the same representative feature request against a codebase at 15 successive refactoring stages, using a fresh agent each time to eliminate learning bias - a controlled experiment that was simply not possible before agents, because no human forgets a codebase on demand. Breaking a 17,155-line single Rust file into 19 files took the input tokens required for that feature from 159,564 to 27,360, an 83% reduction, or roughly $0.40 per change at Sonnet 5 pricing. The per-change figure is small. The structure of it is not: that reduction applies to every future modification of that code, by every agent, forever, which makes refactoring a compounding investment with an observable rate of return rather than a hygiene argument engineers lose to roadmap pressure. The honest caveat is that the cost of performing the refactor itself, an upper bound of roughly five million tokens, was not precisely tracked.
This gives continuous modernization a second metric alongside items closed: the input-token cost of a representative change to each area of the codebase. Measure it before the agent works an area and after. Unlike debt-item counts, it is denominated in the same units as your bill, and it makes the case to a CFO without translation.
Why It Matters
- Eliminates the project-vs-features tradeoff - When migrations do not consume engineering time to execute, they no longer compete with features for sprint capacity; the perennial "we'll fix the debt after the feature rush" excuse disappears
- Enables backlog clearance at scale - An agent running continuously can process more migration items per week than any human team; a backlog that would take humans three years can be cleared in months
- Maintains currency automatically - Rather than allowing dependency versions to drift for years and then executing a painful major migration, continuous modernization keeps the codebase near-current with incremental updates that are individually simple
- Creates a measurable debt reduction velocity - With an agent producing a consistent stream of debt-reduction PRs, debt velocity becomes a metric: items closed per week, backlog age reduction, lines of deprecated code remaining. This visibility was impossible at L1-L2.
- Compounds with code quality - A codebase that is continuously modernized accumulates fewer secondary debt issues; modern APIs are better tested, better documented, and have clearer deprecation paths than the legacy ones they replace
NOTE - AI also CREATES tech debt. Studies show a 30-41% increase in technical debt within six months of widespread AI tool adoption. PRs with AI-generated code have 1.7x more issues flagged during review, and 89.1% of issues in AI-authored commits are code smells. Continuous modernization must now account for AI-generated debt alongside legacy debt. The agent that pays off old debt must also clean up after other agents - monitoring new-debt inflow from AI-assisted development is as important as clearing the existing backlog.
August 2026 put a production-scale price on that inflow for the first time. A study of 3.52M code changes tracked from April 2025 to April 2026 in a single large enterprise brownfield C++ codebase with full production observability (arXiv 2608.06640) found AI-generated code carrying a higher interface and coupling burden, more copy and allocation overhead, and explicit loops where an optimised standard API existed. Downstream, that showed up as a 5-8% increase in compute resource consumption, plus increased review effort. This is the first number that moves AI code quality from the maintainability ledger, where it can be deferred indefinitely, onto the cloud bill, where it cannot. The same study points at the remedy: targeted, taxonomy-informed feedback to the model cut the targeted static-analysis warnings by 11.1%, which is to say the inflow is steerable if you characterise it first. A separate August study of 441 repositories found a cheaper lever still - repositories without committed AI configuration showed roughly twice the cognitive-complexity increase, 53% against 27%, and 1.7 times the static-analysis warnings, while 73.8% of AI config files were committed once and never touched again.
Getting Started
- Ensure the debt inventory is current and structured - The agent needs a machine-readable work queue. Confirm the debt inventory has items in a consistent format: type, description, target state, and the specific transformation to apply (recipe name, version target, or pattern to replace).
- Establish the agent's toolchain - At minimum, the agent needs: repository access (read and write), the ability to run OpenRewrite recipes, the ability to run the test suite, and the ability to open PRs. Configure these permissions before the first run.
- Start with one category of debt - Do not run all migration types simultaneously. Start with dependency version upgrades (the most mechanical, lowest-risk category). Let the agent process five dependency bumps, review the resulting PRs, and confirm the pattern works before expanding scope.
- Define the PR review SLA - The bottleneck in continuous modernization is review throughput. Establish a norm: debt-reduction PRs (verified green by CI) are reviewed within 48 hours. Without this SLA, PRs pile up, the agent gets blocked, and the "continuous" part breaks down.
- Monitor for false positives - In the first month, track how often agent-generated PRs require changes during review. A false positive rate above 20% means the agent's task specifications are too loose. Tighten the criteria and re-run.
- Expand scope gradually - After dependency bumps are working, add API migration tasks. After API migration is working, add framework version upgrades. Expand the agent's mandate as confidence builds, not all at once.
- Baseline the token cost of a representative change per area - Before the agent works an area, pick one representative change and record the input tokens an agent needs to make it. Record it again afterwards. This is the metric that turns refactoring from a hygiene argument into an investment case, and it compounds: the reduction applies to every future modification of that code. In the controlled experiment behind this practice, decomposing a single 17,155-line file into 19 files cut the input tokens for the same feature request by 83%.
Treat agent-generated debt PRs differently from feature PRs in your review process. A debt PR that is all-green in CI, with a clear description of what changed and why, should have a streamlined review path. Do not apply the same review thoroughness to a dependency bump as to a new feature. The agent has already done the mechanical validation; your job is to spot the edge cases it could not anticipate.
Common Pitfalls
Running the agent without a validated test suite. Continuous modernization depends on tests to validate that transformations are safe. If the test suite is unreliable (flaky tests, low coverage), agent-generated PRs will have unreliable green signals and the review burden rises dramatically. Fix the test suite before enabling continuous modernization.
Letting agent PRs pile up unreviewed. An agent that opens 20 PRs but has 0 merged is not delivering value - it is creating review debt. The review SLA is not optional. If the team cannot commit to 48-hour review of agent PRs, reduce the agent's output rate until the review capacity matches.
Not monitoring for agent drift. Over time, an agent given a broad mandate will start generating PRs that are outside the intended scope - optimizations that are not in the debt inventory, refactoring that changes behavior in subtle ways, or changes to code areas that were not meant to be touched. Review the agent's output pattern monthly; pull back the mandate if scope drift appears.
Applying migrations without canary testing. For high-traffic services, even a mechanically correct migration can have unexpected production behavior. Establish a canary deployment path for agent-generated PRs in critical services: deploy to 5% of traffic before full rollout.
Measuring only the debt you are clearing, never the debt arriving. An agent working the backlog produces a satisfying downward line while a second line climbs out of frame. The August 2026 C++ study is the reason to instrument both: AI-generated changes in a large brownfield codebase carried enough interface, coupling and allocation overhead to raise compute resource consumption by 5-8%, which is a cost that shows up on the infrastructure invoice rather than in a code-quality dashboard. Characterise the inflow the way that study did - name the specific recurring patterns - because targeted feedback to the model cut the targeted warnings by 11.1%, and an inflow you have not characterised is one you can only clean up after.
Treating continuous modernization as a replacement for engineering judgment. The agent handles the mechanical work; engineers handle the judgment calls. Some debt items will be flagged by the agent but require human decisions - does this API change affect any downstream consumers? Should this deprecated pattern be replaced or removed entirely? These decisions should escalate to humans, not be made autonomously.
How Different Roles See It
Bob has been running continuous modernization for six weeks. The agent has generated 34 PRs: 28 have been merged, 4 are in review, and 2 were closed because they touched code areas that were in active feature development. The merged PRs have addressed 14 items from the debt inventory - more progress than the team made in the previous year through manual effort. Bob is converting from skeptic to advocate.
The next challenge for Bob is organizational: other teams have heard about this and want to adopt it, but they do not have a structured debt inventory, and their test suites are less reliable than his team's. Bob should create a "continuous modernization readiness checklist" - the prerequisites that teams must meet before enabling an agent-based migration workflow. The checklist is: structured debt inventory with 20+ items, test coverage above 70% in the areas to be migrated, and a designated PR reviewer who commits to the 48-hour SLA. Teams that meet the checklist get access to the shared agent configuration. Teams that do not have a clear improvement path to readiness.
Sarah now has the data she has been waiting for: a clear before-and-after comparison for debt reduction velocity. Before continuous modernization: the team addressed 2 debt items per quarter through manual effort. After continuous modernization: the team is addressing 14 items in six weeks. The engineering time per item has dropped from approximately 40 hours (manual) to approximately 2 hours (review only). That is a 20x productivity improvement on debt reduction specifically.
Sarah should publish this comparison as a case study. It is the clearest possible demonstration of AI maturity ROI, and it will be more persuasive to other teams and to leadership than any abstract argument. She should also start tracking "debt backlog age" - the average age of items in the inventory - as a leading indicator of organizational technical health. As continuous modernization runs, this metric should decline. If it does not, the agent's output rate is not keeping up with new debt creation, which is itself a useful signal.
The stronger version of the case study adds a second number in a currency finance already understands. Alongside items closed and hours saved, Sarah should record the input tokens an agent needs for a representative change in each area of the codebase, before and after the agent works it. The controlled experiment behind this practice reported an 83% reduction on a single decomposed file, roughly $0.40 per change, applying to every subsequent modification of that code. That is an argument for refactoring that does not rely on anyone believing an engineer's intuition about maintainability.
Victor is the one who configured the agent, wrote the task specifications for the debt inventory items, and is the primary reviewer of agent-generated PRs. He has developed a strong sense for the difference between agent output that is clearly safe to merge quickly and agent output that needs careful review. Dependency bumps with green tests: quick merge. API migration in a module with low test coverage: careful review. Framework upgrade touching 300 files: line-by-line review of a sample, test run in staging.
Victor should codify this review heuristic as a written protocol - the "agent PR review guide" for his team. The guide specifies: for each category of agent-generated PR, what is the appropriate review depth? Which categories can be merged by any developer? Which require Victor's review? Which require staging deployment before merge? This protocol scales Victor's knowledge to the entire team and means that when Victor is on vacation, the agent's output does not pile up unreviewed. The protocol is also the foundation for the higher-autonomy configuration at L4, where the lowest-risk categories move from "requires review" to "auto-merge on green CI."
Further Reading
From the Field
Recent releases, projects, and discussions relevant to this maturity level.
How This Guide Changed
What each edition changed in this guide, newest first.
- V1.6September 2026LATEST
Gave the payoff a unit. A controlled experiment running the same feature request against a codebase at 15 successive refactoring stages, with a fresh agent each time to strip out learning bias, found that decomposing a 17,155-line Rust file into 19 files cut the input tokens for that change from 159,564 to 27,360 - an 83% reduction, roughly $0.40 per change, applying to every future modification of that code. The guide now asks teams to baseline the token cost of a representative change per area before and after the agent works it, because that is an investment case a finance function can read without translation. The cost of performing the refactor itself was not precisely tracked, and the guide says so. On the other side of the ledger, a study of 3.52M changes in a large brownfield C++ codebase put the first production-scale price on AI-generated debt: a 5-8% increase in compute resource consumption, moving the problem from the maintainability ledger onto the cloud bill, with targeted feedback to the model cutting the targeted warnings by 11.1%.
- V1.5August 2026
Reworded to put the shift up front - debt stops competing with features, the agent works the inventory and engineers review PRs instead of writing them - rather than approaching it through a definition of what L3 means. The economic case that this framing invites arrived in the next edition.
- V1.3June 2026
June sharpened the vocabulary this guide depends on without changing the guide itself: Agentic Technical Debt as a stock of liability, the Stochastic Tax as the recurring flow-cost of keeping probabilistic agents in bounds. DORA's finding that AI gains collapse to roughly ten percent on complex legacy code also set a realistic ceiling on what a background agent should be expected to recover. Only a source pointer moved here.
- V1.1April 2026
Added the counterweight that AI also creates debt: a 30-41% rise in technical debt within six months of broad AI adoption, 1.7x more issues flagged on AI-authored PRs, and 89.1% of issues in AI commits being code smells. The agent paying off old debt now has to clean up after other agents, so tracking new-debt inflow matters as much as clearing the backlog.
- V1.0March 2026
Shipped in the first edition as the L3 answer to a scheduling problem far older than AI: debt reduction always loses to features because both draw on the same capacity. The guide's proposal was to stop treating it as a project at all - the L2 inventory becomes an agent's work queue, transformations run overnight and at weekends, and the engineering time spent on modernization collapses to review.
Where does your team actually sit on this?
This guide describes one level of one area. Run the assessment to place your team across all 16 areas, see which gates you have passed, and get a report you can take to your stakeholders.
Tech Debt & Modernization