series · from legacy to agent-ready · post 0

Why This Series Exists: From Legacy to Agent-Ready

The problem

Most writing about coding with agents starts from an empty folder. Write the specification, generate the code, admire the result. It is a fine way to learn the ideas and a useless way to run a company, because almost nobody's code lives in an empty folder. It lives in a service that has been in production for six years, has a test suite that half the team ignores, and depends on a cron job that nobody has dared to touch since the person who wrote it left.

Point an agent at that service, and one of two things happens. Either the team reads every line the agent produces, in which case the agent has saved nothing, or the team does not, in which case the first bad change reaches a customer. Most teams try the first for a month, then quietly go back to writing the code themselves and using the agent for autocomplete.

The gap is not the model. The gap is that the codebase cannot tell anyone, human or agent, when a change is wrong.

None of this is new. A codebase that cannot tell you when a change is wrong was always a problem. The tests nobody trusted, the boundaries nobody wrote down, the deploy that needed a person watching: all of it was there before the agents. What changed is the pace. When writing code was slow, it hid everything downstream. A team could only produce so many changes a week, and review, testing, and release kept up, more or less. Now an agent produces a week's worth of changes before lunch, and the steps that were always slow are suddenly the only thing anyone can see.

Andy Hunt and Dave Thomas gave us the other half of the picture in The Pragmatic Programmer, borrowing the broken windows theory: one broken window left unrepaired tells everyone that nobody cares, and the decay spreads from there. In most legacy codebases, the windows were already broken. They were just in the parts of the building nobody walked past: the test suite people had stopped reading, the module everyone routed around, the release checklist that lived in one person's head. Agents walk past every window, every day. They read the whole codebase, take what they find as the house style, and repeat it at the speed they write. A broken window an agent has seen is no longer one broken window. It is the pattern for the next fifty changes.

Eliyahu Goldratt described this forty years ago in The Goal. A system's throughput is set by its constraint, its one slowest step, and speeding up any other step does not make the system faster. It only piles up work in front of the constraint. For most of the history of software, the constraint looked like writing code, so that is where we put our effort: better languages, better editors, better frameworks. Agents removed that constraint almost overnight, and the constraint moved to where it had been hiding all along: understanding, verifying, and releasing a change. The pile of work in front of it is the queue of agent-written merge requests that nobody has had time to read.

Goldratt's answer still applies, step for step. Find the constraint. Get the most out of it before you add anything. Make everything else serve it. Only then widen it, and look for where it moves next. A faster model widens a step that is no longer the constraint. Raising the codebase's capacity to verify a change widens the one that is. In one line: autonomy is bounded by verification capacity, not by generation capacity.

There is very little that is truly new in software engineering. The practices that make a codebase safe for an agent are the ones that made it safe for a new team member: tests at the right boundary, contracts, written reasons, a pipeline that fails when something is wrong. What is new is that skipping them now costs you every day instead of every quarter. This series is about closing that gap, on code that already exists, one step at a time.

Who this is for

You should read this series if:

You will get the most out of it if you have shipped production software and have, at least once, been afraid to change something that worked.

The thesis

You can trust an agent exactly as far as your codebase can verify its work. Put more shortly: autonomy is bounded by verification capacity, not by generation capacity. Not as far as the model is clever, and not as far as your prompt is detailed. As far as the repository and the runtime can tell a wrong change from a right one without a person in the loop.

So the way to get an agent to do most of the work is not to find a better agent. It is to raise the codebase's capacity to verify a change: tests that would survive a rewrite, contracts a change cannot cross, rules and reasons written where the agent reads them, a pipeline where every check fails the build, and a production environment that notices a bad release and reverses it. Build those, in the right order, and the agent's autonomy rises with them. Skip them, and no model will ever be good enough.

The destination is a codebase where engineers move from in the loop to on the loop. They stop approving each change before it merges and start supervising the system that approves it: they own the rules, the checks, and the gates, sample the stream, and step in on the changes that matter. On Dan Shapiro's widely shared five-level scale, that is Level 4, where you review plans and test results, not diffs. Other ladders give it other numbers; Pedro's Law maps them. The numbers disagree. Who is in the loop does not.

