Loading...
Loading...
Structural code search via ast-grep — use when code shape and element relationships matter, not just text. E.g., "find async functions without error handling", "refactor foo(a, b) to foo({ a, b })". Use Grep for simple name lookups.
npx skill4agent add poteto/noodle ast-greppatternkindhasinside--stdinstopBy: endhasinside# WRONG — will miss deeply nested matches
has:
pattern: await $EXPR
# RIGHT
has:
pattern: await $EXPR
stopBy: end$VAR# Double-quoted: escape with backslash
ast-grep scan --inline-rules "id: test
language: javascript
rule:
pattern: await \$EXPR" .
# Single-quoted: no escaping needed
ast-grep scan --inline-rules 'id: test
language: javascript
rule:
pattern: await $EXPR' .obj.on$EVENT"Hello $WORLD"a $OP b$jq$$OP$$$ARGSecho "async function test() { await fetch(); }" | ast-grep scan --inline-rules 'id: test
language: javascript
rule:
kind: function_declaration
has:
pattern: await $EXPR
stopBy: end' --stdinkindast-grep run --pattern 'your code here' --lang javascript --debug-query=cstcstastpatternreferences/rule_reference.md