Skip to main content

Use case · safe migrations

Migrate a Legacy Codebase with AI Agents

Use AI agents to migrate legacy codebases, Next.js Pages Router → App Router, Express → Fastify, Python 2 → 3, Java 8 → 21, AngularJS → React. Stepwise, test-backed, low-risk. Skills-hub recipe with Claude Code sub-agents.

Short answer

Install the `migrate-safe` composition. Run it against your repo with the target framework/language as the argument. The agent generates a migration plan, applies it incrementally per file or module, runs tests after each batch, and halts on failure. Best with Claude Code sub-agents, parallel sub-agents migrate independent modules simultaneously.

Migrations are where teams discover what their codebase actually depends on. The 2026 best practice: AI agents do the rote rewriting; humans do the judgment calls. Below is the canonical recipe, install one composition, point it at the migration target, let it work file-by-file with tests as the safety net.

Step-by-step

  1. 1

    Install the migration composition

    migrate-safe + the migrate sub-skill. Together they handle framework upgrades, language version bumps, and library swaps.

    $ npx @skills-hub-ai/cli install migrate-safe
  2. 2

    Run a dry-run analysis

    First pass produces a migration plan: file-by-file changes, dependencies between modules, estimated breakages. Review it before running the actual migration.

  3. 3

    Migrate one module at a time

    On Claude Code with sub-agents, fan out across independent modules. On other tools, run sequentially. Each module migration is its own commit + test run.

  4. 4

    Run the full test suite between batches

    After every 5-10 file batch, the agent runs the test suite. On failure, halt and report; don't auto-fix. Migration failures usually need human judgment.

  5. 5

    Hand off the remaining 10-20%

    AI handles 80-90% of routine migrations. The last 10-20%, gnarly edge cases, business-logic-sensitive paths, untested code, is for a human. That's where the time savings compound.

Skills installed in this recipe

Frequently asked questions

What kinds of migrations work well?

Framework upgrades (Next.js Pages → App Router, Express → Fastify, Vue 2 → 3, React 17 → 19), language version bumps (Python 2 → 3, Java 8 → 21), library swaps (Moment.js → date-fns, Redux → Zustand), and codemods (TypeScript strict mode, ESLint config upgrades).

What doesn't work well?

Database schema migrations (use the migration-verify skill instead), undocumented business logic, code without tests (build a test suite first, then migrate). Anything where 'we used this trick because of a 2017 bug' lives un-commented.

How long does a typical migration take?

Small library swap: 1-3 hours including review. Framework upgrade (Next.js Pages → App Router for a 200-page app): 2-3 days. Language version bump on 100K LOC: 1-2 weeks.

Risk of regressions?

Real but bounded by your test coverage. The agent never auto-fixes test failures, if a test breaks after migration, it halts and surfaces the diff. Worst case: you get more PRs to review, never silently broken code.

Which AI tool is best for migrations?

Claude Code's sub-agents excel at multi-file migrations because each sub-agent gets fresh context per module. Cursor's Composer handles single-module migrations well. Cline's per-step approval is the safest option but slower.

Related use cases

Browse 4,900+ skills in the catalog

Free, MIT, works in every major AI coding tool.

Browse the catalog →