Guides writing, reviewing, and debugging ast-grep rules for code search, linting, and transformation with YAML patterns, meta variables, constraints, and testing workflows.
npx claudepluginhub joshuarweaver/cascade-code-general-misc-1 --plugin pproenca-dot-skills-1This skill uses the workspace's default tool permissions.
Comprehensive best practices guide for ast-grep rule writing and usage, maintained by the ast-grep community. Contains 46 rules across 8 categories, prioritized by impact to guide automated rule generation and code transformation.
Applies Acme Corporation brand guidelines including colors, fonts, layouts, and messaging to generated PowerPoint, Excel, and PDF documents.
Builds DCF models with sensitivity analysis, Monte Carlo simulations, and scenario planning for investment valuation and risk assessment.
Calculates profitability (ROE, margins), liquidity (current ratio), leverage, efficiency, and valuation (P/E, EV/EBITDA) ratios from financial statements in CSV, JSON, text, or Excel for investment analysis.
Comprehensive best practices guide for ast-grep rule writing and usage, maintained by the ast-grep community. Contains 46 rules across 8 categories, prioritized by impact to guide automated rule generation and code transformation.
Reference these guidelines when:
Follow this workflow when creating ast-grep rules for code search:
Clarify what you want to find:
Write a sample code snippet representing the desired match pattern.
Choose the right approach:
pattern for simple structureskind with has/inside for complex structuresall, any, or not for compound queriesstopBy: end for relational rules (inside, has) to ensure complete search# 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]
Deploy the validated rule:
# 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 - Ensures complete subtree traversal for relational rules--debug-query=ast to verify structure matching\$VAR or single quotes for shell commands| Priority | Category | Impact | Prefix |
|---|---|---|---|
| 1 | Pattern Correctness | CRITICAL | pattern- |
| 2 | Meta Variable Usage | CRITICAL | meta- |
| 3 | Rule Composition | HIGH | compose- |
| 4 | Constraint Design | HIGH | const- |
| 5 | Rewrite Correctness | MEDIUM-HIGH | rewrite- |
| 6 | Project Organization | MEDIUM | org- |
| 7 | Performance Optimization | MEDIUM | perf- |
| 8 | Testing & Debugging | LOW-MEDIUM | test- |
pattern-valid-syntax - Use valid parseable code as patternspattern-language-aware - Account for language-specific syntax differencespattern-context-selector - Use context and selector for code fragmentspattern-avoid-comments-strings - Avoid matching inside comments and stringspattern-strictness-levels - Configure pattern strictness appropriatelypattern-kind-vs-pattern - Choose kind or pattern based on specificity needspattern-debug-ast - Use debug query to inspect AST structurepattern-nthchild-matching - Use nthChild for index-based positional matchingpattern-range-matching - Use range for character position matchingmeta-naming-convention - Follow meta variable naming conventionsmeta-single-node - Match single AST nodes with meta variablesmeta-reuse-binding - Reuse meta variables to enforce equalitymeta-underscore-noncapture - Use underscore prefix for non-capturing matchesmeta-named-vs-unnamed - Use double dollar for unnamed node matchingmeta-multi-match-lazy - Understand multi-match variables are lazycompose-all-for-and-logic - Use all for AND logic between rulescompose-any-for-or-logic - Use any for OR logic between rulescompose-not-for-exclusion - Use not for exclusion patternscompose-inside-for-context - Use inside for contextual matchingcompose-has-for-children - Use has for child node requirementscompose-matches-for-reuse - Use matches for rule reusabilitycompose-precedes-follows - Use precedes and follows for sequential positioningcompose-field-targeting - Use field to target specific sub-nodesconst-kind-filter - Use kind constraints to filter meta variablesconst-regex-filter - Use regex constraints for text patternsconst-not-inside-not - Avoid constraints inside not rulesconst-pattern-constraint - Use pattern constraints for structural filteringconst-post-match-timing - Understand constraints apply after matchingrewrite-preserve-semantics - Preserve program semantics in rewritesrewrite-meta-variable-reference - Reference all necessary meta variables in fixrewrite-transform-operations - Use transform for complex rewritesrewrite-test-before-deploy - Test rewrites on representative coderewrite-syntax-validity - Ensure fix templates produce valid syntaxorg-project-structure - Use standard project directory structureorg-unique-rule-ids - Use unique descriptive rule IDsorg-severity-levels - Assign appropriate severity levelsorg-file-filtering - Use file filtering for targeted rulesorg-message-clarity - Write clear actionable messagesperf-specific-patterns - Use specific patterns over generic onesperf-stopby-boundaries - Use stopBy to limit search depthperf-thread-parallelism - Leverage parallel scanning with threadsperf-avoid-regex-heavy - Avoid heavy regex in hot pathstest-valid-invalid-cases - Write both valid and invalid test casestest-snapshot-updates - Use snapshot testing for fix verificationtest-playground-first - Test patterns in playground firsttest-edge-cases - Test edge cases and boundary conditionsRead individual reference files for detailed explanations and code examples:
| 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 |