ast-grep Workflow 1. Write a test snippet representing the target code 2. Write the rule (start with , escalate to + / if needed) 3. Test with before searching the codebase 4. Search the codebase once the rule matches Critical Gotchas Always use on relational rules Without it, / stop at the first non-matching node instead of traversing the full subtree: Escape metavariables in shell gets interpreted by the shell. Either escape or single-quote: Metavariables must be the sole content of an AST node These don't work : , , , Use for unnamed nodes (operators, punctuation). Use for zero-or-more nod…