aiskillstore/marketplace / skills/0xdarkmatter/structural-search
structural-search
VerifiedSearch 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.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 3.1 KB |
| assets/rule-template.yaml | config | 736 B |
| references/advanced-usage.md | markdown | 4.3 KB |
| references/go-rust-patterns.md | markdown | 3.2 KB |
| references/js-ts-patterns.md | markdown | 2.4 KB |
| references/python-patterns.md | markdown | 2.3 KB |
| references/security-patterns.md | markdown | 3.1 KB |
| scripts/.gitkeep | other | 0 B |
| skill-report.json | config | 53.8 KB |
references/python-patterns.md
View on GitHub# Python Patterns
Complete pattern library for ast-grep in Python.
## Function Definitions
```bash
# Find function definitions
sg -p 'def $NAME($$$): $$$' --lang python
# Find async function definitions
sg -p 'async def $NAME($$$): $$$' --lang python
# Find class definitions
sg -p 'class $NAME: $$$' --lang python
# Find class with inheritance
sg -p 'class $NAME($_): $$$' --lang python
```
## Decorators
```bash
# Find any decorated functions
sg -p '@$_
def $NAME($$$): $$$' --lang python
# Find pytest fixtures
sg -p '@pytest.fixture
def $NAME($$$): $$$' --lang python
# Find Flask routes
sg -p '@app.route($_)
def $NAME($$$): $$$' --lang python
# Find property decorators
sg -p '@property
def $NAME($$$): $$$' --lang python
# Find classmethod/staticmethod
sg -p '@classmethod
def $NAME($$$): $$$' --lang python
```
## Imports
```bash
# Find standard imports
sg -p 'import $_' --lang python
# Find from imports
sg -p 'from $_ import $_' --lang python
# Find aliased imports
sg -p 'import $_ as $_' --lang python
# Find wildcard imports (anti-pattern)
sg -p 'from $_ import *' --lang python
```
## Control Flow
```bash
# Find try-except blocks
sg -p 'try:
$$$
except $_:
$$$' --lang python
# Find with statements (context managers)
sg -p 'with $_ as $_: $$$' --lang python
# Find list comprehensions
sg -p '[$_ for $_ in $_]' --lang python
# Find dict comprehensions
sg -p '{$_: $_ for $_ in $_}' --lang python
# Find generator expressions
sg -p '($_ for $_ in $_)' --lang python
```
## String Formatting
```bash
# Find f-strings
sg -p 'f"$$$"' --lang python
# Find .format() calls
sg -p '"$$$".format($$$)' --lang python
# Find % formatting (old style)
sg -p '"$$$" % $_' --lang python
```
## Common Patterns
```bash
# Find main block
sg -p 'if __name__ == "__main__":
$$$' --lang python
# Find dataclass definitions
sg -p '@dataclass
class $NAME:
$$$' --lang python
# Find type hints
sg -p 'def $NAME($$$) -> $_: $$$' --lang python
# Find assert statements
sg -p 'assert $_' --lang python
# Find raise statements
sg -p 'raise $_' --lang python
```
## Testing Patterns
```bash
# Find test functions
sg -p 'def test_$NAME($$$): $$$' --lang python
# Find pytest parametrize
sg -p '@pytest.mark.parametrize($_)
def $NAME($$$): $$$' --lang python
# Find mock patches
sg -p '@patch($_)
def $NAME($$$): $$$' --lang python
```
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| receiving-code-reviewobra/superpowersUse when receiving code review feedback, before implementing suggestions, especially if feedback seems unclear or technically questionable - requires technical rigor and verification, not performative agreement or blind implementation | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| requesting-code-reviewobra/superpowersUse when completing tasks, implementing major features, or before merging to verify work meets requirements | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| using-git-worktreesobra/superpowersUse when starting feature work that needs isolation from current workspace or before executing implementation plans - ensures an isolated workspace exists via native tools or git worktree fallback | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| verification-before-completionobra/superpowersUse when about to claim work is complete, fixed, or passing, before committing or creating PRs - requires running verification commands and confirming output before making any success claims; evidence before assertions always | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |