ast-grep Code Search & Rewrite

•
1
•

Performs structural, AST-aware code search, refactoring, and deterministic codemods across 25 programming languages.

The ast-grep skill equips Claude with structural code manipulation capabilities using ast-grep (sg). Unlike text-based search tools like grep or ripgrep, ast-grep parses code into Abstract Syntax Trees, enabling precise pattern matching and automated rewrites based on syntax shape rather than text bytes. It includes a robust Python helper for offline pattern validation, dry-run safety checks, automated two-pass file updates, and multi-language support (JavaScript, TypeScript, Python, Rust, Go, and more). It is ideal for large-scale repo migrations, syntax modernization, API updates, and enforcing custom YAML linting rules.

主な機能

01Offline pattern validation preventing regex mistakes and syntax parse errors
021 GitHub stars
03Custom YAML rule scanning and automated autofix execution
04Safe dry-run previews before applying destructive multi-file codemods
05AST-aware structural code search and replacement across 25 languages
06Two-pass rewrite execution ensuring reliable batch file updates and JSON output

ユースケース

01Performing large-scale codebase migrations such as updating deprecated API patterns or typing conventions
02Executing linting passes and applying YAML-based architectural and code-quality rules across repos
03Finding structural anti-patterns like empty catch blocks, missing awaits, or unsafe type casts