ast-grep
A tool for code structural search, linting and rewriting.
The tool operates on abstract syntax trees, allowing users to search code by structural patterns rather than plain text. Patterns are written in a syntax similar to the target language, with `$`‑prefixed placeholders acting as wildcards that match any single AST node. This enables precise matching of code fragments that share the same syntactic shape, and the same mechanism can be used to rewrite matched code according to a supplied template.
It is useful for developers who need to perform large‑scale codebase refactoring, enforce custom linting rules, or locate specific programming constructs across multiple languages. The command‑line interface accepts a pattern, an optional rewrite template, and a language identifier, and can apply changes in‑place or output results for review.
The utility is distributed as a stable CLI package and can be installed via common package managers such as npm, pip, Cargo, Homebrew, Scoop, and others, or built from source with Rust. It provides a lightweight alternative to text‑based search tools, focusing on structural code analysis.
Reviews
Loading reviews…
Similar apps

Terminals & CLI
srgn
A grep-like tool which understands code syntax and also allows for manipulation.
File Management & Transfer
ripgrep
A line-oriented search tool that recursively searches your current directory for a regex pattern.

Markdown Editors
mq
Jq-like markdown processor.
Version Control & Git
gitlogue
Cinematic git commit replay.
Terminals & CLI
semantic-grep
A tool for semantic search using word embeddings (e.g. search for "death" and find "dead", "killing", "murder".)

Terminals & CLI
grex
Generate regular expressions from user-provided test cases.