← Back to Frontend and design systems
See how it helps
Codemods and deprecated API cleanup
Applies reviewable automated migrations and checks the semantic cases that mechanical transformations can miss.
codemods-deprecation-cleanup
Team members using this skill
When is it useful?
Use when an upgrade replaces APIs across many files or provides an official migration tool.
What does it help you do?
- Isolates mechanical changes from unrelated edits and manual fixes.
- Selects official or syntax-aware transformations for the actual code patterns.
- Audits aliases, async changes, placeholders and remaining deprecated calls.
Try asking this
Prepare a scoped deprecated API migration, show the mechanical diff and identify call sites needing manual semantic correction. Include an aliased import and a callback with changed semantics. Automatically transform only supported cases and list the remaining manual edits explicitly.
Detailed documentation
Read the skill’s original instructions, examples and checks in their authored language.
Show less
Codemods & Deprecation Cleanup
When to Use
Use when a package or framework upgrade deprecates or removes APIs across many call sites, or when upstream provides official migration schematics/codemods (@next/codemod, ng update, rector, django-upgrade, pyupgrade, cargo fix --edition).
Codemod Execution Discipline
1. Run Codemods on a Clean Tree & Separate Commits/Steps
- Never run an automated codemod on a dirty working tree mixed with manual edits.
- Run the codemod in an isolated step so its mechanical diff can be inspected line by line before applying manual edge-case fixes.
2. Vet Official vs. Custom AST Transformations
- JavaScript / TypeScript:
- Official framework codemods (
npx @next/codemod@latest <transform>,npx @tanstack/react-query-codemod,npx prisma,ng update). - For custom multi-file API migrations, prefer AST-aware tools (
jscodeshift,ts-morph,ast-grep) over fragile regex search-and-replace when call sites span multiple lines, aliased imports, or overloaded method names.
- Official framework codemods (
- PHP:
rector/rector(vendor/bin/rector process --dry-run) with targeted rule sets (LevelSetList,LaravelSetList,SymfonySetList,PHPUnitSetList).
- Python:
pyupgrade,django-upgrade,ruff check --select UP,bump-pydantic, orLibCSTtransforms.
- Rust:
cargo fixandcargo clippy --fixfor compiler-verified edition and deprecation migrations.
3. Mandatory Post-Codemod Audit ("Never Trust Codemod Output Blindly")
Automated codemods operate on syntax trees and often miss dynamic patterns, type nuances, or comments. After running any codemod, inspect git diff for:
- Broken Semantics & Edge Cases:
- Aliased or re-exported imports that the codemod skipped.
async/awaitadditions where the enclosing function was not markedasyncor callers were not updated to handle a returnedPromise.- Complex dynamic expressions wrapped in
/* TODO */or fallback casts (as any) inserted by the codemod.
- Formatting & Comment Preservation:
- Ensure the codemod did not strip important domain comments, license headers, or reformat untouched lines across the file. Run the project's formatter/linter only on the modified lines/files if needed.
- Complete Deprecation Removal:
- Grep for the deprecated symbol, import path, configuration key, or CLI flag across the entire repository (including test helpers, Storybook stories, seed scripts, and docs) to confirm zero stragglers remain.
Systematic Deprecation Replacement Without Codemods
When replacing deprecated APIs manually:
- Map the old contract vs. new contract (arguments, return values, error behavior, side effects, default options).
- Migrate call sites directly to the new canonical API rather than wrapping the new API in a permanent legacy-imitating helper—unless a temporary adapter is needed to stage a huge change, in which case mark it
@deprecatedwith a clear removal condition. - Run tests with deprecation warnings elevated to errors (e.g.,
node --throw-deprecation,pytest -W error::DeprecationWarning,PHPUnit failOnDeprecation="true",RUSTFLAGS="-D warnings") to prove the deprecated code path is no longer triggered at runtime.
Included files 1
SKILL.md
