่ทณ่‡ณไธป่ฆๅ†…ๅฎน
ๅฐ้พ™่™พๅฐ้พ™่™พAI
๐Ÿค–

Migration Compass

Universal migration planner for any swap โ€” framework to framework, library to library, language to language, database to database. Generates a step-by-step m...

ไธ‹่ฝฝ46
ๆ˜Ÿๆ ‡0
็‰ˆๆœฌ1.0.0
ๅผ€ๅ‘ๅทฅๅ…ท
ๅฎ‰ๅ…จ้€š่ฟ‡
๐Ÿ’ฌPrompt

ๆŠ€่ƒฝ่ฏดๆ˜Ž


name: migration-compass version: 1.0.0 description: > Universal migration planner for any swap โ€” framework to framework, library to library, language to language, database to database. Generates a step-by-step migration path with rollback points, parallel-run strategies, and the exact order to change things so nothing breaks in the middle. Because "we'll migrate gradually" is not a plan. author: J. DeVere Cooley category: everyday-tools tags:

  • migration
  • planning
  • upgrades
  • transitions metadata: openclaw: emoji: "๐Ÿงญ" os: ["darwin", "linux", "win32"] cost: free requires_api: false tags:
    • zero-dependency
    • everyday
    • architecture

Migration Compass

"Every failed migration has the same obituary: 'We started replacing everything at once, got halfway, ran out of time, and now we have two systems.'"

What It Does

You need to migrate. Maybe it's Express โ†’ Fastify. Maybe it's JavaScript โ†’ TypeScript. Maybe it's MySQL โ†’ PostgreSQL. Maybe it's React class components โ†’ hooks. Maybe it's a monolith โ†’ microservices.

You know where you are. You know where you want to be. You don't know the safe path between them โ€” the order that lets you change incrementally, validate at each step, and roll back if something goes wrong, all while keeping production running.

Migration Compass generates that path.

The Migration Model

Every migration follows the same fundamental structure, regardless of what's being migrated:

STATE A (current) โ”€โ”€โ”€โ”€โ”€โ”€ TRANSITION โ”€โ”€โ”€โ”€โ”€โ”€ STATE B (target)
                    โ”‚
                    โ”œโ”€โ”€ Parallel Run Zone (both states coexist)
                    โ”œโ”€โ”€ Rollback Points (safe places to reverse)
                    โ”œโ”€โ”€ Validation Gates (proof each step worked)
                    โ””โ”€โ”€ Strangler Boundary (old โ†’ new interface)

The Three Migration Laws

Law 1: Never Big-Bang Change one thing at a time. Validate. Proceed or roll back. A migration that requires changing everything simultaneously is not a migration โ€” it's a rewrite disguised as a migration.

Law 2: Parallel Before Replace The new system must run alongside the old system before it replaces it. You need proof it works in production before you remove the old one.

Law 3: Every Step Must Be Deployable At no point during the migration should the codebase be in a state that can't be deployed to production. Every commit is a valid checkpoint.

Migration Types

Type 1: Library Swap

Replace one library with another (same language, same purpose)

Example: moment.js โ†’ date-fns

COMPASS ROUTE:
โ”œโ”€โ”€ Step 1: AUDIT
โ”‚   โ”œโ”€โ”€ Find every import of moment (grep analysis)
โ”‚   โ”œโ”€โ”€ Catalog every moment function you use
โ”‚   โ”œโ”€โ”€ Map each moment function โ†’ date-fns equivalent
โ”‚   โ””โ”€โ”€ Identify any moment features with no date-fns equivalent
โ”‚
โ”œโ”€โ”€ Step 2: INSTALL PARALLEL
โ”‚   โ”œโ”€โ”€ npm install date-fns (alongside moment, not replacing)
โ”‚   โ”œโ”€โ”€ Create adapter module: src/utils/date-adapter.ts
โ”‚   โ”‚   โ””โ”€โ”€ Exports your date operations, internally calls moment OR date-fns
โ”‚   โ””โ”€โ”€ โœ… Deploy. Both libraries installed. Only moment used.
โ”‚
โ”œโ”€โ”€ Step 3: MIGRATE CONSUMERS (one at a time)
โ”‚   โ”œโ”€โ”€ Change import from 'moment' โ†’ import from 'date-adapter'
โ”‚   โ”œโ”€โ”€ Do NOT change behavior โ€” adapter calls moment internally
โ”‚   โ”œโ”€โ”€ โœ… Deploy after each file. Rollback = revert one file.
โ”‚   โ””โ”€โ”€ Repeat until all consumers use adapter
โ”‚
โ”œโ”€โ”€ Step 4: SWAP INTERNALS
โ”‚   โ”œโ”€โ”€ Inside date-adapter, change implementation from moment โ†’ date-fns
โ”‚   โ”œโ”€โ”€ Run tests. Compare outputs.
โ”‚   โ”œโ”€โ”€ โœ… Deploy. If issues, revert adapter internals only (one file).
โ”‚   โ””โ”€โ”€ Monitor for edge cases (timezone, locale, formatting)
โ”‚
โ”œโ”€โ”€ Step 5: CLEANUP
โ”‚   โ”œโ”€โ”€ Remove moment from package.json
โ”‚   โ”œโ”€โ”€ Optionally inline adapter (or keep for future flexibility)
โ”‚   โ”œโ”€โ”€ โœ… Deploy.
โ”‚   โ””โ”€โ”€ Total migration: N small PRs, zero downtime, full rollback at each step
โ”‚
โ””โ”€โ”€ ROLLBACK POINTS: Every step. Maximum rollback cost: 1 file revert.

