ast-grep
Originally fromast-grep/claude-skill
Installation
SKILL.md
ast-grep
Workflow
- Write a test snippet representing the target code
- Write the rule (start with
pattern, escalate tokind+has/insideif needed) - Test with
--stdinbefore searching the codebase - Search the codebase once the rule matches
Critical Gotchas
Always use stopBy: end on relational rules
Without it, has/inside stop at the first non-matching node instead of traversing the full subtree:
# WRONG — will miss deeply nested matches
has:
pattern: await $EXPR
Related skills