← 返回 Skills 市场
charlie-morrison

Codebase Migration Planner

作者 charlie-morrison · GitHub ↗ · v1.0.0 · MIT-0
cross-platform ✓ 安全检测通过
43
总下载
0
收藏
0
当前安装
1
版本数
在 OpenClaw 中安装
/install codebase-migration-planner
功能描述
Plan complex codebase migrations — framework upgrades, language transitions, architecture refactors. Analyze dependencies, estimate effort, map migration pat...
使用说明 (SKILL.md)

Codebase Migration Planner

Plan and execute large-scale codebase migrations systematically. Whether it's React class→hooks, Express→Fastify, Python 2→3, monolith→microservices, or JavaScript→TypeScript — this skill maps the current state, identifies migration paths, estimates effort, and generates a phased execution plan.

Use when: "plan a migration", "migrate from X to Y", "upgrade from v1 to v2", "rewrite this in TypeScript", "how much work to migrate", "migration effort estimate", or planning a major framework/language change.

Commands

1. assess — Migration Assessment

Analyze the current codebase to understand migration scope.

Step 1: Inventory Current State

echo "=== Codebase Inventory ==="

# Language distribution
echo "--- Language Distribution ---"
find . -type f \( -name "*.ts" -o -name "*.tsx" -o -name "*.js" -o -name "*.jsx" \
  -o -name "*.py" -o -name "*.go" -o -name "*.rs" -o -name "*.java" -o -name "*.rb" \
  -o -name "*.vue" -o -name "*.svelte" -o -name "*.css" -o -name "*.scss" \) \
  -not -path '*/node_modules/*' -not -path '*/vendor/*' -not -path '*/dist/*' -not -path '*/.git/*' 2>/dev/null | \
  sed 's/.*\.//' | sort | uniq -c | sort -rn

# Total lines of code
echo "--- Lines of Code ---"
find . -type f \( -name "*.ts" -o -name "*.tsx" -o -name "*.js" -o -name "*.jsx" \
  -o -name "*.py" -o -name "*.go" -o -name "*.rs" -o -name "*.java" \) \
  -not -path '*/node_modules/*' -not -path '*/vendor/*' -not -path '*/dist/*' 2>/dev/null | \
  xargs wc -l 2>/dev/null | tail -1

# Framework/library detection
echo "--- Frameworks & Libraries ---"
if [ -f "package.json" ]; then
  python3 -c "
import json
d = json.load(open('package.json'))
deps = {**d.get('dependencies',{}), **d.get('devDependencies',{})}
frameworks = {
    'react': 'React', 'next': 'Next.js', 'vue': 'Vue.js', 'nuxt': 'Nuxt',
    'angular': 'Angular', 'svelte': 'Svelte', '@sveltejs/kit': 'SvelteKit',
    'express': 'Express', 'fastify': 'Fastify', 'koa': 'Koa', 'hapi': 'Hapi',
    'jest': 'Jest', 'vitest': 'Vitest', 'mocha': 'Mocha', 'cypress': 'Cypress',
    'webpack': 'Webpack', 'vite': 'Vite', 'esbuild': 'esbuild', 'rollup': 'Rollup',
    'tailwindcss': 'Tailwind CSS', 'styled-components': 'styled-components',
    'prisma': 'Prisma', 'typeorm': 'TypeORM', 'sequelize': 'Sequelize',
    'redux': 'Redux', 'zustand': 'Zustand', 'mobx': 'MobX',
}
found = [(v, deps[k]) for k, v in frameworks.items() if k in deps]
for name, ver in sorted(found):
    print(f'  {name}: {ver}')
" 2>/dev/null
fi

# Test count
TEST_COUNT=$(find . -type f \( -name "*.test.*" -o -name "*.spec.*" -o -name "test_*" \) \
  -not -path '*/node_modules/*' 2>/dev/null | wc -l)
echo "Test files: $TEST_COUNT"

