AST-Grep Code Search

•
383
•

Performs structural code search and analysis using Abstract Syntax Tree patterns to locate complex code constructs across large codebases.

Unlock the power of structural code search with ast-grep, a tool that identifies code patterns based on their syntactic structure rather than just text. This skill enables developers to perform precise queries—such as finding async functions without error handling—by translating natural language requests into sophisticated AST-based rules. It is particularly useful for large-scale code audits, refactoring, and locating specific language constructs where traditional string-based search falls short.

Key Features

01Enables complex filtering using composite logic like 'all', 'any', and 'not'
02Supports relational matching using 'inside', 'has', and 'precedes' operators
03Facilitates both quick inline pattern searches and reusable YAML-based rules
04Translates natural language queries into structural AST search rules
05Provides AST inspection tools to identify specific node kinds and structures
06383 GitHub stars

Use Cases

01Finding all async functions that perform await operations without try-catch blocks
02Locating specific function calls with particular parameters within class methods
03Searching for structural anti-patterns or deprecated code constructs across a project