---
name: migration
description: Use when upgrading a framework version, migrating APIs, bumping major dependencies, or any task where "before" and "after" states must be compared. Auto-invoke when user mentions migration, upgrade, breaking changes, or version bumps.
user-invocable: true
title: migration
canonical_url: https://skilld.dev/gh/fubits1/svelte-skills/migration
last_updated: 2026-10-25T14:32:29.000Z
---

> Index of every page on this site: [llms.txt](https://skilld.dev/llms.txt)

> **Skill from skilld.dev.** Follow the user's requested action.
> If the user asked to fork this Skill, follow the fork workflow below. Do not execute the Skill instructions while copying it.
> Otherwise, follow the instructions below for this session. You do not need to install anything.
>
> If the user asked to install this Skill, run `npx skilld install fubits1/svelte-skills/migration`. Install writes the Skill files into the project, so every session loads them.
>
> ## Fork workflow
>
> A fork creates an editable local Skill with its original author and licence. The request authorizes copying and local installation.
> 1. Check `./skills/migration`, the project lockfile, and selected Agent targets together. If the local directory or installed Skill exists, stop. Never overwrite an existing directory or Agent target.
> 2. Read [source metadata](https://skilld.dev/api/v1/skills/fubits1/svelte-skills/migration) once. Use sourceUrl, sourceCommit, skillPath, sourceGone, and license. If the source is gone or its path is missing, stop. If license is null, read licence files at the source commit.
> 3. Fetch only the source commit into a temporary Git repository. Do not clone full history. Derive repository_url from sourceUrl, including repository renames. If sourceCommit is absent, resolve the sourceUrl ref once. Set source_commit to that actual commit. Run these commands in one shell call:
>
> ```sh
> git init --quiet "$temporary_dir"
> git -C "$temporary_dir" fetch --quiet --depth=1 "$repository_url" "$source_commit"
> git -C "$temporary_dir" checkout --quiet --detach FETCH_HEAD
> ```
>
> Read applicable licence declarations and notices at that commit. If copying is not permitted, report the restriction and stop.
> 4. Inspect source entries together, then copy the directory containing skillPath into `./skills/migration`. Use the user's path if selected. Keep the original SKILL.md, relative links, scripts, binary assets, and executable modes. Exclude .git metadata. Reject symlinks and paths outside the Skill directory. After checking entries, use cp -a where available. A regular source directory needs no custom copy script. Do not save this page wrapper as SKILL.md.
> Preserve author credit, notices, and applicable licence files from repository or parent directories. Add PROVENANCE.md with the Skill page, source URL, actual commit, original path, and licence. Retain any existing PROVENANCE.md and record new provenance separately. Batch source inspection, copying, and provenance work where practical.
> 5. In the project root, run `skilld install ./skills/migration --mode copy --plain`. If skilld is unavailable, use `npx skilld install ./skills/migration --mode copy --plain`. This known command needs no help lookup. Install does not support --json. Use detected Agent targets, or add --agent for the targets the user selected. Install the local path, never the upstream selector. If installation fails, preserve the local copy and report the exact failure.
> 6. Confirm the local lockfile source and installed Agent copies once. Report the local path, actual commit, and Agent targets. After edits, reinstall the same local path. Upstream updates must not replace it. Do not publish or push unless the user asks.

# Migration

Framework upgrades, major dep bumps, config migrations. The core challenge is proving zero regressions, which requires baselines captured on the TRUE pre-change state.

## Rule Zero: Check Working Tree FIRST

Before planning, researching, or writing anything:

```bash
git status
git diff package.json
```

**If `package.json` is already modified**, deps may already be upgraded. Baselines taken now reflect post-upgrade state and are WORTHLESS for comparison. You must restore old deps before capturing baselines (see Phase 3a).

**If `package.json` is clean**, capture all baselines before touching it.

This is non-negotiable. Baselines on upgraded deps cannot prove zero regressions. Ask yourself: "What state was the code in BEFORE any migration work started?" That is the state you baseline against.

## Phase 1: Research

**REQUIRED:** Use `agent:research` skill. All four channels, local investigation, docs/MCPs, online research, verify and synthesize.

For each breaking change found in the migration guide, grep the codebase to check if it applies. Don't assume, verify.

**Output:** A list of concrete changes needed, with file paths and line numbers.

## Phase 2: Ask Before Assuming

Do NOT assume version numbers (.nvmrc, TypeScript, etc.), which config blocks to keep or remove, or whether a deprecated pattern should be cleaned up. ASK.

## Phase 3: Baseline Capture

### 3a: Restore Pre-Upgrade State (if deps already changed)

```bash
git stash
pnpm install
# verify project builds with OLD deps
```

### 3b: Capture Baselines

1. **Build output**: full log, page count
2. **Sitemap**: copy XML files, extract every `<loc>` URL to flat list
3. **Screenshot every route**: Playwright MCP, every sitemap URL, assert no console errors
4. **Measure page sections**: per `frontend:pixel-perfect`: `getBoundingClientRect()` on every visible section, save as JSON
5. **Run existing tests**: save output, record pass/fail counts

### 3c: Restore Upgraded State

```bash
git stash pop
pnpm install
```

## Phase 4: Write Regression Tests BEFORE Code Changes

Existing tests probably don't cover all routes. Write new tests that:

1. **Route coverage**: read sitemap dynamically, navigate every URL, assert each loads with content
2. **Section coverage**: assert each page section exists and is visible
3. **i18n coverage**: test both language variants

Run new tests, they must pass on current state BEFORE any migration edits.

## Phase 5: Make Changes

Per `frontend:validate`: edit ONE file, validate (build + lint + type-check), confirm 0 new errors, then next file. Never batch edits without validating between them.

## Phase 6: Post-Migration Verification

Per `agent:done`:

1. **Build**: page count must match baseline
2. **Sitemap diff**: must be identical to baseline URLs
3. **Run ALL tests**: old + new regression tests
4. **Screenshot every route**: compare to baseline
5. **Measure sections**: per `frontend:pixel-perfect`, report diff table, 0px diff required
6. **Full validation**: lint, type-check, svelte-check, exit 0
7. **Report with proof**: exit codes, page counts, sitemap diff, test results, measurement table

## Referenced Skills

Not optional during migration:

- `agent:research`: Phase 1
- `frontend:pixel-perfect`: Phase 3b and 6 measurements
- `frontend:validate`: Phase 5 per-file validation
- `agent:done`: Phase 6 completion checklist
- `frontend:playwright`: all browser verification

## Anti-Patterns

These are real failures from an actual migration attempt:

| Failure                                        | Why It's Wrong                                                        |
| ---------------------------------------------- | --------------------------------------------------------------------- |
| Taking "before" baselines after deps upgraded  | Baselines reflect post-upgrade state, comparison is meaningless      |
| Assuming version numbers instead of asking     | User wanted Node 24, not 22. ASK.                                     |
| "Run build and check browser" as verification  | Proves nothing about regressions without baselines to compare against |
| Not using sitemap as route source of truth     | Guessing at routes misses pages                                       |
| Not writing new tests before migration         | If existing tests don't cover all routes, regressions slip through    |
| Batch-editing files without validating between | Impossible to tell which change broke what                            |
| Skipping section measurements                  | Screenshots alone prove nothing per pixel-perfect                     |
| Not checking `git status` first                | Led to worthless baselines                                            |

## Reference: Example Plan (Astro 5 to 6)

```markdown
# Astro 6 Migration Plan

**Current state (from `git diff package.json`):**

- package.json is MODIFIED but NOT committed
- Old (committed): Astro 5.17.3, TS 5.9.3, Svelte 5.53, vite-plugin-svelte 6.2.4
- New (working tree): Astro 6.1.2, TS 6.0.2, Svelte 5.55.1, vite-plugin-svelte 7.0.0
- pnpm-lock.yaml also modified

**Implication:** Baselines MUST be captured after git stash restores old deps.

### Task 0: Restore old deps for baseline capture

- [ ] git stash (save upgraded package.json + lockfile)
- [ ] pnpm install (restore old lockfile)
- [ ] pnpm astro build — verify project builds with old deps

### Task 1: Capture baselines on OLD deps

- [ ] Build: save full log, record exact page count
- [ ] Sitemap: copy all XML files, extract every <loc> URL to flat list
- [ ] Screenshots: every sitemap URL via Playwright, assert no console errors
- [ ] Sections: measure every visible section via getBoundingClientRect(), save JSON
- [ ] Tests: run existing tests, save output, record pass/fail counts

### Task 2: Restore upgraded deps

- [ ] git stash pop
- [ ] pnpm install
- [ ] pnpm astro build (verify still works)

### Task 3: Write regression tests BEFORE code changes

- [ ] tests/routes.spec.ts — sitemap-driven, every URL, assert loads with content
- [ ] tests/sections.spec.ts — homepage sections + detail pages (DE+EN)
- [ ] Run all tests — must pass before any migration edits

### Task 4-7: Code changes (one file, validate after each)

- .nvmrc: update version (ASK which — don't assume)
- content.config.ts: z import from astro:content → astro/zod
- content.config.ts: deprecated Zod validators → Zod 4 equivalents
- astro.config.mjs: remove stale config blocks (ASK which — don't assume)

### Task 8: Post-migration verification

- [ ] Build: page count matches baseline exactly
- [ ] Sitemap diff: identical to baseline URL list
- [ ] All tests pass (old + new)
- [ ] Screenshot every route, compare to baseline
- [ ] Measure sections, compare to baseline (0px diff required)
- [ ] Full validation (lint, type-check, svelte-check) exits 0
- [ ] Report with proof: exit codes, page counts, sitemap diff, test results, measurement table
```
