code-search
Use when searching code, refactoring, running codemods, or choosing between search tools. Provides guidance on ast-grep vs ripgrep selection and usage patterns.
What this skill does
# Code Search & Refactoring Tools
## ast-grep vs ripgrep
### When to Use ast-grep
**Use `ast-grep` when structure matters.** It parses code and matches AST nodes, so results ignore comments/strings, understand syntax, and can **safely rewrite** code.
**Best for:**
- Refactors/codemods: rename APIs, change import forms, rewrite call sites or variable kinds
- Policy checks: enforce patterns across a repo (`scan` with rules + `test`)
- Editor/automation: LSP mode; `--json` output for tooling
- Any operation where you'll **apply changes** to code
### When to Use ripgrep
**Use `ripgrep` when text is enough.** It's the fastest way to grep literals/regex across files.
**Best for:**
- Recon: find strings, TODOs, log lines, config values, or non‑code assets
- Pre-filter: narrow candidate files before a precise pass
- Quick searches where you just need to **find text**
## Rule of Thumb
- Need correctness over speed, or you'll **apply changes** → start with `ast-grep`
- Need raw speed or you're just **hunting text** → start with `rg`
- Often combine: `rg` to shortlist files, then `ast-grep` to match/modify with precision
## Usage Examples
### ast-grep Examples
**Find structured code** (ignores comments/strings):
```bash
ast-grep run -l TypeScript -p 'import $X from "$P"'
```
**Codemod** (only real `var` declarations become `let`):
```bash
ast-grep run -l JavaScript -p 'var $A = $B' -r 'let $A = $B' -U
```
**Find function calls with specific patterns:**
```bash
ast-grep run -l Python -p 'logger.$METHOD($$$ARGS)'
```
**Replace with transformation:**
```bash
ast-grep run -l TypeScript \
-p 'useQuery($ARGS)' \
-r 'useSuspenseQuery($ARGS)' \
-U
```
### ripgrep Examples
**Quick textual hunt:**
```bash
rg -n 'console\.log\(' -t js
```
**Find in specific file types:**
```bash
rg 'TODO|FIXME' -t py -t js
```
**Context around matches:**
```bash
rg -C 3 'error' -t log
```
**List files with matches:**
```bash
rg -l 'import.*React' -t tsx
```
### Combined Approach
**Speed + Precision:** Use `rg` to find candidates, then `ast-grep` for precise operations:
```bash
rg -l -t ts 'useQuery\(' | xargs ast-grep run -l TypeScript \
-p 'useQuery($A)' \
-r 'useSuspenseQuery($A)' \
-U
```
## Mental Model
| Aspect | ast-grep | ripgrep |
| ------------------- | -------------------------- | ----------------------- |
| **Unit of match** | AST node | Line |
| **False positives** | Low (understands syntax) | Depends on regex |
| **Rewrites** | First-class, safe | Requires sed/awk, risky |
| **Speed** | Slower (parses code) | Fastest (text only) |
| **Use case** | Structural search/refactor | Text search/grep |
## Quick Decision Tree
```
Need to modify code?
├─ Yes → ast-grep (safe, structural rewrites)
└─ No
├─ Searching code structure? → ast-grep (accurate)
└─ Just finding text? → ripgrep (fastest)
```
## Common Patterns
### Finding all function definitions
```bash
# ast-grep (language-aware)
ast-grep run -l Python -p 'def $NAME($$$PARAMS): $$$BODY'
# ripgrep (text-based, faster but less precise)
rg '^def \w+\(' -t py
```
### Refactoring API calls
```bash
# ast-grep: Safe, precise
ast-grep run -l JavaScript \
-p 'axios.get($URL)' \
-r 'fetch($URL)' \
-U
# ripgrep: Don't use for rewrites (will match in comments/strings)
```
### Finding TODOs
```bash
# ripgrep: Perfect for this
rg 'TODO:|FIXME:' --color=always
# ast-grep: Overkill for text search
```
Related in General
modeling-omnistudio-epc-catalog
IncludedSalesforce Industries CME EPC product-modeling skill for Product2-based catalog creation. Use when creating EPC products, configuring product attributes, building offer bundles with Product Child Items, or reviewing EPC DataPack JSON metadata for product catalog changes. TRIGGER when: user creates or updates Product2 EPC records, AttributeAssignment payloads, AttributeMetadata/AttributeDefaultValues, Offer bundles, or ProductChildItem relationships. DO NOT TRIGGER when: designing OmniScripts/FlexCards/Integration Procedures (use building-omnistudio-omniscript, building-omnistudio-flexcard, or building-omnistudio-integration-procedure), implementing Apex business logic (use generating-apex), or troubleshooting deployment pipelines (use deploying-metadata).
relationship-science-coach
IncludedUse this skill for direct, practical adult relationship coaching: couples conflict, repair, trust, marriage, dating, flirting, attachment patterns, emotional connection, sex, desire differences, eroticism, kink negotiation, affection, love languages, breakups, and long-term passion. Draw on Gottman, EFT and Hold Me Tight, attachment science, modern sex research, Perel, Nagoski, Kerner, Schnarch, Love and Stosny, and flexible love-language tools. Be concrete and low-hedge. Redirect only for imminent danger, abuse, coercive control, minors, non-consent, self-harm, stalking, or medical/legal/psychiatric decisions.
building-sf-integrations
IncludedSalesforce integration architecture and runtime plumbing with 120-point scoring. Use this skill to set up Named Credentials, External Credentials, External Services, REST/SOAP callout patterns, Platform Events, and Change Data Capture. TRIGGER when: user sets up Named Credentials, External Services, REST/SOAP callouts, Platform Events, CDC, or touches .namedCredential-meta.xml files. DO NOT TRIGGER when: Connected App/OAuth config (use configuring-connected-apps), Apex-only logic (use generating-apex), or data import/export (use handling-sf-data).
venue-templates
IncludedAccess comprehensive LaTeX templates, formatting requirements, and submission guidelines for major scientific publication venues (Nature, Science, PLOS, IEEE, ACM), academic conferences (NeurIPS, ICML, CVPR, CHI), research posters, and grant proposals (NSF, NIH, DOE, DARPA). This skill should be used when preparing manuscripts for journal submission, conference papers, research posters, or grant proposals and need venue-specific formatting requirements and templates.
let-fate-decide
IncludedDraws the 12 Houses of the Zodiac Tarot spread to inject entropy into planning when prompts are vague, ambiguous, or casually delegated. Interprets the spread to guide next steps. Use when the user says 'let fate decide', 'YOLO', 'whatever', 'idk', or other nonchalant phrases, makes Yu-Gi-Oh references, or when you are about to arbitrarily pick between multiple reasonable approaches. Prefer over ask-questions-if-underspecified when the user's tone is casual or playful rather than precision-seeking.
net-ops
IncludedCross-platform network troubleshooting (Windows, macOS, Linux) via local or remote shell. Use for: DNS broken, can't resolve hostnames, nslookup/dig works but apps fail, NRPT, WFP, scutil, /etc/resolver, systemd-resolved, /etc/resolv.conf, NetworkManager, VPN DNS leak residue (ProtonVPN/Mullvad/WireGuard/AnyConnect), AV/firewall blocking DNS or DoH, Tailscale DNS interaction, intermittent connectivity, remote diagnostics over SSH.