Search a codebase for a specific code pattern regardless of variable names.
Rewrite matching code automatically across many files at once.
Write custom lint rules in YAML to enforce team coding standards.
Help a library's users migrate to a new API by scripting the rewrite.
| adsharma/ast-grep | codeitlikemiley/antigravity-sdk-rust | codeitlikemiley/duplex-server-rs | |
|---|---|---|---|
| Stars | 3 | 3 | 3 |
| Language | Rust | Rust | Rust |
| Last pushed | — | — | 2025-09-18 |
| Maintenance | — | — | Quiet |
| Setup difficulty | easy | hard | moderate |
| Complexity | 3/5 | 4/5 | 3/5 |
| Audience | developer | developer | developer |
Figures from each repo's GitHub metadata at analysis time.
Installable via npm, pip, cargo, or homebrew with no extra configuration.
ast-grep, often shortened to sg, is a command line tool for finding and rewriting code based on its structure rather than its exact text. Most developers are familiar with grep, which searches files for matching lines of text. ast-grep works the same way in spirit, but instead of matching plain text it understands the actual structure of the code, called an abstract syntax tree, so it can find code that has the same shape even if variable names or formatting differ. Patterns are written to look like ordinary code you would write anyway. A special wildcard symbol, a dollar sign followed by capital letters, can stand in for any piece of code, similar to how a dot works in a regular expression but applied to code structure instead of raw text. This makes it possible to search for a pattern like a certain function call and automatically rewrite every match into a new form, across an entire codebase at once. The tool is written in Rust and built on tree-sitter, a widely used code parsing library, which lets it work across many programming languages and take advantage of multiple processor cores for speed. It can be installed through common package managers such as npm, pip, cargo, or homebrew, or built directly from source. Beyond one-off search and replace commands, ast-grep also supports writing linting rules in YAML, so teams can define and enforce their own coding standards. The project describes several groups of people it aims to help: open source library maintainers who want to help their users adopt breaking changes more smoothly, tech leads who want to enforce coding practices tailored to their team, and security researchers who want to write detection rules quickly. An online playground is also available for trying out patterns without installing anything.
A command line tool that searches and rewrites code by its structure instead of plain text, using patterns that look like ordinary code.
Mainly Rust. The stack also includes Rust, tree-sitter, CLI.
The README does not state a license.
Setup difficulty is rated easy, with roughly 5min to a first successful run.
Mainly developer.
This repo across BitVibe Labs
Don't trust strangers blindly. Verify against the repo.