# Configuration files
echo "--- Configuration ---"
for f in tsconfig.json jsconfig.json .babelrc babel.config.* webpack.config.* vite.config.* \
         rollup.config.* .eslintrc* eslint.config.* biome.json prettier* jest.config.* \
         vitest.config.* next.config.* nuxt.config.* svelte.config.*; do
  ls $f 2>/dev/null
done

Step 2: Migration Target Analysis

Based on what the user wants to migrate to, analyze:

  • API surface differences between old and new
  • Configuration changes needed
  • Incompatible patterns that need rewriting
  • Available codemods or migration tools

Step 3: Scope Estimation

echo "=== Migration Scope ==="

# Count files that need migration (depends on migration type)
# Example: JS → TS migration
echo "--- Files Requiring Migration ---"
find . -name "*.js" -o -name "*.jsx" | \
  grep -v node_modules | grep -v dist | grep -v build | wc -l

# Group by directory (to plan phases)
echo "--- Files by Directory ---"
find . \( -name "*.js" -o -name "*.jsx" \) \
  -not -path '*/node_modules/*' -not -path '*/dist/*' 2>/dev/null | \
  xargs -I{} dirname {} | sort | uniq -c | sort -rn | head -20

# Complexity per directory (rough effort indicator)
echo "--- Complexity by Directory ---"
for dir in $(find . -maxdepth 2 -type d -not -path '*/.git*' -not -path '*/node_modules*' -not -path '*/dist*' 2>/dev/null); do
  LOC=$(find "$dir" -maxdepth 1 -type f \( -name "*.js" -o -name "*.ts" -o -name "*.py" \) 2>/dev/null | \
    xargs wc -l 2>/dev/null | tail -1 | awk '{print $1}')
  [ "$LOC" -gt 0 ] 2>/dev/null && echo "  $dir: $LOC lines"
done | sort -t: -k2 -rn | head -15

2. plan — Generate Migration Plan

Produce a phased migration plan with effort estimates.

# Migration Plan: [From] → [To]
Generated: [date]
Estimated total effort: X person-weeks

## Phase 0: Preparation (Week 1)
- [ ] Set up new tooling alongside old (dual support)
- [ ] Add configuration for target framework
- [ ] Ensure CI runs both old and new test suites
- [ ] Create migration tracking document
- Effort: 2-3 days

## Phase 1: Foundation (Week 2-3)
Target: shared utilities, types, constants
- [ ] Migrate `src/utils/` (N files, ~X lines)
- [ ] Migrate `src/types/` (N files, ~X lines)
- [ ] Migrate `src/constants/` (N files, ~X lines)
- Effort: N days
- Risk: Low (leaf modules, no dependents to break)

## Phase 2: Core Libraries (Week 4-5)
Target: internal libraries used by features
- [ ] Migrate `src/lib/` (N files, ~X lines)
- [ ] Update imports in consuming files
- [ ] Run full test suite after each library
- Effort: N days
- Risk: Medium (other code depends on these)

## Phase 3: Features (Week 6-8)
Target: feature modules, one at a time
- [ ] Migrate `src/features/auth/` (N files)
- [ ] Migrate `src/features/users/` (N files)
- [ ] ... (ordered by dependency — leaf features first)
- Effort: N days
- Risk: Medium-High (user-facing code)

## Phase 4: Cleanup (Week 9)
- [ ] Remove old tooling and configuration
- [ ] Update CI to remove dual-support
- [ ] Update documentation
- [ ] Final integration testing
- Effort: 2-3 days

## Rollback Strategy
At any phase, the old code still works alongside the new:
- Revert the phase's commits
- Restore old configuration
- No data migration needed (this is code-only)

3. codemods — Find Available Codemods

Search for automated migration tools:

echo "=== Available Codemods ==="

# Common migration codemods
# React
if rg -q "from ['\"]react['\"]" -g '*.{tsx,jsx}' 2>/dev/null; then
  echo "React codemods:"
  echo "  - npx @codemod/cli --transform react/19/migration"
  echo "  - npx react-codemod rename-unsafe-lifecycles"
  echo "  - npx react-codemod update-react-imports"
