ast-grep
ast-grep(sg) is a CLI tool for code structural search, lint, and rewriting.
ast-grep(sg) is a CLI tool for code structural search, lint, and rewriting.
To install this package, run one of the following:
ast-grep is an AST-based tool to search code by pattern code. Think it as your old-friend grep but it matches AST nodes instead of text. You can write patterns as if you are writing ordinary code. It will match all code that has the same syntactical structure. You can use $ sign + upper case letters as wildcard, e.g. $MATCH, to match any single AST node. Think it as REGEX dot ., except it is not textual.
Summary
ast-grep(sg) is a CLI tool for code structural search, lint, and rewriting.
Last Updated
Dec 15, 2025 at 16:38
License
MIT
Total Downloads
66.6K
Supported Platforms
GitHub Repository
https://github.com/ast-grep/ast-grepDocumentation
https://ast-grep.github.io/