Stack Gems
Menu
← Catalog

ast-grep

MIT structural AST search and rewrite (sg)

Rust / Terminal · OSS/MIT · 16.3k

Reviewed 2026-09-12 · last push 2026-10-15 · repo checked 2026-10-19

What's Good

MIT. ast-grep/ast-grep (`sg`). Pattern-based structural search, lint (`scan`), and codemod rewrite across many languages via tree-sitter. Interactive rewrite, LSP, and Node API (`@ast-grep/napi`). Homepage ast-grep.github.io; source github.com/ast-grep/ast-grep.

The Catch

Vs Semgrep (SAST/SCA product with Free Edition caps) and ripgrep (text search): ast-grep is the *structural AST CLI/codemod*, not a hosted AppSec platform and not byte/regex grep. You author AST patterns; text-only hunts still belong to rg. Slug is `ast-grep` (binary often `sg`).

Verdict

MIT AST search/rewrite. Free forever; match syntax trees, not just strings.

Embed

Maintainer? Add the badge to your README. It is free, links to this review, and there is no paid version.

Reviewed on Stack Gems

Markdown

[![Reviewed on Stack Gems](https://stackgems.com/badge/ast-grep.svg)](https://stackgems.com/gems/ast-grep)

HTML

<a href="https://stackgems.com/gems/ast-grep"><img src="https://stackgems.com/badge/ast-grep.svg" alt="ast-grep reviewed on Stack Gems" height="20"></a>

Related

Rust →