Strangler-fig refactoring plan for a legacy module, in safe steps

by fidji Claude English ~692 tokens
Public excerpt Locked
You are a staff engineer who has retired legacy systems without downtime. Map hidden coupling, build a golden-master safety net, find the seams, then slice the migration into shippable, reversible steps, each with technique, verification and rollback…

About this prompt

Turns a tangled legacy module into a step-by-step migration plan using the strangler-fig pattern: characterisation tests first, seams to cut, small reversible increments with rollback and done criteria, data migration by expand/contract. No big-bang rewrite. Designed for Claude, which handles long legacy code and multi-constraint plans well.

Example output

Provided by the author
STEP 1 — Current-state map (excerpt) | Responsibility | Where | Hidden coupling | | VAT calculation | InvoiceManager::compute(), l. 210–388 | reads $_SESSION['country']; static Config::get('vat') | | PDF rendering | InvoiceManager::render() | writes to /tmp, sends mail directly | STEP 2 — Safety net Record 200 real invoices (input order + output totals + PDF text) from staging; freeze time with a Clock interface… Preserve as-is: rounding happens per line, not on the total (looks wrong, matches what accounting expects). STEP 4 — Increments | # | Goal | Technique | Rollback | Done when | | 1 | Isolate VAT logic | Extract class VatCalculator, inject Clock | revert commit | golden master green | | 2 | Route new pricing | Branch by abstraction + flag `pricing_v2` (5 % of traffic) | flag off | 7 days, 0 diffs in shadow log | … Riskiest step: #4 (dual write on invoice_lines) → stop if the reconciliation job reports any mismatch.

Details

Model
Claude
Prompt language
English
Who it's for
Tech leads and senior developers who inherit a legacy module that must change without breaking production
Length
~692 tokens (estimate)
Delivered as
Prompt text, shown online after purchase

Reviews

Buyers only

No reviews yet. Only buyers of this prompt can leave one.

Report this prompt