AST-Grep Structural Code Search & Refactoring
Automates structural code search, security scanning, and large-scale refactoring using AST analysis across 40+ programming languages.
This skill integrates ast-grep into Claude Code, enabling developers to perform semantic code searches and transformations that surpass traditional regex capabilities. By understanding the Abstract Syntax Tree (AST), it allows for precise pattern matching, automated code migrations (codemods), and the enforcement of complex security rules. Whether you are migrating deprecated APIs, identifying SQL injection risks, or refactoring nested function calls, this tool provides the structural awareness needed for safe and efficient code manipulation in polyglot environments.
Key Features
01Advanced security scanning with customizable YAML-based rules
02Automated code transformation and large-scale refactoring (codemods)
03Structural pattern matching using meta-variables and variadic arguments
0416 GitHub stars
05Relational search capabilities to find patterns within specific scopes or function contexts
06Support for over 40 programming languages including TypeScript, Python, and Rust
Use Cases
01Performing complex API migrations by rewriting function calls across an entire codebase
02Enforcing project-specific architectural patterns or linting rules that require AST context
03Scanning for security vulnerabilities like SQL injection or XSS using syntax-aware rules