ast-grep is a powerful CLI tool that lets you search and modify code based on its structure rather than text patterns. Using abstract syntax tree matching, it works like grep but understands code syntax, allowing you to write patterns that look like ordinary code and match all structurally identical code regardless of formatting.
Key capabilities include:
$VARIABLE wildcards to match any AST node--rewrite flag to automatically transform matching code at scalejq or other tools for custom processingPerfect for library authors migrating APIs, tech leads enforcing code standards, security researchers writing detection rules, or anyone automating repetitive code changes across large repositories.
$ pip install ast-grep-cli