Skip to content
All writing

Agentic delivery · Part 2 of 5

Coding With Agents: Boundaries, Checks and Context

Setting up agent coding work so it comes back as something you would merge, including on legacy .NET and Angular code.

AIAgentic deliveryDevelopment

Once the spec is clear, an agent can write a surprising amount of working code. The question for a delivery team is not whether to let it, but how to set up the work so that what comes back is something you would merge from a careful colleague.

This is the second of five notes on agentic delivery in the software development lifecycle.

Give each task its own branch and its own boundary

Treat every agent task as a unit of work with a clear edge: one branch, one purpose, one pull request. It keeps changes reviewable and makes it easy to discard a run that went the wrong way without disturbing anything else.

It also makes parallel work possible. Several agents can work on separate, well-bounded tasks at the same time, as long as the tasks really are separate. When two tasks touch the same files, the merge conflict is the least of the problems; the bigger one is two agents making different assumptions about the same code. Check for overlapping work before starting, the same way a lead would before handing out tickets.

Let the agent run the checks itself

An agent that can run the build, the linter and the tests locally will catch most of its own mistakes before a person sees them. An agent that cannot will hand you code that only looks right.

So give it the same fast checks a developer would run: the unit tests for the area it is changing, the type checker, the formatter. Make the commands obvious in the repository instructions. Ask for evidence in the pull request, such as the test output, rather than a statement that the tests pass.

One rule matters more than the rest: an agent must not make a failing test pass by weakening the test. Skipping it, loosening an assertion or deleting it to get a green build is the easiest path to "done", and agents will take easy paths. Say plainly in the repository instructions that this is not allowed, and look for it in review.

Legacy code needs more context, not less

Agents tend to do best on clean, modern, well-tested code, and that is exactly the code that needs the least help. Business-critical systems are often the opposite: older .NET services, a front end that predates current Angular, business rules that live in stored procedures and in one person's memory.

On code like that, the agent needs more of the context a senior developer would carry in their head:

  • which parts are load-bearing and must not change behaviour, even if they look odd
  • which wire contracts other systems depend on
  • where the tests are thin, so that a passing build means less than usual
  • which modernisation direction the team has chosen, so the agent does not invent its own

Writing this down is useful well beyond the agent. It is the same knowledge a new team member needs, and it is usually the knowledge that walks out of the door when someone leaves.

Characterisation tests first

When an agent is asked to change legacy behaviour, a good first step is to have it write tests that pin down what the code does today, before changing anything. These characterisation tests are not a statement that the current behaviour is right; they are a record of it. They turn a risky edit into a visible one: if a test changes, the behaviour changed, and someone has to agree that it should.

Review the diff, not the story

Agents usually explain what they did, and the explanation is usually fluent. It is also not the change. Review the diff itself, run it, and check it against the acceptance criteria in the spec. A confident summary of a change is worth exactly as much as the code underneath it.

The next note in this series is about that review step: how to review and test code that an agent wrote, including using a second agent as an adversarial reviewer.

Responsible for a business-critical system?

If it is an inventory or build-out system that has become hard to change, the Inventory Data Health Check turns it into a plan with a switch-off date.