ast_grep
Search code structurally using AST patterns. Groups matches by enclosing class or function, filtering out comment and string noise.
Instructions
AST-aware structural search across files. Matches are grouped by enclosing class/function, with kind tags [def]/[import]. Comment/string noise is filtered by default. Regex is auto-detected.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| json | No | Return machine-readable JSON output | |
| kind | No | Narrow results by classification kind | |
| count | No | Show match counts per file (-c) | |
| paths | Yes | File or directory paths to search | |
| pattern | Yes | Search pattern (literal or regex, auto-detected) | |
| maxCount | No | Maximum number of matches per file (-m) | |
| filesOnly | No | List matching files only (-l) | |
| wordMatch | No | Match whole words only (-w) | |
| caseInsensitive | No | Case-insensitive matching (-i) |