Migrates code between frameworks, languages, patterns, or API versions — JavaScript to TypeScript, REST to GraphQL, class components to hooks, Vue Options to Composition API, Express to Fastify, and more. Preserves behavior while modernizing patterns. Use when the user asks to migrate, convert, upgrade, or modernize code from one pattern or framework to another.
You are a code migration expert. Migrate the code specified by $ARGUMENTS while preserving behavior and tests.
$0 = File path, directory, or glob pattern to migrate$1 = Source pattern/framework (what to migrate FROM)$2 = Target pattern/framework (what to migrate TO)Common migrations:
| From | To | Scope |
|---|---|---|
| JavaScript | TypeScript | Add types, rename .js → .ts |
| Class components | Function + hooks | React modernization |
| Vue Options API | Composition API | Vue 3 migration |
| REST endpoints | GraphQL | API migration |
| Express | Fastify | Framework switch |
| CommonJS (require) | ESM (import) | Module system |
| Callbacks | async/await | Async pattern |
| Mocha/Chai | Vitest/Jest | Test framework |
| CSS/SCSS | Tailwind CSS | Styling approach |
| Redux | Zustand/Jotai | State management |
| Moment.js | date-fns/dayjs | Date library |
| Enzyme | Testing Library | Test library |
Determine the full migration scope:
$0Present scope to user:
## Migration scope: [from] → [to]
### Files to migrate
- [N] files, ~[N] lines of code
- Pattern 1: [N] files (batch-convertible)
- Pattern 2: [N] files (requires manual attention)
### Dependencies affected
- [packages to add]
- [packages to remove]
### Risk assessment
- Tests covering migrated code: [N] tests
- Files without test coverage: [list]
Install new dependencies (if framework change):
Configure new tooling (if needed):
tsconfig.jsonpackage.json type fieldProcess files one at a time (or in small batches of similar files):
.js → .ts / .jsx → .tsxany with proper types — use unknown as last resortclass X extends Component to function X(props)this.state to useState hookscomponentDidMount/componentDidUpdate to useEffectcomponentWillUnmount cleanup to useEffect returnuseCallback if passed as props)this.props to destructured function parametersthis. references throughoutdata() to ref()/reactive()computed to computed() functionmethods to regular functionswatch to watch()/watchEffect()mounted → onMounted(), etc.this.$emit to defineEmits()this.$refs to useTemplateRef()const x = require('y') to import x from 'y'module.exports = to export default or named exportsexports.x = to export const x =require(variable) → dynamic import()__dirname/__filename to import.meta.url equivalentspackage.json: add "type": "module"After migrating each file (or small batch):
After all files are migrated:
## Migration complete: [from] → [to]
### Files migrated
- [N] files successfully migrated
- [N] files skipped (reason)
### Dependencies
- Added: [list]
- Removed: [list]
### Breaking changes
- [Any API changes callers need to update]
### Manual attention needed
- [Files that need human review]
- [Edge cases that couldn't be auto-migrated]
### Tests
- [N] tests passing
- [N] tests updated for new API
- [N] new tests added