migrate

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

/migrate - Migration Workflow

/migrate - 迁移工作流

Safe migrations for frameworks, languages, and infrastructure.
为框架、语言和基础设施提供安全的迁移方案。

When to Use

适用场景

  • "Migrate to X"
  • "Upgrade framework"
  • "Move from X to Y"
  • "Upgrade Python/Node/etc."
  • "Migrate database"
  • Framework version upgrades
  • Language migrations
  • Infrastructure changes
  • "迁移至X"
  • "升级框架"
  • "从X迁移至Y"
  • "升级Python/Node等"
  • "迁移数据库"
  • 框架版本升级
  • 语言迁移
  • 基础设施变更

Workflow Overview

工作流概览

┌──────────┐    ┌──────────┐    ┌────────────┐    ┌──────────┐    ┌───────────┐
│  oracle  │───▶│ phoenix  │───▶│   plan-    │───▶│  kraken  │───▶│ surveyor  │
│          │    │          │    │   agent    │    │          │    │           │
└──────────┘    └──────────┘    └────────────┘    └──────────┘    └───────────┘
  Research       Analyze          Plan             Implement       Review
  target         current          migration        changes         migration
┌──────────┐    ┌──────────┐    ┌────────────┐    ┌──────────┐    ┌───────────┐
│  oracle  │───▶│  phoenix  │───▶│   plan-    │───▶│  kraken  │───▶│ surveyor  │
│          │    │          │    │   agent    │    │          │    │           │
└──────────┘    └──────────┘    └────────────┘    └──────────┘    └───────────┘
  调研       分析          规划             实施       评审
  目标技术栈  当前系统      迁移计划         变更实施    迁移结果

Agent Sequence

Agent执行序列

#AgentRoleOutput
1oracleResearch target framework/versionResearch report
2phoenixAnalyze current codebase for migration impactImpact analysis
3plan-agentCreate phased migration planMigration plan
4krakenImplement migration changesCode changes
5surveyorReview migration for completenessMigration review
序号Agent角色输出
1oracle调研目标框架/版本调研报告
2phoenix分析当前代码库的迁移影响影响分析报告
3plan-agent创建分阶段迁移计划迁移计划
4kraken实施迁移变更代码变更
5surveyor评审迁移完成情况迁移评审报告

Why Extra Gates?

为何设置额外环节?

Migrations are high-risk:
  • Breaking changes between versions
  • Dependency conflicts
  • Data format changes
  • API deprecations
The extra research and review phases catch issues early.
迁移是高风险操作:
  • 版本间的破坏性变更
  • 依赖冲突
  • 数据格式变更
  • API废弃
额外的调研和评审环节可提前发现问题。

Execution

执行步骤

Phase 1: Research Target

阶段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
  """
)
Task(
  subagent_type="oracle",
  prompt="""
  调研迁移目标: [TARGET]

  调研内容:
  - 当前版本到目标版本的破坏性变更
  - 新API和模式
  - 我们正在使用的已废弃特性
  - 官方文档中的迁移指南
  - 常见陷阱与解决方案

  输出: 迁移调研报告
  """
)

Phase 2: Analyze Current State

阶段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
  """
)
Task(
  subagent_type="phoenix",
  prompt="""
  分析代码库的迁移影响: [FROM] → [TO]

  识别内容:
  - 使用废弃API的文件
  - 依赖冲突
  - 需要更新的代码模式
  - 受影响区域的测试覆盖率
  - 风险区域(关键路径)

  输出: 包含受影响文件的影响分析报告
  """
)

Phase 3: Plan Migration

阶段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
  """
)
Task(
  subagent_type="plan-agent",
  prompt="""
  创建迁移计划: [FROM] → [TO]

  调研结果: [来自oracle的输出]
  影响分析: [来自phoenix的输出]

  计划需满足:
  - 分阶段执行(尽可能增量迁移)
  - 每个阶段可独立测试
  - 包含回滚策略
  - 优先保障关键路径稳定性

  输出: 分阶段迁移计划
  """
)

Phase 4: Implement

阶段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
  """
)
Task(
  subagent_type="kraken",
  prompt="""
  实施迁移阶段: [PHASE_N]

  迁移计划: [来自plan-agent的输出]

  要求:
  - 严格遵循计划执行
  - 每次变更后运行测试
  - 记录所有偏差情况
  - 测试失败时立即停止

  输出: 已完成的阶段及测试结果
  """
)

Phase 5: Review Migration

阶段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
  """
)
Task(
  subagent_type="surveyor",
  prompt="""
  评审迁移结果: [FROM] → [TO]

  检查内容:
  - 所有废弃API已替换
  - 无残留兼容层
  - 测试全部通过
  - 性能符合要求
  - 无安全回归问题

  输出: 迁移评审报告
  """
)

Migration Types

迁移类型

Framework Upgrade

框架升级

User: /migrate React 17 → 18
→ Full workflow with hooks/concurrent mode changes
用户: /migrate React 17 → 18
→ 包含hooks/并发模式变更的完整工作流

Language Version

语言版本升级

User: /migrate Python 3.9 → 3.12
→ Focus on new syntax, removed features
用户: /migrate Python 3.9 → 3.12
→ 重点关注新语法、移除的特性

Database Migration

数据库迁移

User: /migrate MongoDB → PostgreSQL
→ Schema design, data transformation, query rewrite
用户: /migrate MongoDB → PostgreSQL
→  Schema设计、数据转换、查询重写

Infrastructure

基础设施迁移

User: /migrate AWS → GCP
→ Service mapping, config translation
用户: /migrate AWS → GCP
→ 服务映射、配置转换

Example

示例

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
用户: /migrate from Express to Fastify

Claude: 启动/migrate工作流:Express → Fastify

阶段1:调研Fastify...
[启动oracle Agent]
核心差异:
- 基于Schema的验证(对比中间件模式)
- 插件架构
- 原生支持Async/await
- 不同的中间件模式

阶段2:分析当前Express使用情况...
[启动phoenix Agent]
影响分析:
- 23个路由文件需更新
- 8个中间件需转换
- 3个插件需要Fastify等效替代方案
- 测试覆盖率: 78%

阶段3:创建迁移计划...
[启动plan-agent]

迁移计划: Express → Fastify
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

阶段1:基础设置与核心迁移
- 在Express旁部署Fastify
- 迁移核心服务器配置
- 并行运行两者

阶段2:按业务域迁移路由
- 迁移认证路由
- 迁移用户路由
- 迁移产品路由
- ...

阶段3:中间件转换
- 转换错误处理器
- 转换认证中间件
- 转换日志中间件

阶段4:清理工作
- 移除Express
- 移除兼容层
- 最终测试

回滚策略: 在阶段4完成前保留Express

阶段4:实施阶段1...
[启动kraken Agent]
✅ Fastify服务器已与Express并行运行
✅ 核心路由已迁移完成
✅ 测试通过

[继续执行后续阶段...]

阶段5:评审迁移结果...
[启动surveyor Agent]
✅ 所有Express代码已移除
✅ 23/23个路由已迁移
✅ 性能提升(2.1倍速)
✅ 无安全回归问题

迁移完成!Express → Fastify

Incremental Migration

增量迁移

For large codebases, run one phase at a time:
User: /migrate React 17 → 18 --phase 1
[Runs only Phase 1]

User: /migrate React 17 → 18 --phase 2
[Runs Phase 2, reads previous handoff]
对于大型代码库,可分阶段执行:
用户: /migrate React 17 → 18 --phase 1
[仅执行阶段1]

用户: /migrate React 17 → 18 --phase 2
[执行阶段2,读取之前的交接数据]

Flags

命令行参数

  • --phase N
    : Run specific phase only
  • --dry-run
    : Plan without implementing
  • --rollback
    : Execute rollback plan
  • --parallel
    : Run new alongside old (strangler fig)
  • --phase N
    : 仅执行指定阶段
  • --dry-run
    : 仅生成计划不执行变更
  • --rollback
    : 执行回滚计划
  • --parallel
    : 新旧系统并行运行(绞杀者模式)