Type 2: Framework Migration

Replace one framework with another (same language)

Example: Express โ†’ Fastify

COMPASS ROUTE:
โ”œโ”€โ”€ Step 1: AUDIT
โ”‚   โ”œโ”€โ”€ Catalog all routes (count, complexity, middleware usage)
โ”‚   โ”œโ”€โ”€ Catalog all middleware (auth, logging, CORS, etc.)
โ”‚   โ”œโ”€โ”€ Identify Express-specific patterns (req/res augmentation, etc.)
โ”‚   โ””โ”€โ”€ Map Express concepts โ†’ Fastify equivalents
โ”‚
โ”œโ”€โ”€ Step 2: STRANGLER FACADE
โ”‚   โ”œโ”€โ”€ Introduce a reverse proxy (or route splitter) in front of Express
โ”‚   โ”œโ”€โ”€ All traffic โ†’ Express (no change in behavior)
โ”‚   โ”œโ”€โ”€ โœ… Deploy. Verify no change.
โ”‚   โ””โ”€โ”€ This proxy will later split traffic between Express and Fastify
โ”‚
โ”œโ”€โ”€ Step 3: PARALLEL INSTANCE
โ”‚   โ”œโ”€โ”€ Stand up Fastify instance alongside Express
โ”‚   โ”œโ”€โ”€ Migrate ONE low-risk route (health check, static asset, etc.)
โ”‚   โ”œโ”€โ”€ Route proxy: /health โ†’ Fastify, everything else โ†’ Express
โ”‚   โ”œโ”€โ”€ โœ… Deploy. Verify Fastify serves /health correctly.
โ”‚   โ””โ”€โ”€ Rollback: Route /health back to Express
โ”‚
โ”œโ”€โ”€ Step 4: INCREMENTAL ROUTE MIGRATION
โ”‚   โ”œโ”€โ”€ Migrate routes one at a time (or in small batches)
โ”‚   โ”œโ”€โ”€ Order: lowest risk โ†’ highest risk
โ”‚   โ”‚   โ”œโ”€โ”€ Static routes (no state, no auth)
โ”‚   โ”‚   โ”œโ”€โ”€ Read-only authenticated routes
โ”‚   โ”‚   โ”œโ”€โ”€ Write routes (mutations)
โ”‚   โ”‚   โ””โ”€โ”€ Complex routes (multi-step, transactional)
โ”‚   โ”œโ”€โ”€ For each route:
โ”‚   โ”‚   โ”œโ”€โ”€ Implement in Fastify
โ”‚   โ”‚   โ”œโ”€โ”€ Validate with parallel run (same request โ†’ both systems โ†’ compare)
โ”‚   โ”‚   โ”œโ”€โ”€ Switch proxy to Fastify
โ”‚   โ”‚   โ”œโ”€โ”€ โœ… Deploy. Monitor.
โ”‚   โ”‚   โ””โ”€โ”€ Rollback: Switch proxy back to Express
โ”‚   โ””โ”€โ”€ Repeat until all routes are on Fastify
โ”‚
โ”œโ”€โ”€ Step 5: DECOMMISSION
โ”‚   โ”œโ”€โ”€ Remove Express from package.json
โ”‚   โ”œโ”€โ”€ Remove proxy (Fastify serves directly)
โ”‚   โ”œโ”€โ”€ โœ… Deploy.
โ”‚   โ””โ”€โ”€ Clean up any compatibility shims
โ”‚
โ””โ”€โ”€ ROLLBACK POINTS: Per-route. Maximum rollback: re-route one endpoint.

