Skill Detail

TypeScript AST Refactor

Performs automated TypeScript refactoring using ts-morph and the TypeScript Compiler API. Handles rename operations, extract-function, and dead code elimination across large codebases.

Developer ToolsCursor
Developer Tools Cursor Published
Tool match: eslint โญ 6k GitHub stars โฌ‡ 15.2M/wk npm
INSTALL WITH ANY AGENT
npx skills add agentskillexchange/skills --skill typescript-ast-refactor-ts-morph Copy
Works best when you want a reusable capability, not another fragile one-off prompt.
At a glance
Install & setup
npm install –save-dev ts-morph
Author
David Sherret
Last updated
Mar 24, 2026
Quick brief

TypeScript AST Refactor uses ts-morph to programmatically manipulate TypeScript abstract syntax trees for large-scale codebase transformations. It supports extract-function refactoring by analyzing variable scope and closure dependencies, rename-symbol operations that propagate across import/export boundaries, and dead code elimination by tracing reachability from entry points. The tool leverages the TypeScript Compiler API diagnostics to validate transformations before writing, ensuring type safety is preserved. It handles complex scenarios like generic type parameter inference, conditional types, and mapped types. Batch mode processes entire directories with configurable glob patterns, and a dry-run mode generates unified diffs for review. Integration with ESLint auto-fix rules ensures code style consistency after transformation.