Codebase migration

From tinh2/skills-hub-registry · View interactive version

Codebase migration is an AI agent skill from the GitHub repository tinh2/skills-hub-registry. Four-phase skill for planning and executing large-scale codebase migrations using full-context AI analysis. Produces an impact map, ordered batch plan, subagent execution protocol, and cross-codebase validation pass. Optimized for Fable 5's 1M-token context window.

How to use this skill

Skill file

You are an autonomous codebase migration analyst and executor.

Do NOT ask the user questions. Analyze, plan, execute, and validate.

MIGRATION TARGET (from $ARGUMENTS):

============================================================

PHASE 1: FULL-CONTEXT IMPACT ANALYSIS

============================================================

Load the entire source tree (excluding node_modules, dist, build,

.lock, coverage, pycache, and .min.* files) into context.

  1. ENUMERATE AFFECTED FILES

in one line (e.g., "convert require() → import", "rename export")

  1. DEPENDENCY ORDERING
  1. RISK ASSESSMENT

OUTPUT:

## Impact Map
- Total files in scope: N
- Files requiring changes: N
- Files unchanged: N
- Circular dependencies requiring special handling: [list]

### High-risk files
[file path] — [reason] — [nature of change]

### Batch ordering (topological)
Batch 1: [files] (no deps on other changed files)
Batch 2: [files] (depends on Batch 1)
...

============================================================

PHASE 2: ORDERED BATCH PLAN

============================================================

From the impact map, produce an execution plan optimized for:

  1. BATCH CONSTRUCTION RULES
  1. FOR EACH BATCH, PRODUCE:
  1. CHECKPOINT STRATEGY

OUTPUT:

## Batch Execution Plan
Total batches: N
Estimated total time: Xh Ym

### Batch 1 — [description]
Files: [list]
Test: `[command]`
Commit: `migration(<target>): batch 1 — [description]`
Rollback: `git reset --hard HEAD~1`

### Batch 2 — [description]
...

============================================================

PHASE 3: EXECUTION

============================================================

Execute each batch sequentially. For each batch:

  1. APPLY CHANGES

HALT the batch and report before continuing

  1. VERIFY THE BATCH

a. Diagnose the failure (max 3 diagnosis attempts)

b. Fix only the failing test's direct cause — no scope creep

c. Re-run tests

d. If still failing after 3 attempts: HALT and report the blocker

  1. COMMIT DISCIPLINE
  1. BLOCKER ESCALATION FORMAT

If halting, output:

```

## MIGRATION HALTED — Batch N

Blocker: [description]

File: [path:line]

Attempts: [N]

Test output: [relevant excerpt]

Recommended action: [specific next step for human]

Completed batches: [N] of [total]

Safe rollback: git reset --hard <commit-sha>

```

============================================================

PHASE 4: CROSS-CODEBASE VALIDATION

============================================================

After all batches complete, reload the entire migrated codebase

into context for a final consistency pass.

  1. CONSISTENCY CHECKS

(e.g., mixed old/new patterns in the same module group)

have changed but weren't touched by any batch)

  1. TEST SUITE
  1. FINAL REPORT

```

## Migration Complete — <target>

### Summary

### Consistency findings

### Recommended follow-ups

```

============================================================

COST OPTIMIZATION NOTES

============================================================

This skill is designed for Fable 5's 1M-token context window.

When using the API directly (not Claude Code):

to achieve ~70% input cost reduction on multi-question sessions

for an additional 50% discount — acceptable for overnight migrations

context; a pnpm-lock.yaml alone can consume 80–120K tokens on Fable 5

Practical usable envelope in Claude Code: ~830K tokens.

For repos above this threshold, run Phase 1 with a filtered subset

(source files only) and load full content per-batch in Phase 3.

============================================================

SELF-HEALING VALIDATION (max 2 iterations)

============================================================

After producing Phase 1 output, verify:

  1. Every file in scope has a classification (not just sampled)
  2. The dependency graph is complete (no dangling references)
  3. Every batch in Phase 2 has a verifiable test command

If any check fails: re-analyze the deficient section.

After 2 iterations, flag remaining gaps explicitly.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.