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.
sg -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.
sg scan
ast-grep also provides node-js binding for manipulating syntax trees programmatically. You can use jQuery like utility methods to traverse and manipulate syntax tree nodes, or use operators to compose complex matching from simple patterns.
npm install @ast-grep/napi