ast-grep

Installation
SKILL.md

ast-grep

Search

ast-grep run --pattern 'console.log($ARG)' --lang javascript .        # simple pattern
ast-grep scan --inline-rules "<yaml>" <path>                          # relational/composite rule, no temp file
ast-grep scan --rule /path/rule.yml <path>                            # complex rule from file
echo '<code>' | ast-grep scan --inline-rules "<yaml>" --stdin         # test a rule on a snippet before scanning the codebase
ast-grep run --pattern '<code>' --lang <lang> --debug-query=<style>   # cst = target's full tree (find correct `kind`), ast = named nodes only, pattern = how ast-grep parsed your pattern

Gotchas:

  • Relational rules (inside, has) stop at the first non-matching node unless you add stopBy: end — always add it for deep traversal:
Installs
23
GitHub Stars
7
First Seen
Mar 15, 2026
ast-grep — trancong12102/agentskills