Type 3: Language Migration

Convert codebase from one language to another

Example: JavaScript โ†’ TypeScript

COMPASS ROUTE:
โ”œโ”€โ”€ Step 1: CONFIGURE
โ”‚   โ”œโ”€โ”€ Add tsconfig.json with strict: false (permissive start)
โ”‚   โ”œโ”€โ”€ Enable allowJs: true (JS and TS coexist)
โ”‚   โ”œโ”€โ”€ โœ… Deploy. Zero behavior change.
โ”‚
โ”œโ”€โ”€ Step 2: RENAME (leaf nodes first)
โ”‚   โ”œโ”€โ”€ Dependency graph: find files with NO importers (leaf nodes)
โ”‚   โ”œโ”€โ”€ Rename .js โ†’ .ts (one file at a time)
โ”‚   โ”œโ”€โ”€ Add minimal types (any where needed to compile)
โ”‚   โ”œโ”€โ”€ โœ… Deploy after each batch.
โ”‚   โ””โ”€โ”€ Work inward: leaves โ†’ branches โ†’ trunk
โ”‚
โ”œโ”€โ”€ Step 3: TIGHTEN
โ”‚   โ”œโ”€โ”€ Replace `any` with real types (one module at a time)
โ”‚   โ”œโ”€โ”€ Enable stricter tsconfig rules incrementally:
โ”‚   โ”‚   โ”œโ”€โ”€ noImplicitAny
โ”‚   โ”‚   โ”œโ”€โ”€ strictNullChecks
โ”‚   โ”‚   โ”œโ”€โ”€ strictFunctionTypes
โ”‚   โ”‚   โ””โ”€โ”€ strict: true (final)
โ”‚   โ”œโ”€โ”€ โœ… Deploy after each rule change.
โ”‚   โ””โ”€โ”€ Rollback: Disable the rule, fix later
โ”‚
โ”œโ”€โ”€ Step 4: CLEANUP
โ”‚   โ”œโ”€โ”€ Remove allowJs when all files are .ts
โ”‚   โ”œโ”€โ”€ Remove any remaining @ts-ignore comments
โ”‚   โ””โ”€โ”€ โœ… Deploy.
โ”‚
โ””โ”€โ”€ ROLLBACK POINTS: Per-file during rename. Per-rule during tightening.

Type 4: Database Migration

Move from one database to another

Type 5: Architecture Migration

Monolith to microservices, MVC to event-driven, etc.

Type 6: Version Migration

Major version upgrade of a framework or library

The Compass Process

INPUT: What are you migrating from? What to? What's the current usage?

Phase 1: SURVEY
โ”œโ”€โ”€ Analyze current usage of the source (what features, what patterns)
โ”œโ”€โ”€ Map source concepts โ†’ target equivalents
โ”œโ”€โ”€ Identify gaps (source features with no target equivalent)
โ”œโ”€โ”€ Estimate per-component migration effort
โ””โ”€โ”€ Identify the riskiest components (most complex, most critical)

Phase 2: ROUTE PLANNING
โ”œโ”€โ”€ Determine migration type (library, framework, language, DB, architecture)
โ”œโ”€โ”€ Select migration strategy:
โ”‚   โ”œโ”€โ”€ Strangler Fig: Route-by-route replacement (best for services)
โ”‚   โ”œโ”€โ”€ Branch by Abstraction: Adapter layer swaps (best for libraries)
โ”‚   โ”œโ”€โ”€ Parallel Run: Both systems simultaneously (best for data stores)
โ”‚   โ””โ”€โ”€ Incremental Rewrite: File-by-file conversion (best for language)
โ”œโ”€โ”€ Order components: lowest risk first โ†’ highest risk last
โ”œโ”€โ”€ Define rollback points for each step
โ””โ”€โ”€ Estimate total duration and effort

Phase 3: VALIDATION GATES
โ”œโ”€โ”€ For each step, define how to verify success:
โ”‚   โ”œโ”€โ”€ Tests that must pass
โ”‚   โ”œโ”€โ”€ Metrics that must be maintained (latency, error rate, throughput)
โ”‚   โ”œโ”€โ”€ Comparison criteria (old output == new output)
โ”‚   โ””โ”€โ”€ Monitoring alerts to watch
โ””โ”€โ”€ Define go/no-go criteria for each step

Phase 4: COMPASS OUTPUT
โ”œโ”€โ”€ Ordered step-by-step plan
โ”œโ”€โ”€ Per-step: what to do, how to verify, how to roll back
โ”œโ”€โ”€ Risk assessment per step
โ”œโ”€โ”€ Total effort estimate
โ”œโ”€โ”€ Dependencies between steps
โ””โ”€โ”€ Parallel work opportunities (what can be done simultaneously)

