| Zero or more nodes | `function $_($$) {}` |\n\n## Top 10 Essential Patterns\n\n```bash\n# 1. Find console.log calls\nsg -p 'console.log($_)'\n\n# 2. Find React hooks\nsg -p 'const [$_, $_] = useState($_)'\nsg -p 'useEffect($_, [$$])'\n\n# 3. Find function definitions\nsg -p 'function $NAME($$) { $$ }'\nsg -p 'def $NAME($$): $
L’interface est localisée ; les présentations et documents des Skills sont traduits automatiquement par IA dans votre langue. Le code, les commandes, chemins et termes techniques restent en version originale, et le document de l’auteur fait foi.
Explorer les Skills
Développement · SKILL.md

structural-search

structural-search

Search code by AST structure using ast-grep. Find semantic patterns like function calls, imports, class definitions instead of text patterns. Triggers on: find all calls to X, search for pattern, refactor usages, find where function is used, structural search, ast-grep, sg.

Independent GitHub snapshot · Automated classification · Original documentation governs

Documentation de la Skill

GitHub

name: structural-search description: "Search code by AST structure using ast-grep. Find semantic patterns like function calls, imports, class definitions instead of text patterns. Triggers on: find all calls to X, search for pattern, refactor usages, find where function is used, structural search, ast-grep, sg." license: MIT compatibility: "Requires ast-grep (sg) CLI tool. Install: brew install ast-grep (macOS) or cargo install ast-grep (cross-platform)." allowed-tools: "Bash" metadata: author: claude-mods

Structural Search

Search code by its abstract syntax tree (AST) structure. Finds semantic patterns that regex cannot match reliably.

Tools

ToolCommandUse For
ast-grepsg -p 'pattern'AST-aware code search

Pattern Syntax

PatternMatchesExample
$NAMENamed identifierfunction $NAME() {}
$_Any single nodeconsole.log($_)
$$Zero or more nodesfunction $_($$) {}

Top 10 Essential Patterns

# 1. Find console.log calls
sg -p 'console.log($_)'

# 2. Find React hooks
sg -p 'const [$_, $_] = useState($_)'
sg -p 'useEffect($_, [$$])'

# 3. Find function definitions
sg -p 'function $NAME($$) { $$ }'
sg -p 'def $NAME($$): $#x27; --lang python

# 4. Find imports
sg -p 'import $_ from "$_"'
sg -p 'from $_ import $_' --lang python

# 5. Find async patterns
sg -p 'await $_'
sg -p 'async function $NAME($$) { $$ }'

# 6. Find error handling
sg -p 'try { $$ } catch ($_) { $$ }'
sg -p 'if err != nil { $$ }' --lang go

# 7. Find potential issues
sg -p '$_ == $_'           # == instead of ===
sg -p 'eval($_)'           # Security risk
sg -p '$_.innerHTML = $_'  # XSS vector

# 8. Preview refactoring
sg -p 'console.log($_)' -r 'logger.info($_)'

# 9. Apply refactoring
sg -p 'var $NAME = $_' -r 'const $NAME = $_' --rewrite

# 10. Search specific language
sg -p 'pattern' --lang typescript

Quick Reference

TaskCommand
Find patternsg -p 'pattern'
Specific languagesg -p 'pattern' --lang python
Replace (preview)sg -p 'old' -r 'new'
Replace (apply)sg -p 'old' -r 'new' --rewrite
Show contextsg -p 'pattern' -A 3
JSON outputsg -p 'pattern' --json
File list onlysg -p 'pattern' -l
Count matchessg -p 'pattern' --count
Run YAML rulessg scan

When to Use

  • Finding all usages of a function/method
  • Locating specific code patterns (hooks, API calls)
  • Preparing for large-scale refactoring
  • When regex would match false positives
  • Detecting anti-patterns and security issues
  • Creating custom linting rules

Additional Resources

For complete patterns, load:

  • ./references/js-ts-patterns.md - JavaScript/TypeScript patterns
  • ./references/python-patterns.md - Python patterns
  • ./references/go-rust-patterns.md - Go and Rust patterns
  • ./references/security-patterns.md - Security vulnerability detection
  • ./references/advanced-usage.md - YAML rules and tool integration
  • ./assets/rule-template.yaml - Starter template for custom rules
