Loading...
Loading...
ast-grep rule writing and usage best practices. This skill should be used when writing, reviewing, or debugging ast-grep rules for code search, linting, and transformation. Triggers on tasks involving YAML rules, pattern syntax, meta variables, constraints, or code rewriting.
npx skill4agent add pproenca/dot-skills ast-greppatternkindhasinsideallanynotstopBy: endinsidehas# Inspect AST structure
ast-grep run --pattern '[code]' --lang [language] --debug-query=ast
# Test inline rule
echo "[code]" | ast-grep scan --inline-rules "[rule]" --stdin
# Test from file
ast-grep scan --rule [file.yml] [path]# Search with pattern (simple matches)
ast-grep run --pattern '[pattern]' --lang [language] [path]
# Search with rule file (complex queries)
ast-grep scan --rule [file.yml] [path]
# Apply fixes interactively
ast-grep scan --rule [file.yml] --interactive [path]stopBy: end--debug-query=ast\$VAR| Priority | Category | Impact | Prefix |
|---|---|---|---|
| 1 | Pattern Correctness | CRITICAL | |
| 2 | Meta Variable Usage | CRITICAL | |
| 3 | Rule Composition | HIGH | |
| 4 | Constraint Design | HIGH | |
| 5 | Rewrite Correctness | MEDIUM-HIGH | |
| 6 | Project Organization | MEDIUM | |
| 7 | Performance Optimization | MEDIUM | |
| 8 | Testing & Debugging | LOW-MEDIUM | |
pattern-valid-syntaxpattern-language-awarepattern-context-selectorpattern-avoid-comments-stringspattern-strictness-levelspattern-kind-vs-patternpattern-debug-astpattern-nthchild-matchingpattern-range-matchingmeta-naming-conventionmeta-single-nodemeta-reuse-bindingmeta-underscore-noncapturemeta-named-vs-unnamedmeta-multi-match-lazycompose-all-for-and-logiccompose-any-for-or-logiccompose-not-for-exclusioncompose-inside-for-contextcompose-has-for-childrencompose-matches-for-reusecompose-precedes-followscompose-field-targetingconst-kind-filterconst-regex-filterconst-not-inside-notconst-pattern-constraintconst-post-match-timingrewrite-preserve-semanticsrewrite-meta-variable-referencerewrite-transform-operationsrewrite-test-before-deployrewrite-syntax-validityorg-project-structureorg-unique-rule-idsorg-severity-levelsorg-file-filteringorg-message-clarityperf-specific-patternsperf-stopby-boundariesperf-thread-parallelismperf-avoid-regex-heavytest-valid-invalid-casestest-snapshot-updatestest-playground-firsttest-edge-cases| File | Description |
|---|---|
| AGENTS.md | Complete compiled guide with all rules |
| references/_sections.md | Category definitions and ordering |
| assets/templates/_template.md | Template for new rules |
| metadata.json | Version and reference information |