AST-Grep Structural Refactoring
Performs syntax-aware structural code search and bulk multi-file refactoring using AST patterns.
Leverage the power of ast-grep (CLI: sg) within Claude Code to perform rapid, syntax-aware code search and automated structural refactoring across multi-language repositories. By matching and transforming code via Abstract Syntax Tree patterns rather than raw text, this skill respects syntax, handles formatting variations, and safely updates call signatures, renames identifiers, and migrates deprecated APIs across hundreds of files without fragile manual edits.
主な機能
01Uses metavariable matching ($NAME, $$$ARGS) to accurately capture AST single nodes and sibling sequences
02Supports complex relational rules like inside, has, and follows to target deeply nested contexts
035 GitHub stars
04Executes syntax-aware structural search and replacement across 20+ programming languages
05Applies automated in-place multi-file updates with safe diff preview capabilities
06Handles TypeScript multi-kind identifier renames across expressions, types, and object properties
ユースケース
01Migrating deprecated APIs and restructuring function call signatures across a codebase
02Updating library import paths and wrapping legacy functions in modern error-handling logic
03Renaming types, interfaces, and methods across varied syntactic positions in TypeScript