In rough numbers, across a codebase, engineers hand-write about a fifth of the code and read about a fifth of the changes, and the rest ships on evidence. That is an average, not a quota. The code that moves money or guards security may still be written and reviewed entirely by people. A well-fenced adapter may be written and checked entirely by agents. The fifth is what you get when you add up a codebase where each part sits where its risk says it should.

What this series is not

It is not about greenfield projects. It starts from code that exists and runs.

It is not a deep treatment of regenerative software or the Phoenix Architecture, Chad Fowler's essays on software you can delete and rebuild from what you wrote down about it. I borrow a few ideas from his series, because they are the right names for what has to be written down. The rest of that body of work is for another day.

This isn't about evolving the architecture once the codebase is ready. That is a question I care about a great deal, and it deserves its own treatment. This one stops at the moment you can trust the agent with the codebase as it is.

And it is not a tooling guide. I have written tools for this kind of work, and I will say so where it matters, but the aim is that you can do each step with whatever agent and whatever pipeline you already have.

How to read it

Think of it as a staircase. Each step should leave you with something you can check on your own codebase, so you know whether you have actually climbed it, and the steps come in an order that the work itself imposes more than I do.

Everything is per component, not per company. A codebase on this path has some components that have earned trust and others that have not, and the team knows which is which. Pick one component, climb with it, then pick the next.

I will write from what happened on real codebases, told without names, and I will try to end each piece with what I would do in yours.

Why me

I spent my first fifteen years in software learning the craft, and the last fifteen helping teams master it, first by hand and now with agents. The dated record is on LinkedIn; the short version follows.

The work, by hand. Full time since 2014, when I joined Codurance as a Principal Consultant and started doing this on other people's production systems: seams, characterization tests, contracts, decision records, one component at a time, with the code of a team that was still shipping around me. Embedded in the teams at Société Générale in London. Two years at ASOS on warehouse, logistics, and web platforms. A migration strategy from an e-commerce monolith to a distributed cloud system at Mango. Then a year back at ASOS as a principal engineer on orders, bag, pricing, and promotions. Then, through the company I co-founded, I did technical coaching at Wallapop and led architecture at Iberia. I used the method in the legacy-code chapters of Agile Technical Practices Distilled, and I still use it.

The work, with agents. At Vista, a large company where I am a Distinguished Engineer, and at Refine, a small startup where I am the senior engineering advisor, I led major refactors of existing codebases. In each case, the first move was not the refactor. It was bringing the codebase to a state where agents could work on it safely, and only then letting them do most of the typing. At Refine, the starting point was a Python command-line prototype written by two economists, domain-rich and without the engineering foundations to scale; in three months, with a team of one to three and agents driving every step, it became a distributed, highly available cloud system, and the tests and the architectural boundaries were what made each jump survivable. At Vista, I also co-authored the framework that defines engineering excellence for the entire engineering organization, drafted its testing rubric, and wrote a set of agent skills that run the legacy-code workflow end to end. I wrote Pedro's Law, the rule for how code gets generated from an approved specification.

Teaching and speaking. I am the principal author of Agile Technical Practices Distilled (Packt), with Marco Consolaro and Alessandro Di Gioia. At Codurance, I redesigned its apprenticeship program and ran its first iteration. I maintain kata starter kits for legacy-code practice in nine languages, and I built a three-day workshop on building, repairing, and evolving software with agents, which I have run three times at Vista with three different teams. I have been speaking at conferences and software engineering communities across Europe since 2014: SoCraTes in the UK, Germany, Belgium, Italy, and Spain; Software Crafters Barcelona and Pamplona; DDD Europe, KanDDDinsky, Agile Spain, Agile Portugal, SPA, I T.A.K.E. Unconference, Code Freeze, and the Barcelona and London software crafters meetups before that. Most recently, I gave a talk on Pedro's Law at Software Crafters Barcelona 2026.

I do not think any of that makes me right. I think it means I have made most of the mistakes this series warns about, on real systems, and paid and learned from most of them. That is what I have to offer.

What's next

The first post defines legacy for the age of agents, and shows why a tested codebase with high code quality can still be legacy by that definition. Start there.

Let's make it engineering.

Sources

How this was written: I used AI heavily to draft, edit, and polish this article. The ideas are mine, and so is the responsibility for every word. Why I am unapologetic about it.

Want help taking your codebase there?

Let's talk