finds.dev← search

// the find

ast-grep/ast-grep

★ 16,195 · Rust · MIT · updated Oct 2026

⚡A CLI tool for code structural search, lint and rewriting. Written in Rust

ast-grep is a Rust CLI that searches, lints, and rewrites code by matching against the actual abstract syntax tree instead of text or regex, using tree-sitter grammars for 20+ languages. It's for anyone doing large codemods, enforcing custom lint rules across a codebase, or migrating a breaking API change where plain grep produces too many false positives.

Patterns are written as ordinary code with $VAR wildcards, so you don't need to learn tree-sitter query syntax to get started - a big usability win over raw tree-sitter or writing your own parser. Rules and rewrites can be defined in YAML and reused as a lint config, not just thrown away as one-off CLI invocations. It's genuinely fast on large repos since it's compiled and multi-threaded. Beyond the CLI there are napi, pyo3, and wasm bindings plus an LSP, so it's usable as a library from Node or Python and inside an editor, not just a terminal tool.

Matching is purely syntactic - there's no type or scope information, so it can't do semantic-aware renames or distinguish two variables with the same name in different scopes the way a language server or Semgrep-with-taint-tracking can. Tree-sitter grammar quality and completeness varies a lot by language, so less mainstream languages can hit parse edge cases or produce patterns that almost-but-don't-quite match. Getting a pattern to match reliably across formatting variations (optional parens, trailing commas, multiline vs single-line) takes real trial and error despite the 'looks like code' pitch. The codebase itself spans many crates (core, cli, napi, pyo3, wasm, lsp) so contributing beyond a simple rule fix means understanding which binding layer you're actually touching.

View on GitHub → Homepage ↗

// want more like this?

We dig through GitHub every week and send a few repos picked for what you actually care about — each with an honest take like this one.

Get finds in your inbox → Search again →