ast-grep
Share on:
Enter Your Mastodon Instance
Copy the link below to share to Mastodon
https://terminaltrove.com/ast-grep/
A CLI tool for code structural search, lint and rewriting.

ast-grep is a CLI tool for structural code search, linting and rewriting using abstract syntax tree patterns.
It lets you search code with structural patterns, reuse patterns across many languages, define metavariables on nodes, run bulk refactors with --rewrite, apply fixes in interactive modes, turn patterns into lint rules in YAML, organize rules in a project config, scan stdin or directories, and also export matches as JSON for piping into jq or other tools. Additionally, you can plug it into CI using the GitHub Action so rules include templates or transforms to migrate APIs, rename symbols or adjust call sites.
This tool helps developers, maintainers, library authors and anyone automating repetitive code rewrites or enforcing project-specific patterns in large repositories.
