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...
ๆ่ฝ่ฏดๆ
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ใ๏ผ
- ๆๅผๅฐ้พ่พAI๏ผWeb ๆ iOS App๏ผ
- ็นๅปไธๆนใ็ซๅณไฝฟ็จใๆ้ฎ๏ผๆๅจๅฏน่ฏๆกไธญ่พๅ ฅไปปๅกๆ่ฟฐ
- ๅฐ้พ่พAI ไผ่ชๅจๅน้ ๅนถ่ฐ็จใMigration Compassใๆ่ฝๅฎๆไปปๅก
- ็ปๆๅณๆถๅ็ฐ๏ผๆฏๆ็ปง็ปญๅฏน่ฏไผๅ