Output Format

โ•”โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•—
โ•‘                   MIGRATION COMPASS                         โ•‘
โ•‘        From: moment.js โ†’ To: date-fns                       โ•‘
โ•‘        Scope: 47 files, 126 usages                          โ•‘
โ•‘        Estimated effort: 12 dev-hours                       โ•‘
โ• โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•ฃ
โ•‘                                                              โ•‘
โ•‘  ROUTE (5 steps, 0 downtime, full rollback at each step):   โ•‘
โ•‘                                                              โ•‘
โ•‘  [1] AUDIT (1h)                              โœ… deployable   โ•‘
โ•‘  โ””โ”€โ”€ Map 126 usages across 47 files                         โ•‘
โ•‘                                                              โ•‘
โ•‘  [2] INSTALL + ADAPTER (2h)                  โœ… deployable   โ•‘
โ•‘  โ””โ”€โ”€ date-adapter.ts wrapping moment โ†’ date-fns             โ•‘
โ•‘  โ””โ”€โ”€ Rollback: delete adapter, keep moment                  โ•‘
โ•‘                                                              โ•‘
โ•‘  [3] REWIRE CONSUMERS (4h)                   โœ… deployable   โ•‘
โ•‘  โ””โ”€โ”€ 47 files: import moment โ†’ import date-adapter          โ•‘
โ•‘  โ””โ”€โ”€ Rollback: revert individual file imports               โ•‘
โ•‘                                                              โ•‘
โ•‘  [4] SWAP INTERNALS (3h)                     โœ… deployable   โ•‘
โ•‘  โ””โ”€โ”€ Adapter: moment calls โ†’ date-fns calls                 โ•‘
โ•‘  โ””โ”€โ”€ Rollback: revert adapter (1 file)                      โ•‘
โ•‘                                                              โ•‘
โ•‘  [5] CLEANUP (2h)                            โœ… deployable   โ•‘
โ•‘  โ””โ”€โ”€ npm remove moment, inline adapter                      โ•‘
โ•‘                                                              โ•‘
โ•‘  RISK AREAS:                                                 โ•‘
โ•‘  โ”œโ”€โ”€ Timezone handling differs (3 usages need manual review) โ•‘
โ•‘  โ”œโ”€โ”€ Locale formatting differs for zh-CN and ar-SA           โ•‘
โ•‘  โ””โ”€โ”€ moment.duration() has no exact date-fns equivalent      โ•‘
โ•‘                                                              โ•‘
โ•‘  PARALLEL OPPORTUNITIES:                                     โ•‘
โ•‘  Steps 3 can be split across developers (per-directory)      โ•‘
โ•šโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•

When to Invoke

  • When someone says "let's just swap it out" (it's never "just")
  • When planning any library, framework, or language migration
  • When upgrading a major version with breaking changes
  • When evaluating whether a migration is worth the cost
  • When a migration is "halfway done" and stalled (Compass can re-route from current state)

Why It Matters

80% of failed migrations fail for the same reason: they tried to change too much at once, had no rollback plan, and ended up with two half-working systems. The remaining 20% fail because they underestimated the scope.

Migration Compass eliminates both failure modes. Every step is small. Every step is deployable. Every step has a rollback. And the full scope is visible before you start.

Zero external dependencies. Zero API calls. Pure codebase analysis and planning.

ๅฆ‚ไฝ•ไฝฟ็”จใ€ŒMigration Compassใ€๏ผŸ

  1. ๆ‰“ๅผ€ๅฐ้พ™่™พAI๏ผˆWeb ๆˆ– iOS App๏ผ‰
  2. ็‚นๅ‡ปไธŠๆ–นใ€Œ็ซ‹ๅณไฝฟ็”จใ€ๆŒ‰้’ฎ๏ผŒๆˆ–ๅœจๅฏน่ฏๆก†ไธญ่พ“ๅ…ฅไปปๅŠกๆ่ฟฐ
  3. ๅฐ้พ™่™พAI ไผš่‡ชๅŠจๅŒน้…ๅนถ่ฐƒ็”จใ€ŒMigration Compassใ€ๆŠ€่ƒฝๅฎŒๆˆไปปๅŠก
  4. ็ป“ๆžœๅณๆ—ถๅ‘ˆ็Žฐ๏ผŒๆ”ฏๆŒ็ปง็ปญๅฏน่ฏไผ˜ๅŒ–

็›ธๅ…ณๆŠ€่ƒฝ