Legacy refactoring

AI imitates what it sees, so repay tech debt and show examples before unleashing it.

Slide 98 — Refactoring ➞ Dare!

  • Label the patterns AI detects as good vs crap: garbage in, garbage out.
  • Finish half-done migrations — two failed re-architecture attempts side by side, and the agent copies both.
  • Show, don’t tell: polish one slice of a million-line monster with an agent as ≈100 conventional commits, hand that chain over as the example, then “agent, do the rest”. ⚓ mowing the lawn
    • or point at the company’s one impeccable hexagonal repo
  • Use a parsed call graph, not text search: on VetRepository.findById the IDE finds 3 references, grep finds 71.
  • Mass changes go through OpenRewrite recipes, syntax-safe.
  • In legacy the agent fills its context fast: spawn subagents with fresh context.
  • Constrain monster PRs: SQL stays byte-identical — cut and pasted, never reinvented — checked adversarially (→ Adversarial review).
    • frontier only: Opus high/xhigh, Fable reviewing, never Sonnet (→ Model seniority)

See also: OpenRewrite recipes · Testing with agents · Model seniority · Home Source: Responsibly Dimming the Lights in the Software Factory @ Devoxx Belgium, Day 1 (6 Oct 2026) — section Legacy refactoring (2:26:08)