Writing a Migration Guide for a Major Version

A changelog tells people what changed. A migration guide tells them what to do about it, in the order they will hit it. Most upgrade pain is not caused by the breaking changes themselves but by having to reverse-engineer them from commit history. This tutorial walks through producing a migration guide for a hypothetical library, Package B, moving from 3.x to 4.0.

Step 1: Build an inventory from the diff, not from memory

Start with the public surface. Compare the exported names, function signatures, configuration keys, CLI flags, environment variables and supported runtime versions between the last 3.x tag and the 4.0 release branch. For typed packages, diffing the generated declaration files (.d.ts, .pyi stubs) is a quick way to catch signature changes you forgot. Every difference goes into a spreadsheet or a plain list, even ones you believe nobody uses.

Step 2: Classify each change

ClassWhat it means for the readerHow to present it
RemovedCode fails immediatelyName the replacement or say there is none
Renamed / movedMechanical find-and-replaceOld name, new name, ideally a codemod
Behaviour changedCode runs but gives different resultsBefore/after example plus how to detect it
Default changedSilent difference unless configuredShow the option that restores the old default
Environment droppedInstall or runtime errorsMinimum versions, stated once at the top

"Behaviour changed" and "default changed" deserve the most words. They are the ones that pass the type checker and reach production.

Step 3: Order by when the reader will hit it

Readers upgrade top to bottom. Put environment requirements first, because nothing else matters if installation fails. Then import and configuration changes, then API changes grouped by feature area, then subtle behavioural differences. Within each group, lead with the change that affects the most users.

Step 4: Write each entry in the same shape

Consistency lets people skim. For Package B we use four parts: a one-line summary, why it changed, a before/after snippet, and how to check you are done.

### `createClient()` no longer reads `PKGB_TOKEN` automatically

Why: implicit environment reads surprised users running several clients.

Before (3.x):
  const client = createClient();

After (4.0):
  const client = createClient({ token: process.env.PKGB_TOKEN });

Check: search your code for `createClient()` called with no arguments.

The "why" line is short but important. People accept breaking changes far more readily when the reason is stated.

Step 5: Offer a bridge release where you can

If it is practical, publish a final 3.x minor that emits deprecation warnings for everything removed in 4.0. Users can then upgrade to the bridge release, fix every warning while still on a compatible version, and make the jump with fewer surprises. Link the migration guide from each warning message.

Step 6: Test the guide

  1. Take a small real consumer of your package, such as an example app or an internal project.
  2. Follow the guide literally, with no extra knowledge.
  3. Note every point where you had to guess, and fix the guide, not the example.

Common mistakes

For the versioning rules behind this, see our semver edge cases FAQ.

Related pages