Track 03 · Agents & toolsLesson 12 of 12

Coding agents in someone else's codebase

Use coding agents to change a legacy system safely: characterise first, then migrate in slices.

What you'll be able to do

What you'll be able to do

01
  • Read an unfamiliar repository: entry points, data flow, owners, the tests that exist, and whether the source matches what runs in production.
  • Write characterisation tests from recorded inputs and outputs before changing anything, and read what their diffs say.
  • Parse fixed-width records from a copybook, with implied decimals and COBOL's rounding.
  • Plan a strangler-fig migration in slices, each with a parallel run and a cutover gate.
  • Set guardrails for a coding agent (sandbox, least-privilege credentials, pull requests only, test gates, reviewers) and measure what it delivers.
Before you start

Before you start

Starting here? This lesson anchors the AI coding and modernisation elective. Two terms used throughout: a characterisation test records what a system does today, right or wrong, and fails when anything changes; the strangler fig replaces a system one piece at a time, routing each piece to the new code once it's proven, until the old system has nothing left to do.

The short version

The short version

Modernisation projects fail on behaviour nobody wrote down: a rounding rule, a patch applied in production and never merged back, an edge case a downstream report depends on. A coding agent doesn't change that; it makes it easier to produce a lot of plausible code that has the same blind spots, faster. So the order of work matters more, not less.

First, read the repository the way its owners do: what runs, in what order, reading and writing what, owned by whom, tested how. Second, characterise: capture real inputs and outputs from the running system and write tests that replay them against your new code, record by record. Third, migrate in slices: one program or one rule at a time, run in parallel with the old system until the outputs match for long enough, then cut over and switch the old piece off. The agent works inside that structure: in a sandbox, on a branch, through pull requests the customer's engineers review, with the characterisation run as a gate it can't skip. Measure it on merged changes and defects found later, not on lines written.

  • Characterise before you change. The recorded output is the specification, including its bugs.
  • The source isn't always what runs. Compare the library with production behaviour before trusting either.
  • Small slices, parallel runs. Each slice is proven against the old system before anything depends on it.
  • The agent proposes, the owners merge. Branch, pull request, required checks, a human reviewer.
  • Know your sandbox. Every product draws its boundary differently; read what it covers.

Pro lesson

The rest of this lesson is in Pro.

The mental model, worked example, field note, failure table, exercise and self-check, with the voice tutor.

  • Every stage and specialisation, in full
  • Every lab and every role project
  • Halden weeks 2–10, on your record
  • Every drill, live in the playground
  • All solutions, plus the server judge
  • Lab Assistant and every Teach with AI