rg-code-search
ripgrep (rg) fast code search: smart defaults, regex, file filtering. Use when searching for text patterns, code snippets, or doing multi-file analysis.
What this skill does
# rg Code Search
Expert knowledge for using `rg` (ripgrep) as a blazingly fast code search tool with powerful filtering and pattern matching.
## When to Use This Skill
| Use this skill when... | Use fd-file-finding instead when... |
|---|---|
| Searching file contents for text or regex patterns | Searching for files by name, extension, or path |
| Filtering matches by file type (`-t py`, `-t js`) | Filtering files by mtime, size, or `-type` |
| Multi-line pattern matching across source files | Locating files to feed into another tool |
| Use this skill when... | Use binary-analysis instead when... |
|---|---|
| Searching source code or text-encoded files | Extracting strings from compiled binaries or firmware |
| Auditing repos for hardcoded patterns in tracked files | Hunting for credentials inside ELF, Mach-O, or `.bin` blobs |
## Core Expertise
**ripgrep Advantages**
- Extremely fast (written in Rust)
- Respects `.gitignore` automatically
- Smart case-insensitive search
- Recursive by default
- Colorized output
- Multi-line search support
- Replace functionality
## Basic Usage
### Simple Search
```bash
# Basic search
rg pattern # Search in current directory
rg "import numpy" # Search for exact phrase
rg function_name # Search for function name
# Case-sensitive search
rg -s Pattern # Force case-sensitive
rg -i PATTERN # Force case-insensitive
```
### File Type Filtering
```bash
# Search specific file types
rg pattern -t py # Python files only
rg pattern -t rs # Rust files only
rg pattern -t js # JavaScript files
rg pattern -t md # Markdown files
# Multiple types
rg pattern -t py -t rs # Python and Rust
# List available types
rg --type-list # Show all known types
```
### Extension Filtering
```bash
# Filter by extension
rg pattern -g '*.rs' # Rust files
rg pattern -g '*.{js,ts}' # JavaScript and TypeScript
rg pattern -g '!*.min.js' # Exclude minified files
```
## Advanced Patterns
### Regular Expressions
```bash
# Word boundaries
rg '\bfunction\b' # Match whole word "function"
rg '\btest_\w+' # Words starting with test_
# Line anchors
rg '^import' # Lines starting with import
rg 'return$' # Lines ending with return
rg '^class \w+:' # Python class definitions
# Character classes
rg 'TODO|FIXME|XXX' # Find markers
rg '[Ee]rror' # Error or error
rg '\d{3}-\d{4}' # Phone numbers
```
### Multi-line Search
```bash
# Multi-line patterns
rg -U 'fn.*\{.*\}' # Function definitions (Rust)
rg -U 'struct.*{[^}]*}' # Struct definitions
# Context lines
rg -A 5 pattern # Show 5 lines after
rg -B 3 pattern # Show 3 lines before
rg -C 2 pattern # Show 2 lines before and after
```
### Output Formatting
```bash
# Control output
rg -l pattern # List files with matches only
rg -c pattern # Count matches per file
rg --count-matches pattern # Total match count
# Show context
rg -n pattern # Show line numbers (default)
rg -N pattern # Don't show line numbers
rg --heading pattern # Group by file (default)
rg --no-heading pattern # Don't group by file
# Customize output
rg --vimgrep pattern # Vim-compatible format
rg --json pattern # JSON output
```
## Advanced Filtering
### Path Filtering
```bash
# Search in specific directories
rg pattern src/ # Only src/ directory
rg pattern src/ tests/ # Multiple directories
# Exclude paths
rg pattern -g '!target/' # Exclude target/
rg pattern -g '!{dist,build,node_modules}/' # Exclude multiple
# Full path matching
rg pattern -g '**/test/**' # Only test directories
```
### Content Filtering
```bash
# Search only in files containing pattern
rg --files-with-matches "import.*React" | xargs rg "useState"
# Exclude files by content
rg pattern --type-not markdown
# Search only uncommitted files
rg pattern $(git diff --name-only)
```
### Size and Hidden Files
```bash
# Include hidden files
rg pattern -u # Include hidden
rg pattern -uu # Include hidden + .gitignore'd
rg pattern -uuu # Unrestricted: everything
# Exclude by size
rg pattern --max-filesize 1M # Skip files over 1MB
```
## Code Search Patterns
### Finding Definitions
```bash
# Function definitions
rg '^def \w+\(' # Python functions
rg 'fn \w+\(' # Rust functions
rg '^function \w+\(' # JavaScript functions
rg '^\s*class \w+' # Class definitions
# Interface/type definitions
rg '^interface \w+' # TypeScript interfaces
rg '^type \w+ =' # Type aliases
rg '^struct \w+' # Struct definitions (Rust/Go)
```
### Finding Usage
```bash
# Find function calls
rg 'functionName\(' # Direct calls
rg '\.methodName\(' # Method calls
# Find imports
rg '^import.*module_name' # Python imports
rg '^use.*crate_name' # Rust uses
rg "^import.*'package'" # JavaScript imports
```
### Code Quality Checks
```bash
# Find TODOs and FIXMEs
rg 'TODO|FIXME|XXX|HACK' # Find all markers
rg -t py '#\s*TODO' # Python TODOs
rg -t rs '//\s*TODO' # Rust TODOs
# Find debug statements
rg 'console\.log' # JavaScript
rg 'println!' # Rust
rg 'print\(' # Python
# Find security issues
rg 'password.*=|api_key.*=' # Potential secrets
rg 'eval\(' # Eval usage
rg 'exec\(' # Exec usage
```
### Testing Patterns
```bash
# Find tests
rg '^def test_' -t py # Python tests
rg '#\[test\]' -t rs # Rust tests
rg "describe\(|it\(" -t js # JavaScript tests
# Find skipped tests
rg '@skip|@pytest.mark.skip' -t py
rg '#\[ignore\]' -t rs
rg 'test\.skip|it\.skip' -t js
```
## File Operations
### Search and Replace
```bash
# Preview replacements
rg pattern --replace replacement
# Perform replacement (requires external tool)
rg pattern -l | xargs sed -i 's/pattern/replacement/g'
# With confirmation (using fd and interactive)
fd -e rs | xargs rg pattern --files-with-matches | xargs -I {} sh -c 'vim -c "%s/pattern/replacement/gc" -c "wq" {}'
```
### Integration with Other Tools
```bash
# Pipe to other commands
rg -l "TODO" | xargs wc -l # Count lines with TODOs
rg "function" --files-with-matches | xargs nvim # Open files in editor
# Combine with fd (prefer fd's native -x execution)
fd -e py -x rg "class.*Test" {} # Find test classes
fd -e rs -x rg "unsafe" {} # Find unsafe blocks
# Count occurrences
rg -c pattern | awk -F: '{sum+=$2} END {print sum}'
```
### Stats and Analysis
```bash
# Count total matches
rg pattern --count-matches --no-filename | awk '{sum+=$1} END {print sum}'
# Find most common matches
rg pattern -o | sort | uniq -c | sort -rn
# Files with most matches
rg pattern -c | sort -t: -k2 -rn | head -10
```
## Performance Optimization
### Speed Tips
```bash
# Limit search
rg pattern --max-depth 3 # Limit directory depth
rg pattern -g '*.rs' -t rust # Use type filters
# Parallel processing (default)
rg pattern -j 4 # Use 4 threads
# Memory management
rg pattern --mmap # Use memory maps (faster)
rg pattern --no-mmap # Don't use memory maps
```
### Large Codebase Strategies
```bash
# Narrow scope first
rg pattern src/ # Specific directory
rg pattern -t py -g '!test*' # Specific type, exclude tests
# Use file list caching
rg --files > /tmp/files.txt
rg pattern $(cat /tmp/files.txt)
# Exclude large directories
rg pattern -g '!{target,node_modules,dist,build}/'
```
## Best Practices
**When to Use rg**
- Searching code for patterns
- Finding function/class definitions
- Code analysis and auditing
- Refactoring support
- Security scanning
**When to Use grep Instead**
- POSIX compatibility required
- SiRelated 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.