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
Jan 5, 2026 at 14:36
License
MIT
Total Downloads
69.1K
Supported Platforms
Unsupported Platforms
GitHub Repository
https://github.com/ast-grep/ast-grepDocumentation
https://ast-grep.github.io/