ast-grep

Installation
SKILL.md

ast-grep (sg)

ast-grep is a fast, polyglot tool that treats code as syntax trees instead of text. Reach for it whenever a task depends on code structure: mapping a file, finding a call shape, banning a pattern, or rewriting code at scale. It is a hybrid of grep, eslint, and codemod, backed by tree-sitter.

Prefer the short alias sg for every invocation, exactly as rg stands in for ripgrep; ast-grep is the same binary if sg is shadowed on a host. For exact flags, run sg <command> --help. When a rule is non-trivial, read references/rule-reference.md for the full rule object, transforms, and ESQuery selectors.

The four commands

Installs
5
Repository
zlliang/skills
First Seen
Jun 27, 2026
ast-grep — zlliang/skills