A CLI tool for structural code search, linting, and rewriting using abstract syntax trees, written in Rust.
ast-grep is a command-line interface tool that uses abstract syntax trees to perform structural search, linting, and rewriting of source code. It allows developers to write patterns that match code based on its syntactical structure rather than plain text, enabling precise and scalable code transformations and analysis.
Open-source library authors needing to manage breaking changes, tech leads enforcing custom code practices, and security researchers writing fast, structural rules for code analysis.
It offers an intuitive pattern syntax isomorphic to everyday code, combined with high performance from Rust and tree-sitter, making AST manipulation accessible without deep compiler expertise.
⚡A CLI tool for code structural search, lint and rewriting. Written in Rust
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Patterns are written as ordinary code with wildcards like $MATCH, making structural search accessible without deep AST knowledge, as emphasized in the README's introduction.
Built in Rust with multi-core utilization, enabling fast processing on large codebases, which is critical for massive-scale transformations as highlighted in the key features.
Uses tree-sitter grammars to parse multiple languages, allowing consistent structural analysis across different programming ecosystems, per the multi-language support feature.
Enables defining reusable linting and rewriting rules in YAML files, facilitating custom code quality workflows, as shown in the example of implementing eslint rules.
While patterns are intuitive, complex matching scenarios still require understanding of AST nodes, which can be a barrier despite the goal to democratize AST magic.
Lacks the deep language-specific features and ecosystems of dedicated tools like ESLint or Prettier, making it less suitable for advanced, single-language optimizations.
Accuracy and performance depend on the underlying tree-sitter grammars, which may have inconsistencies or bugs for edge cases in supported languages.