fi

# TypeScript adoption
if [ -f "jsconfig.json" ] || find . -name "*.js" -not -path '*/node_modules/*' 2>/dev/null | head -1 | grep -q .; then
  echo "JS → TS codemods:"
  echo "  - npx ts-migrate setup ."
  echo "  - npx @codemod/cli --transform js-to-ts"
fi

# Express → Fastify
if rg -q "require\(['\"]express['\"]\)|from ['\"]express['\"]" 2>/dev/null; then
  echo "Express → Fastify migration:"
  echo "  - Manual migration (no automated codemod)"
  echo "  - Key changes: app.get → fastify.get, middleware → hooks/plugins"
fi

# Vue 2 → Vue 3
if rg -q "from ['\"]vue['\"]" -g '*.{vue,js,ts}' 2>/dev/null; then
  echo "Vue codemods:"
  echo "  - npx @vue/compat"
  echo "  - gogocode-cli -s ./src -t vue2-to-vue3 -o ./src"
fi

4. track — Migration Progress Tracking

Update a MIGRATION.md tracking file:

# Migration Progress: JS → TypeScript

| Directory | Files | Migrated | Remaining | Status |
|-----------|-------|----------|-----------|--------|
| src/utils/ | 12 | 12 | 0 | ✅ Complete |
| src/lib/ | 8 | 5 | 3 | 🔄 In Progress |
| src/features/auth/ | 6 | 0 | 6 | ⏳ Pending |
| src/features/users/ | 15 | 0 | 15 | ⏳ Pending |
| src/pages/ | 22 | 0 | 22 | ⏳ Pending |
| **Total** | **63** | **17** | **46** | **27%** |

Last updated: 2026-04-28

5. risks — Risk Assessment

Analyze migration risks:

  • Dependency compatibility: Do all dependencies support the target?
  • Test coverage: Which migrated files lack tests?
  • API surface: Which public APIs might change?
  • Data compatibility: Any serialization/deserialization changes?
  • Performance: Known performance differences between old/new?
# Check if major dependencies support the target
echo "=== Dependency Compatibility ==="
if [ -f "package.json" ]; then
  python3 -c "
import json
d = json.load(open('package.json'))
deps = list(d.get('dependencies', {}).keys())
print(f'Production dependencies to verify: {len(deps)}')
for dep in deps[:20]:
    print(f'  {dep} — check compatibility with target')
" 2>/dev/null
fi

6. effort — Effort Estimation

Estimate person-hours based on file analysis:

Factor Weight Notes
Lines of code 1 hr per 200 LOC Mechanical changes
Complex files (>300 LOC) 2x multiplier Need careful migration
Files without tests 1.5x multiplier Need manual verification
API boundary files 2x multiplier Risk of breaking consumers
Configuration files 2 hrs each Need deep understanding
Estimated effort:
  Simple files (\x3C 100 LOC, with tests): 35 files × 0.5 hr = 17.5 hrs
  Medium files (100-300 LOC): 20 files × 1.5 hr = 30 hrs
  Complex files (> 300 LOC): 8 files × 4 hr = 32 hrs
  Config/build files: 5 files × 2 hr = 10 hrs
  Testing/verification: 20% buffer = 18 hrs

  Total: ~108 hours (~2.7 person-weeks)

Output Formats

  • text (default): Human-readable plan with tables
  • json: {assessment: {}, plan: {phases: []}, risks: [], effort: {}, codemods: []}
  • markdown: Stakeholder-ready document with Gantt-style timeline

Common Migration Types

This skill handles any migration, but excels at:

  • JS → TypeScript: File-by-file, incremental adoption
  • React class → hooks: Component-by-component
  • Express → Fastify: Route-by-route
  • Webpack → Vite: Config rewrite + plugin mapping
  • Jest → Vitest: Near-drop-in with config changes
  • Vue 2 → Vue 3: Composition API + breaking changes
  • REST → GraphQL: Schema-first, resolver mapping
  • Monolith → Microservices: Domain-driven decomposition

