The workshop · Edition No. 19 · 13 Sep 2026

ast-grep/ast-grep

Searches and rewrites code by matching the syntax tree rather than the raw text, so a pattern written in the language itself finds every real match.

← The workshopRead the whole edition →

15.7k stars · MIT · 0.45.3 (2026-08-31) · Track this in Scout

Searches and rewrites code by matching the syntax tree rather than the raw text, so a pattern written in the language itself finds every real match.

▶Repo detailsthe review · specs · pros & cons · install

What it is

ast-grep is a single command-line program written in Rust. It parses your code into a tree, the same way a compiler does, and matches patterns against that tree rather than against the raw characters. It supports many languages and can also run a set of your own rules as a checker.

What it is good for. Anybody making the same change in many places. The pattern is written in the language itself: console.log($ARG) finds every one of those calls whatever the spacing or line breaks. Rewrites use the same notation, so a rename across four hundred files is reliable instead of hopeful. This is the best pairing on the page with a coding assistant. Instead of asking it to read the whole project and find every place something happens, you hand it one exact command that already found them.

Stars15.7k
LicenceMIT
Latest0.45.3 (2026-08-31)
Good
  • Fast on large projects, and there is nothing left running afterwards.
  • Rewrites are expressed the same way as searches, so what you found is what you change.
  • You can write your own rules as text files and run them as a project checker.
Watch for
  • Simple patterns are easy but the rule format has a real learning curve once you need conditions and relationships between pieces of code.
  • Language support depends on community grammars, so an unusual language may parse badly or not at all.
  • It is still before version 1.0 after several years, and the rule format has changed between releases, so saved rules can need revisiting after an upgrade.
Similar repositories
  • comby-tools/comby

    The same structural search and replace across many languages, using lighter parsing, so it is more forgiving and less precise.

    Track this in Scout
  • biomejs/gritql

    The same declarative searching and changing of code, now maintained inside the Biome project rather than as a standalone tool; it moved from getgrit/gritql.

    Track this in Scout
  • semgrep/semgrep

    The same idea of matching on code shape, aimed at security checks with a large public rule library, but heavier, licensed LGPL-2.1, and built to report problems rather than fix them.

    Track this in Scout
Install
npm install --global @ast-grep/cli     # or: pip install ast-grep-cli
# or: brew install ast-grep
ast-grep run --pattern 'console.log($ARG)' --lang ts src/
Screenshots
ast-grep/ast-grep: GitHub preview cardast-grep/ast-grep: Screenshot 1

Get the next edition in your inbox

A dozen repositories, opened and checked. The licence read, the last release dated, and the ones that did not make it named with the reason. It is the half most lists leave out.

No tracking pixels. One click to leave. The archive stays free either way.

We use your address to send the edition and nothing else. Confirm by email, leave in one click. How we handle it.