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
| Class | What it means for the reader | How to present it |
|---|---|---|
| Removed | Code fails immediately | Name the replacement or say there is none |
| Renamed / moved | Mechanical find-and-replace | Old name, new name, ideally a codemod |
| Behaviour changed | Code runs but gives different results | Before/after example plus how to detect it |
| Default changed | Silent difference unless configured | Show the option that restores the old default |
| Environment dropped | Install or runtime errors | Minimum 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
- Take a small real consumer of your package, such as an example app or an internal project.
- Follow the guide literally, with no extra knowledge.
- Note every point where you had to guess, and fix the guide, not the example.
Common mistakes
- Linking to the changelog instead. A changelog is chronological; a migration guide is task-ordered.
- Hiding the guide. Put it in the repository (for example
docs/migrating-to-v4.md), link it from the release notes, the README and the changelog entry. - Forgetting transitive users. If plugins or wrapper packages depend on you, give their authors a section of their own.
- Editing after release without notice. Corrections are fine; mark them with a short "updated" note so people who already migrated can check.
For the versioning rules behind this, see our semver edge cases FAQ.