ast-grep is a Rust-based command-line utility designed for structural code searching, static analysis, linting, and automated source code rewriting. It uses Tree-sitter to parse source files into abstract syntax trees instead of relying exclusively on textual pattern matching. Developers can construct search patterns using familiar programming syntax and metavariables representing code structures. Declarative YAML rules support complex matching conditions, customized diagnostics, and automated fixes. Integrated rewriting functionality facilitates large-scale refactoring and library migration workflows. Multithreaded processing enables efficient analysis across extensive software repositories. Programmable interfaces are available for JavaScript, Python, and WebAssembly. Supported languages include JavaScript, TypeScript, Python, Rust, Go, Java, and C++.

Features

  • Abstract syntax tree-based structural code searching through Tree-sitter parsing and language-aware pattern matching
  • Intuitive code patterns with reusable metavariables for matching and capturing complex syntactic structures
  • Automated source code rewriting for large-scale refactoring, API migrations, and repetitive code transformations
  • Declarative YAML linting rules with relational matching conditions, customized diagnostics, and automated fixes
  • Multithreaded repository scanning with extensive programming language compatibility and custom parser integration
  • Programmable JavaScript, Python, and WebAssembly APIs with structured JSON reporting and rule testing tools

Project Samples

Project Activity

See All Activity >

License

MIT License

Follow ast-grep

ast-grep Web Site

Other Useful Business Software
$300 Free Credits to Build on Google Cloud Icon
$300 Free Credits to Build on Google Cloud

New customers can spin up VMs, build with AI, and query data at no cost.

Put your $300 in credit toward real workloads, then keep building with free monthly usage for 20+ products. No commitment and no charge until you upgrade.
Start Free
Rate This Project
Login To Rate This Project

User Reviews

Be the first to post a review of ast-grep!

Additional Project Details

Operating Systems

Linux, Mac, Windows

Programming Language

Rust

Related Categories

Rust Source Code Analysis Tool, Rust Linters

Registered

57 minutes ago