Perform codebase migrations: upgrade dependencies, swap libraries, adopt new APIs or patterns, and modernize legacy code. Use when the user wants to migrate, upgrade, swap a library, adopt a new pattern, or modernize code.
Perform systematic codebase migrations — upgrading dependencies, swapping libraries, adopting new APIs, or modernizing patterns.
Perform the migration described in $ARGUMENTS. The argument should indicate what to migrate (e.g., "upgrade React from 17 to 18", "swap moment.js with date-fns", "adopt the new config API").
Identify the migration type:
Research the migration:
Use the Agent tool to launch 2 research agents in parallel:
Agent 1: Current usage scan (subagent_type: Explore, thoroughness: very thorough)
Find every usage of [the library/pattern/API being migrated away from] in this codebase.
Search for:
- Import/require statements
- Direct API calls and method usage
- Type references and interface implementations
- Configuration entries (build config, lint config, etc.)
- Usage in tests and test fixtures
- References in documentation, comments, and scripts
- Transitive usage through wrapper modules
For each usage, report: file:line, the specific API/pattern used, and surrounding context.
Group by file, sort by frequency of usage.
Report total count of usages and number of files affected.
Agent 2: Migration guide research (subagent_type: general-purpose)
Research the migration from [source] to [target].
Find:
- Official migration guide or changelog (search the web)
- Breaking changes between versions (if an upgrade)
- API mapping: old API → new API equivalents
- Known gotchas, edge cases, or compatibility issues
- Codemods or automated migration tools available
- Required peer dependency changes
Summarize as a concise mapping table: old pattern → new pattern.
Flag any changes that require manual judgment (not a 1:1 swap).
Present the plan to the user:
## Migration Plan
**Type:** [upgrade | swap | adopt | modernize]
**From:** [current library/version/pattern]
**To:** [target library/version/pattern]
### Scope
- **Files affected:** N
- **Total usages:** N
- **Automated:** N (1:1 mappings that can be mechanically replaced)
- **Manual review:** N (changes requiring judgment)
### API Mapping
| Old | New | Notes |
|-----|-----|-------|
| ... | ... | ... |
### Migration steps
1. [Ordered list of steps]
### Risks
- [Breaking changes, behavioral differences, or edge cases]
Wait for user confirmation before proceeding.
Apply changes in a safe order:
After applying changes: