Migrating to LVD Without a Big-Bang Branch

The restructuring branch has been open for six weeks. It touches two hundred files, it conflicts with main every morning, and the feature team has stopped merging anything near it. Everyone agrees the new layout is better. Nobody can ship it. Migration patterns exist because a codebase that must keep delivering cannot also stop for a rewrite.

Move, leave a signpost, delete when nobody visits

The book names the strangler fig as the main strategy for adopting LVD. The name comes from a vine that grows around a tree until the tree is no longer needed. In code terms, the new layered structure grows beside the old one, callers move across one at a time, and the old structure is removed once it is empty.

The unit of work is a single component. Say a ticketing service keeps its seat-label formatting in src/helpers/seats.ts, and you are moving it into the Utils layer. The sequence has four small moves, each of which leaves the build green:

  1. Create the function in its new home and copy its tests with it.
  2. Turn the old file into a signpost that re-exports from the new location.
  3. Switch callers to the new path in small pull requests, whenever each team gets to it.
  4. Delete the signpost when nothing refers to it.
// src/helpers/seats.ts: old address, kept alive only for stragglers
/** @deprecated import from "@tix/utils/seating" */
export { formatSeatLabel } from "@tix/utils/seating";

The signpost is the whole trick. Because it forwards rather than duplicates, there is never a second copy to drift out of date, and nobody is forced to update their imports on the day you move the code. The system holds a mixture of migrated and unmigrated pieces at every point, and the tests pass throughout.

Close the old door to newcomers

A signpost has one weakness: people keep walking through it. A new feature written next week will copy an import from a neighbouring file, and the old path will gain a customer faster than you remove them.

The fix is a ratchet. Add a lint rule that forbids the old path in new code, so the number of references can only go down:

"no-restricted-imports": ["error", {
  patterns: [{ group: ["**/helpers/seats"], message: "Moved to @tix/utils/seating" }],
}]

Existing imports can be allowed temporarily with a per-file exception, and each exception is a line you delete as callers migrate. The count of exceptions is now a progress bar that anyone can read, and the day it reaches zero you delete the signpost. This is general practice rather than something the book prescribes, but it is the difference between a migration that ends and one that lingers for years.

A rollback switch you must also retire

Moving a pure helper is low risk. Replacing the code that talks to a payment provider is not. For changes like that, the book recommends feature flags, which let a migrated path take real traffic gradually and give you a way back that takes seconds rather than a redeploy. It singles out the Resources and Tools extractions as the places where behavioural regressions are most likely.

const client = flags.isOn("new-payments-resource") ? paymentsResource : legacyPayments;
const receipt = await client.charge(order);

The part teams skip is the other half of the lifecycle. A migration flag has a built-in end date. Once the new path is at full traffic and stable, the flag and the legacy branch behind it are dead weight, and every stale flag doubles the paths a reader must hold in their head. Give each flag an owner and a removal date when you create it, and treat an expired flag as a defect.

The takeaway

Keep every step small enough to merge today: relocate behind a signpost, block new traffic to the old address, and attach an expiry to every temporary switch. The book adds two more patterns and ties all four to its nine-step roadmap; the planning behind that is covered in the roadmap article, and the two usual starting points in migrating from monoliths and microservices. For checking the layer rules themselves along the way, see lvd-lint.

What the book covers

  • Branch by abstraction, and why it suits the Resources layer
  • Canary deployments with quantitative rollback criteria
  • Which of the four patterns the book matches to which roadmap steps
  • A staged percentage rollout for flagged code paths