Performant
Blazing fast search and replace across thousands of source code files, powered by parallel Rust.
Find Code by Syntax
ast-grep(sg) is a fast and polyglot tool for code structural search, lint, rewriting at large scale.
ast-grep is a code tool for structural search and replace. It is like syntax-aware grep/sed! You can write code patterns to locate and modify code, based on AST, in thousands of files, interactively.
ast-grep -p '$A && $A()' -r '$A?.()'
ast-grep is a versatile and flexible tool for linting code with AST patterns. You can easily add new customized rules with intuitive syntax and enjoy pretty error reporting out of box.
ast-grep scan
ast-grep also provides node-js binding to access syntax trees programmatically. You can use jQuery like utility methods to traverse syntax tree nodes. Node API also has opt-in type safety.
npm install @ast-grep/napi