AST-grep(sg) is a CLI tool for code structural search, lint, and rewriting

ast-grep is a CLI tool that allows users to search, lint, and rewrite code based on its abstract syntax tree (AST). It functions similarly to the grep tool but uses AST nodes instead of text for matching. Users can write patterns in the form of ordinary code, with the ability to use wildcard characters like $MATCH to match any single AST node. This tool is available for installation on various platforms and can also be built from source. Key features include an intuitive pattern language, an API for AST traversal and manipulation, YAML configuration for writing new rules, and a user-friendly command line interface. The goal of ast-grep is to make AST programming more accessible to everyone, whether they are open source library authors, tech leads, or security researchers.

https://github.com/ast-grep/ast-grep

To top