mcpField
M
migrate

migrate

github.com/parcadei开发3.9k483 次安装40 周前更新
代码仓库

关于 migrate

migrate 是用于框架、语言、数据库和基础设施迁移的工作流技能。它依次执行目标调研、代码分析、计划制定、实施和审查,也支持分阶段运行与 dry run。

主要功能

  1. 01调研迁移目标
  2. 02分析代码库影响
  3. 03制定分阶段迁移计划
  4. 04实施迁移改动
  5. 05审查迁移完整性
  6. 06指定阶段运行或 dry run

适用场景

  1. 01升级框架版本
  2. 02将代码库迁移到另一语言版本
  3. 03迁移数据库并转换数据
  4. 04规划不同云服务商间的基础设施变更

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/parcadei/continuous-claude-v3 --skill migrate

安装后在 Claude Code 中输入/migrate确认已加载。

详细介绍

/migrate - 迁移工作流

为框架、语言和基础设施安全地执行迁移。

适用场景

  • “迁移到 X”
  • “升级框架”
  • “从 X 迁移到 Y”
  • “升级 Python/Node 等”
  • “迁移数据库”
  • 框架版本升级
  • 语言迁移
  • 基础设施变更

工作流概览

┌──────────┐    ┌──────────┐    ┌────────────┐    ┌──────────┐    ┌───────────┐
│  oracle  │───▶│ phoenix  │───▶│   plan-    │───▶│  kraken  │───▶│ surveyor  │
│          │    │          │    │   agent    │    │          │    │           │
└──────────┘    └──────────┘    └────────────┘    └──────────┘    └───────────┘
  Research       Analyze          Plan             Implement       Review
  target         current          migration        changes         migration

Agent 顺序

#Agent职责输出
1oracle调研目标框架/版本调研报告
2phoenix分析当前代码库受迁移的影响影响分析
3plan-agent制定分阶段迁移计划迁移计划
4kraken实施迁移变更代码变更
5surveyor检查迁移是否完整迁移审查

为什么要设置额外关卡?

迁移风险较高:

  • 不同版本之间存在不兼容变更
  • 依赖冲突
  • 数据格式变更
  • API 弃用

额外的调研和审查阶段可以尽早发现问题。

执行流程

阶段 1:调研目标
Task(
  subagent_type="oracle",
  prompt="""
  Research migration target: [TARGET]

  Investigate:
  - Breaking changes from current version
  - New APIs and patterns
  - Deprecated features we use
  - Migration guides from official docs
  - Common pitfalls and solutions

  Output: Migration research report
  """
)
阶段 2:分析当前状态
Task(
  subagent_type="phoenix",
  prompt="""
  Analyze codebase for migration: [FROM] → [TO]

  Identify:
  - Files using deprecated APIs
  - Dependency conflicts
  - Patterns that need updating
  - Test coverage of affected areas
  - Risk areas (critical paths)

  Output: Impact analysis with affected files
  """
)
阶段 3:规划迁移
Task(
  subagent_type="plan-agent",
  prompt="""
  Create migration plan: [FROM] → [TO]

  Research: [from oracle]
  Impact: [from phoenix]

  Plan should:
  - Be phased (incremental if possible)
  - Each phase independently testable
  - Include rollback strategy
  - Prioritize critical path stability

  Output: Phased migration plan
  """
)
阶段 4:实施
Task(
  subagent_type="kraken",
  prompt="""
  Implement migration phase: [PHASE_N]

  Plan: [from plan-agent]

  Requirements:
  - Follow plan exactly
  - Run tests after each change
  - Document any deviations
  - Stop if tests fail

  Output: Completed phase with test results
  """
)
阶段 5:审查迁移
Task(
  subagent_type="surveyor",
  prompt="""
  Review migration: [FROM] → [TO]

  Check:
  - All deprecated APIs replaced
  - No remaining compatibility shims
  - Tests passing
  - Performance acceptable
  - No security regressions

  Output: Migration review report
  """
)

迁移类型

框架升级
User: /migrate React 17 → 18
→ Full workflow with hooks/concurrent mode changes
语言版本
User: /migrate Python 3.9 → 3.12
→ Focus on new syntax, removed features
数据库迁移
User: /migrate MongoDB → PostgreSQL
→ Schema design, data transformation, query rewrite
基础设施
User: /migrate AWS → GCP
→ Service mapping, config translation

示例

User: /migrate from Express to Fastify

Claude: Starting /migrate workflow: Express → Fastify

Phase 1: Researching Fastify...
[Spawns oracle]
Key differences:
- Schema-based validation (vs middleware)
- Plugin architecture
- Async/await native
- Different middleware pattern

Phase 2: Analyzing current Express usage...
[Spawns phoenix]
Impact analysis:
- 23 route files to update
- 8 middleware to convert
- 3 plugins need Fastify equivalents
- Test coverage: 78%

Phase 3: Creating migration plan...
[Spawns plan-agent]

Migration Plan: Express → Fastify
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Phase 1: Setup & Core
- Add Fastify alongside Express
- Migrate core server setup
- Run both in parallel

Phase 2: Routes (by domain)
- Migrate auth routes
- Migrate user routes
- Migrate product routes
- ...

Phase 3: Middleware
- Convert error handler
- Convert auth middleware
- Convert logging

Phase 4: Cleanup
- Remove Express
- Remove compatibility layer
- Final testing

Rollback: Keep Express until Phase 4 complete

Phase 4: Implementing Phase 1...
[Spawns kraken]
✅ Fastify server running alongside Express
✅ Core routes migrated
✅ Tests passing

[Continues through phases...]

Phase 5: Reviewing migration...
[Spawns surveyor]
✅ All Express code removed
✅ 23/23 routes migrated
✅ Performance improved (2.1x faster)
✅ No security regressions

Migration complete! Express → Fastify

渐进式迁移

对于大型代码库,可一次运行一个阶段:

User: /migrate React 17 → 18 --phase 1
[Runs only Phase 1]

User: /migrate React 17 → 18 --phase 2
[Runs Phase 2, reads previous handoff]

标志

  • --phase N:仅运行指定阶段
  • --dry-run:制定计划但不实施
  • --rollback:执行回滚计划
  • --parallel:新旧版本并行运行(绞杀者模式)

评论

支持 Markdown