Ast-grep Structural Search & Codemod

•
156
•

Performs syntax-aware code exploration and automated mechanical refactoring for Python and Zig using ast-grep.

This skill empowers Claude to go beyond simple text searches by utilizing ast-grep (sg) for structural code analysis and transformation. It enables precise, syntax-aware pattern matching and large-scale mechanical codemods in Python and Zig projects, ensuring that refactors respect the underlying code structure. The skill is specifically configured to manage repository-specific linting rules, run policy checks with 'sg scan', and maintain robust rule sets through automated testing and snapshot verification.

Key Features

01Syntax-aware structural search using abstract syntax tree (AST) patterns
02Project-wide policy enforcement and linting via 'sg scan'
03Integrated rule testing framework with snapshot support
04Automated mechanical codemods for large-scale, safe code rewrites
05Custom parser integration for Zig using local configuration files
06156 GitHub stars

Use Cases

01Refactoring deprecated API calls or patterns across a large multi-language codebase
02Enforcing project-specific architectural rules and coding standards
03Finding complex code patterns like specific error handling blocks that regex cannot match