Notes

  • Does not execute migrations — generates plans and tracks progress
  • Effort estimates are based on heuristics and should be validated with team knowledge
  • Codemod recommendations may have version-specific availability
  • For large migrations (>100 files), recommend incremental approach with dual-support period
  • Migration tracking file (MIGRATION.md) should be committed for team visibility
安全使用建议
This SKILL.md is coherent and appears to do what it says: local repository analysis and planning. Before installing or allowing autonomous runs: (1) Review the SKILL.md yourself and confirm you're comfortable with it reading files in the agent's working directory. (2) Run it only on checked-out codebases you trust — avoid running it from home or other directories containing secrets. (3) Note it uses common POSIX tools and python3 (not declared in metadata); ensure the execution environment has those tools or the commands may fail. (4) If you plan to use it autonomously, consider restricting the agent's working directory or running the skill in a sandboxed environment to prevent accidental exposure of unrelated files.
功能分析
Type: OpenClaw Skill Name: codebase-migration-planner Version: 1.0.0 The codebase-migration-planner skill is a legitimate tool designed to assist in planning and tracking software migrations. The provided scripts in SKILL.md use standard shell commands (find, grep, wc) and basic Python logic to perform static analysis of the codebase, such as counting lines of code, identifying frameworks in package.json, and detecting configuration files. There are no signs of data exfiltration, malicious execution, or prompt injection attempts.
能力评估
Purpose & Capability
The name/description (codebase migration planning) align with the actions in SKILL.md: inventorying files, detecting frameworks from package.json, counting LOC, grouping files by directory, and producing phased plans. The actions requested are what you'd expect for this purpose. One minor omission: the SKILL.md invokes standard system tools (bash utilities and python3) but the skill metadata does not list required binaries — a small mismatch but not a functional contradiction.
Instruction Scope
All instructions operate on the current working directory (the repository): find, ls, grep, xargs, and a python3 snippet that reads package.json. The instructions do not reference external endpoints, environment secrets, or unrelated system paths. Caveat: because it runs filesystem scans across the repo, it will read any files in that directory (so running it from a directory containing secrets could expose them in outputs). The commands also assume POSIX tools and may behave unexpectedly on some platforms or with unusual filenames.
Install Mechanism
Instruction-only skill with no install spec and no code files — lowest install risk. Nothing is downloaded or written to disk by an installer.
Credentials
The skill declares no required env vars or credentials and the instructions do not attempt to access hidden environment variables. However, it does read repository files (including package.json and config files), so any sensitive data present in the working directory could be surfaced in outputs — this is a contextual risk, not a mismatch with declared environment requirements.
Persistence & Privilege
always:false (default) and no installation steps that modify other skills or system-wide settings. The skill does not request persistent presence or elevated privileges.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install codebase-migration-planner
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /codebase-migration-planner 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.0
Initial release of Codebase Migration Planner. - Provides systematic assessment of codebases for migrations, including language, framework, and complexity analysis. - Generates detailed, phased migration plans with effort estimation, risk, and rollback strategies. - Identifies files and directories requiring migration and visualizes migration scope. - Suggests available codemods or migration automation tools based on codebase content. - Enables clear tracking of migration progress via a structured status file.
元数据
Slug codebase-migration-planner
版本 1.0.0
许可证 MIT-0
累计安装 0
当前安装数 0
历史版本数 1
常见问题

Codebase Migration Planner 是什么?

Plan complex codebase migrations — framework upgrades, language transitions, architecture refactors. Analyze dependencies, estimate effort, map migration pat... 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 43 次。

如何安装 Codebase Migration Planner?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install codebase-migration-planner」即可一键安装,无需额外配置。

Codebase Migration Planner 是免费的吗?

是的,Codebase Migration Planner 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。

Codebase Migration Planner 支持哪些平台?

Codebase Migration Planner 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 Codebase Migration Planner?

由 charlie-morrison(@charlie-morrison)开发并维护,当前版本 v1.0.0。

💬 留言讨论