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/go-rust-patterns.md
View on GitHub# Go and Rust Patterns
Complete pattern library for ast-grep in Go and Rust.
## Go Patterns
### Function Declarations
```bash
# Find function declarations
sg -p 'func $NAME($$$) $_ { $$$ }' --lang go
# Find functions without return type
sg -p 'func $NAME($$$) { $$$ }' --lang go
# Find method declarations
sg -p 'func ($_ $_) $NAME($$$) $_ { $$$ }' --lang go
# Find pointer receiver methods
sg -p 'func ($_ *$_) $NAME($$$) $_ { $$$ }' --lang go
```
### Type Definitions
```bash
# Find interface definitions
sg -p 'type $NAME interface { $$$ }' --lang go
# Find struct definitions
sg -p 'type $NAME struct { $$$ }' --lang go
# Find type aliases
sg -p 'type $NAME = $_' --lang go
```
### Error Handling
```bash
# Find error checks
sg -p 'if err != nil { $$$ }' --lang go
# Find error returns
sg -p 'return $_, err' --lang go
# Find error wrapping
sg -p 'fmt.Errorf($$$)' --lang go
```
### Concurrency
```bash
# Find goroutines
sg -p 'go $_' --lang go
# Find defer statements
sg -p 'defer $_' --lang go
# Find channel operations
sg -p '$_ <- $_' --lang go
# Find select statements
sg -p 'select { $$$ }' --lang go
# Find mutex locks
sg -p '$_.Lock()' --lang go
sg -p '$_.Unlock()' --lang go
```
### Common Patterns
```bash
# Find make calls
sg -p 'make($_)' --lang go
# Find new calls
sg -p 'new($_)' --lang go
# Find range loops
sg -p 'for $_, $_ := range $_ { $$$ }' --lang go
# Find init functions
sg -p 'func init() { $$$ }' --lang go
```
---
## Rust Patterns
### Function Definitions
```bash
# Find function definitions with return type
sg -p 'fn $NAME($$$) -> $_ { $$$ }' --lang rust
# Find function definitions without return
sg -p 'fn $NAME($$$) { $$$ }' --lang rust
# Find async functions
sg -p 'async fn $NAME($$$) -> $_ { $$$ }' --lang rust
# Find public functions
sg -p 'pub fn $NAME($$$) -> $_ { $$$ }' --lang rust
```
### Impl Blocks
```bash
# Find impl blocks
sg -p 'impl $_ { $$$ }' --lang rust
# Find trait implementations
sg -p 'impl $_ for $_ { $$$ }' --lang rust
# Find generic impl
sg -p 'impl<$_> $_ { $$$ }' --lang rust
```
### Error Handling
```bash
# Find unwrap calls (potential panics)
sg -p '$_.unwrap()' --lang rust
# Find expect calls
sg -p '$_.expect($_)' --lang rust
# Find ? operator
sg -p '$_?' --lang rust
# Find Result types
sg -p 'Result<$_, $_>' --lang rust
# Find Option types
sg -p 'Option<$_>' --lang rust
```
### Match Expressions
```bash
# Find match expressions
sg -p 'match $_ { $$$ }' --lang rust
# Find if let patterns
sg -p 'if let $_ = $_ { $$$ }' --lang rust
# Find while let patterns
sg -p 'while let $_ = $_ { $$$ }' --lang rust
```
### Macros and Attributes
```bash
# Find derive attributes
sg -p '#[derive($$$)]' --lang rust
# Find macro invocations
sg -p '$_!($$$)' --lang rust
# Find specific macros
sg -p 'println!($$$)' --lang rust
sg -p 'vec![$$$]' --lang rust
```
### Async/Await
```bash
# Find .await calls
sg -p '$_.await' --lang rust
# Find tokio::spawn
sg -p 'tokio::spawn($_)' --lang rust
# Find async blocks
sg -p 'async { $$$ }' --lang rust
```
### Smart Pointers
```bash
# Find Box usage
sg -p 'Box::new($_)' --lang rust
# Find Rc usage
sg -p 'Rc::new($_)' --lang rust
# Find Arc usage
sg -p 'Arc::new($_)' --lang rust
# Find RefCell
sg -p 'RefCell::new($_)' --lang rust
```
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 |