AST-Grep Structural Search & Refactor

•
40
•

Performs structural code searching and systematic refactoring using Abstract Syntax Tree (AST) patterns across multiple programming languages.

The ast-grep skill empowers Claude to perform intelligent code analysis and modification by understanding the underlying structure of the source code rather than relying on brittle text-based searches. By leveraging AST patterns and metavariables, it allows developers to find complex code constructs, identify anti-patterns, and execute systematic refactorings with high precision. This skill is particularly valuable for large-scale codebase migrations, linting domain-specific logic in frameworks like Nextflow, and enforcing architectural standards through custom YAML rules that go beyond standard regex capabilities.

Key Features

01Automated code refactoring with rule-based 'fix' and 'update-all' capabilities
02Relational rules to search within specific contexts like 'inside' or 'has'
0340 GitHub stars
04Structural pattern matching using AST nodes instead of simple text or regex
05Multi-language support including JavaScript, Python, TypeScript, and Nextflow
06Metavariables for capturing and transforming specific code fragments

Use Cases

01Migrating deprecated API calls or function signatures across a large repository
02Identifying and fixing anti-patterns in complex Nextflow workflow definitions
03Automating the addition of error handling to unhandled asynchronous functions