Skills enregistrées
--lang python\n\n# 4. Find imports\nsg -p 'import $_ from \"$_\"'\nsg -p 'from $_ import $_' --lang python\n\n# 5. Find async patterns\nsg -p 'await $_'\nsg -p 'async function $NAME($$) { $$ }'\n\n# 6. Find error handling\nsg -p 'try { $$ } catch ($_) { $$ }'\nsg -p 'if err != nil { $$ }' --lang go\n\n# 7. Find potential issues\nsg -p '$_ == $_' # == instead of ===\nsg -p 'eval($_)' # Security risk\nsg -p '$_.innerHTML = $_' # XSS vector\n\n# 8. Preview refactoring\nsg -p 'console.log($_)' -r 'logger.info($_)'\n\n# 9. Apply refactoring\nsg -p 'var $NAME = $_' -r 'const $NAME = $_' --rewrite\n\n# 10. Search specific language\nsg -p 'pattern' --lang typescript\n```\n\n## Quick Reference\n\n| Task | Command |\n|------|---------|\n| Find pattern | `sg -p 'pattern'` |\n| Specific language | `sg -p 'pattern' --lang python` |\n| Replace (preview) | `sg -p 'old' -r 'new'` |\n| Replace (apply) | `sg -p 'old' -r 'new' --rewrite` |\n| Show context | `sg -p 'pattern' -A 3` |\n| JSON output | `sg -p 'pattern' --json` |\n| File list only | `sg -p 'pattern' -l` |\n| Count matches | `sg -p 'pattern' --count` |\n| Run YAML rules | `sg scan` |\n\n## When to Use\n\n- Finding all usages of a function/method\n- Locating specific code patterns (hooks, API calls)\n- Preparing for large-scale refactoring\n- When regex would match false positives\n- Detecting anti-patterns and security issues\n- Creating custom linting rules\n\n## Additional Resources\n\nFor complete patterns, load:\n- `./references/js-ts-patterns.md` - JavaScript/TypeScript patterns\n- `./references/python-patterns.md` - Python patterns\n- `./references/go-rust-patterns.md` - Go and Rust patterns\n- `./references/security-patterns.md` - Security vulnerability detection\n- `./references/advanced-usage.md` - YAML rules and tool integration\n- `./assets/rule-template.yaml` - Starter template for custom rules\n","licenseDocuments":[]}}
L’interface est localisée ; les présentations et documents des Skills sont traduits automatiquement par IA dans votre langue. Le code, les commandes, chemins et termes techniques restent en version originale, et le document de l’auteur fait foi.
Explorer les Skills
Développement · SKILL.md

structural-search

structural-search

Search code by AST structure using ast-grep. Find semantic patterns like function calls, imports, class definitions instead of text patterns. Triggers on: find all calls to X, search for pattern, refactor usages, find where function is used, structural search, ast-grep, sg.

Independent GitHub snapshot · Automated classification · Original documentation governs

Documentation de la Skill

GitHub

name: structural-search description: "Search code by AST structure using ast-grep. Find semantic patterns like function calls, imports, class definitions instead of text patterns. Triggers on: find all calls to X, search for pattern, refactor usages, find where function is used, structural search, ast-grep, sg." license: MIT compatibility: "Requires ast-grep (sg) CLI tool. Install: brew install ast-grep (macOS) or cargo install ast-grep (cross-platform)." allowed-tools: "Bash" metadata: author: claude-mods

Structural Search

Search code by its abstract syntax tree (AST) structure. Finds semantic patterns that regex cannot match reliably.

Tools

ToolCommandUse For
ast-grepsg -p 'pattern'AST-aware code search

Pattern Syntax

PatternMatchesExample
$NAMENamed identifierfunction $NAME() {}
$_Any single nodeconsole.log($_)
$$Zero or more nodesfunction $_($$) {}

Top 10 Essential Patterns

# 1. Find console.log calls
sg -p 'console.log($_)'

# 2. Find React hooks
sg -p 'const [$_, $_] = useState($_)'
sg -p 'useEffect($_, [$$])'

# 3. Find function definitions
sg -p 'function $NAME($$) { $$ }'
sg -p 'def $NAME($$): $#x27; --lang python

# 4. Find imports
sg -p 'import $_ from "$_"'
sg -p 'from $_ import $_' --lang python

# 5. Find async patterns
sg -p 'await $_'
sg -p 'async function $NAME($$) { $$ }'

# 6. Find error handling
sg -p 'try { $$ } catch ($_) { $$ }'
sg -p 'if err != nil { $$ }' --lang go

# 7. Find potential issues
sg -p '$_ == $_'           # == instead of ===
sg -p 'eval($_)'           # Security risk
sg -p '$_.innerHTML = $_'  # XSS vector

# 8. Preview refactoring
sg -p 'console.log($_)' -r 'logger.info($_)'

# 9. Apply refactoring
sg -p 'var $NAME = $_' -r 'const $NAME = $_' --rewrite

# 10. Search specific language
sg -p 'pattern' --lang typescript

Quick Reference

TaskCommand
Find patternsg -p 'pattern'
Specific languagesg -p 'pattern' --lang python
Replace (preview)sg -p 'old' -r 'new'
Replace (apply)sg -p 'old' -r 'new' --rewrite
Show contextsg -p 'pattern' -A 3
JSON outputsg -p 'pattern' --json
File list onlysg -p 'pattern' -l
Count matchessg -p 'pattern' --count
Run YAML rulessg scan

When to Use

  • Finding all usages of a function/method
  • Locating specific code patterns (hooks, API calls)
  • Preparing for large-scale refactoring
  • When regex would match false positives
  • Detecting anti-patterns and security issues
  • Creating custom linting rules

Additional Resources

For complete patterns, load:

  • ./references/js-ts-patterns.md - JavaScript/TypeScript patterns
  • ./references/python-patterns.md - Python patterns
  • ./references/go-rust-patterns.md - Go and Rust patterns
  • ./references/security-patterns.md - Security vulnerability detection
  • ./references/advanced-usage.md - YAML rules and tool integration
  • ./assets/rule-template.yaml - Starter template for custom rules
Skills enregistrées