rg Code Search Expert knowledge for using (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 ( , ) | Filtering files by mtime, size, or | | Multi-line pattern matching across source files | Locating files to feed into another tool | | Use this skill when... | Use binary-analysis instead when... | |---|---| | Searching s…

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

rg Code Search Expert knowledge for using (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 ( , ) | Filtering files by mtime, size, or | | Multi-line pattern matching across source files | Locating files to feed into another tool | | Use this skill when... | Use binary-analysis instead when... | |---|---| | Searching s…

# Lines ending with return\nrg '^class \\w+:' # Python class definitions\n\n# Character classes\nrg 'TODO|FIXME|XXX' # Find markers\nrg '[Ee]rror' # Error or error\nrg '\\d{3}-\\d{4}' # Phone numbers","type":"text"}]},{"type":"heading","attrs":{"level":3},"content":[{"text":"Multi-line Search","type":"text"}]},{"type":"code_block","attrs":{"wrap":false,"language":"bash"},"content":[{"text":"# Multi-line patterns\nrg -U 'fn.*\\{.*\\}' # Function definitions (Rust)\nrg -U 'struct.*{[^}]*}' # Struct definitions\n\n# Context lines\nrg -A 5 pattern # Show 5 lines after\nrg -B 3 pattern # Show 3 lines before\nrg -C 2 pattern # Show 2 lines before and after","type":"text"}]},{"type":"heading","attrs":{"level":3},"content":[{"text":"Output Formatting","type":"text"}]},{"type":"code_block","attrs":{"wrap":false,"language":"bash"},"content":[{"text":"# Control output\nrg -l pattern # List files with matches only\nrg -c pattern # Count matches per file\nrg --count-matches pattern # Total match count\n\n# Show context\nrg -n pattern # Show line numbers (default)\nrg -N pattern # Don't show line numbers\nrg --heading pattern # Group by file (default)\nrg --no-heading pattern # Don't group by file\n\n# Customize output\nrg --vimgrep pattern # Vim-compatible format\nrg --json pattern # JSON output","type":"text"}]},{"type":"heading","attrs":{"level":2},"content":[{"text":"Advanced Filtering","type":"text"}]},{"type":"heading","attrs":{"level":3},"content":[{"text":"Path Filtering","type":"text"}]},{"type":"code_block","attrs":{"wrap":false,"language":"bash"},"content":[{"text":"# Search in specific directories\nrg pattern src/ # Only src/ directory\nrg pattern src/ tests/ # Multiple directories\n\n# Exclude paths\nrg pattern -g '!target/' # Exclude target/\nrg pattern -g '!{dist,build,node_modules}/' # Exclude multiple\n\n# Full path matching\nrg pattern -g '**/test/**' # Only test directories","type":"text"}]},{"type":"heading","attrs":{"level":3},"content":[{"text":"Content Filtering","type":"text"}]},{"type":"code_block","attrs":{"wrap":false,"language":"bash"},"content":[{"text":"# Search only in files containing pattern\nrg --files-with-matches \"import.*React\" | xargs rg \"useState\"\n\n# Exclude files by content\nrg pattern --type-not markdown\n\n# Search only uncommitted files\nrg pattern $(git diff --name-only)","type":"text"}]},{"type":"heading","attrs":{"level":3},"content":[{"text":"Size and Hidden Files","type":"text"}]},{"type":"code_block","attrs":{"wrap":false,"language":"bash"},"content":[{"text":"# Include hidden files\nrg pattern -u # Include hidden\nrg pattern -uu # Include hidden + .gitignore'd\nrg pattern -uuu # Unrestricted: everything\n\n# Exclude by size\nrg pattern --max-filesize 1M # Skip files over 1MB","type":"text"}]},{"type":"heading","attrs":{"level":2},"content":[{"text":"Code Search Patterns","type":"text"}]},{"type":"heading","attrs":{"level":3},"content":[{"text":"Finding Definitions","type":"text"}]},{"type":"code_block","attrs":{"wrap":false,"language":"bash"},"content":[{"text":"# Function definitions\nrg '^def \\w+\\(' # Python functions\nrg 'fn \\w+\\(' # Rust functions\nrg '^function \\w+\\(' # JavaScript functions\nrg '^\\s*class \\w+' # Class definitions\n\n# Interface/type definitions\nrg '^interface \\w+' # TypeScript interfaces\nrg '^type \\w+ =' # Type aliases\nrg '^struct \\w+' # Struct definitions (Rust/Go)","type":"text"}]},{"type":"heading","attrs":{"level":3},"content":[{"text":"Finding Usage","type":"text"}]},{"type":"code_block","attrs":{"wrap":false,"language":"bash"},"content":[{"text":"# Find function calls\nrg 'functionName\\(' # Direct calls\nrg '\\.methodName\\(' # Method calls\n\n# Find imports\nrg '^import.*module_name' # Python imports\nrg '^use.*crate_name' # Rust uses\nrg \"^import.*'package'\" # JavaScript imports","type":"text"}]},{"type":"heading","attrs":{"level":3},"content":[{"text":"Code Quality Checks","type":"text"}]},{"type":"code_block","attrs":{"wrap":false,"language":"bash"},"content":[{"text":"# Find TODOs and FIXMEs\nrg 'TODO|FIXME|XXX|HACK' # Find all markers\nrg -t py '#\\s*TODO' # Python TODOs\nrg -t rs '//\\s*TODO' # Rust TODOs\n\n# Find debug statements\nrg 'console\\.log' # JavaScript\nrg 'println!' # Rust\nrg 'print\\(' # Python\n\n# Find security issues\nrg 'password.*=|api_key.*=' # Potential secrets\nrg 'eval\\(' # Eval usage\nrg 'exec\\(' # Exec usage","type":"text"}]},{"type":"heading","attrs":{"level":3},"content":[{"text":"Testing Patterns","type":"text"}]},{"type":"code_block","attrs":{"wrap":false,"language":"bash"},"content":[{"text":"# Find tests\nrg '^def test_' -t py # Python tests\nrg '#\\[test\\]' -t rs # Rust tests\nrg \"describe\\(|it\\(\" -t js # JavaScript tests\n\n# Find skipped tests\nrg '@skip|@pytest.mark.skip' -t py\nrg '#\\[ignore\\]' -t rs\nrg 'test\\.skip|it\\.skip' -t js","type":"text"}]},{"type":"heading","attrs":{"level":2},"content":[{"text":"File Operations","type":"text"}]},{"type":"heading","attrs":{"level":3},"content":[{"text":"Search and Replace","type":"text"}]},{"type":"code_block","attrs":{"wrap":false,"language":"bash"},"content":[{"text":"# Preview replacements\nrg pattern --replace replacement\n\n# Perform replacement (requires external tool)\nrg pattern -l | xargs sed -i 's/pattern/replacement/g'\n\n# With confirmation (using fd and interactive)\nfd -e rs | xargs rg pattern --files-with-matches | xargs -I {} sh -c 'vim -c \"%s/pattern/replacement/gc\" -c \"wq\" {}'","type":"text"}]},{"type":"heading","attrs":{"level":3},"content":[{"text":"Integration with Other Tools","type":"text"}]},{"type":"code_block","attrs":{"wrap":false,"language":"bash"},"content":[{"text":"# Pipe to other commands\nrg -l \"TODO\" | xargs wc -l # Count lines with TODOs\nrg \"function\" --files-with-matches | xargs nvim # Open files in editor\n\n# Combine with fd (prefer fd's native -x execution)\nfd -e py -x rg \"class.*Test\" {} # Find test classes\nfd -e rs -x rg \"unsafe\" {} # Find unsafe blocks\n\n# Count occurrences\nrg -c pattern | awk -F: '{sum+=$2} END {print sum}'","type":"text"}]},{"type":"heading","attrs":{"level":3},"content":[{"text":"Stats and Analysis","type":"text"}]},{"type":"code_block","attrs":{"wrap":false,"language":"bash"},"content":[{"text":"# Count total matches\nrg pattern --count-matches --no-filename | awk '{sum+=$1} END {print sum}'\n\n# Find most common matches\nrg pattern -o | sort | uniq -c | sort -rn\n\n# Files with most matches\nrg pattern -c | sort -t: -k2 -rn | head -10","type":"text"}]},{"type":"heading","attrs":{"level":2},"content":[{"text":"Performance Optimization","type":"text"}]},{"type":"heading","attrs":{"level":3},"content":[{"text":"Speed Tips","type":"text"}]},{"type":"code_block","attrs":{"wrap":false,"language":"bash"},"content":[{"text":"# Limit search\nrg pattern --max-depth 3 # Limit directory depth\nrg pattern -g '*.rs' -t rust # Use type filters\n\n# Parallel processing (default)\nrg pattern -j 4 # Use 4 threads\n\n# Memory management\nrg pattern --mmap # Use memory maps (faster)\nrg pattern --no-mmap # Don't use memory maps","type":"text"}]},{"type":"heading","attrs":{"level":3},"content":[{"text":"Large Codebase Strategies","type":"text"}]},{"type":"code_block","attrs":{"wrap":false,"language":"bash"},"content":[{"text":"# Narrow scope first\nrg pattern src/ # Specific directory\nrg pattern -t py -g '!test*' # Specific type, exclude tests\n\n# Use file list caching\nrg --files > /tmp/files.txt\nrg pattern $(cat /tmp/files.txt)\n\n# Exclude large directories\nrg pattern -g '!{target,node_modules,dist,build}/'","type":"text"}]},{"type":"heading","attrs":{"level":2},"content":[{"text":"Best Practices","type":"text"}]},{"type":"paragraph","content":[{"text":"When to Use rg","type":"text","marks":[{"type":"strong"}]}]},{"type":"bullet_list","content":[{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Searching code for patterns","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Finding function/class definitions","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Code analysis and auditing","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Refactoring support","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Security scanning","type":"text"}]}]}]},{"type":"paragraph","content":[{"text":"When to Use grep Instead","type":"text","marks":[{"type":"strong"}]}]},{"type":"bullet_list","content":[{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"POSIX compatibility required","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Simple one-off searches","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Piped input (stdin)","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"System administration tasks","type":"text"}]}]}]},{"type":"paragraph","content":[{"text":"Tips for Effective Searches","type":"text","marks":[{"type":"strong"}]}]},{"type":"bullet_list","content":[{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Escape regex special characters in patterns","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Use ","type":"text"},{"text":"-u","type":"text","marks":[{"type":"code_inline"}]},{"text":" flags when searching ignored/hidden files","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Exclude large binary/generated files with ","type":"text"},{"text":"--glob '!vendor'","type":"text","marks":[{"type":"code_inline"}]}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Prefer rg over grep for speed and smart defaults","type":"text"}]}]}]},{"type":"heading","attrs":{"level":2},"content":[{"text":"Quick Reference","type":"text"}]},{"type":"heading","attrs":{"level":3},"content":[{"text":"Essential Options","type":"text"}]},{"type":"table","attrs":{"layout":null},"content":[{"type":"tr","content":[{"type":"th","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Option","type":"text"}]}]},{"type":"th","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Purpose","type":"text"}]}]},{"type":"th","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Example","type":"text"}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"-t TYPE","type":"text","marks":[{"type":"code_inline"}]}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"File type filter","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"rg -t py pattern","type":"text","marks":[{"type":"code_inline"}]}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"-g GLOB","type":"text","marks":[{"type":"code_inline"}]}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Glob pattern","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"rg -g '*.rs' pattern","type":"text","marks":[{"type":"code_inline"}]}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"-i","type":"text","marks":[{"type":"code_inline"}]}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Case-insensitive","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"rg -i pattern","type":"text","marks":[{"type":"code_inline"}]}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"-s","type":"text","marks":[{"type":"code_inline"}]}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Case-sensitive","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"rg -s Pattern","type":"text","marks":[{"type":"code_inline"}]}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"-w","type":"text","marks":[{"type":"code_inline"}]}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Match whole words","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"rg -w word","type":"text","marks":[{"type":"code_inline"}]}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"-l","type":"text","marks":[{"type":"code_inline"}]}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Files with matches","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"rg -l pattern","type":"text","marks":[{"type":"code_inline"}]}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"-c","type":"text","marks":[{"type":"code_inline"}]}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Count per file","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"rg -c pattern","type":"text","marks":[{"type":"code_inline"}]}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"-A N","type":"text","marks":[{"type":"code_inline"}]}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Lines after","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"rg -A 5 pattern","type":"text","marks":[{"type":"code_inline"}]}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"-B N","type":"text","marks":[{"type":"code_inline"}]}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Lines before","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"rg -B 3 pattern","type":"text","marks":[{"type":"code_inline"}]}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"-C N","type":"text","marks":[{"type":"code_inline"}]}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Context lines","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"rg -C 2 pattern","type":"text","marks":[{"type":"code_inline"}]}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"-U","type":"text","marks":[{"type":"code_inline"}]}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Multi-line","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"rg -U 'pattern.*'","type":"text","marks":[{"type":"code_inline"}]}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"-u","type":"text","marks":[{"type":"code_inline"}]}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Include hidden","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"rg -u pattern","type":"text","marks":[{"type":"code_inline"}]}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"--replace","type":"text","marks":[{"type":"code_inline"}]}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Replace text","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"rg pattern --replace new","type":"text","marks":[{"type":"code_inline"}]}]}]}]}]},{"type":"heading","attrs":{"level":3},"content":[{"text":"File Types (Common)","type":"text"}]},{"type":"table","attrs":{"layout":null},"content":[{"type":"tr","content":[{"type":"th","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Type","type":"text"}]}]},{"type":"th","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Extensions","type":"text"}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"-t py","type":"text","marks":[{"type":"code_inline"}]}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Python (.py, .pyi)","type":"text"}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"-t rs","type":"text","marks":[{"type":"code_inline"}]}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Rust (.rs)","type":"text"}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"-t js","type":"text","marks":[{"type":"code_inline"}]}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"JavaScript (.js, .jsx)","type":"text"}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"-t ts","type":"text","marks":[{"type":"code_inline"}]}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"TypeScript (.ts, .tsx)","type":"text"}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"-t go","type":"text","marks":[{"type":"code_inline"}]}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Go (.go)","type":"text"}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"-t md","type":"text","marks":[{"type":"code_inline"}]}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Markdown (.md, .markdown)","type":"text"}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"-t yaml","type":"text","marks":[{"type":"code_inline"}]}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"YAML (.yaml, .yml)","type":"text"}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"-t json","type":"text","marks":[{"type":"code_inline"}]}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"JSON (.json)","type":"text"}]}]}]}]},{"type":"heading","attrs":{"level":3},"content":[{"text":"Common Command Patterns","type":"text"}]},{"type":"code_block","attrs":{"wrap":false,"language":"bash"},"content":[{"text":"# Find function definitions across codebase\nrg '^\\s*(def|fn|function)\\s+\\w+' -t py -t rs -t js\n\n# Find all imports\nrg '^(import|use|require)' -t py -t rs -t js\n\n# Find potential bugs\nrg 'TODO|FIXME|XXX|HACK|BUG'\n\n# Find test files and count tests\nrg -t py '^def test_' -c\n\n# Find large functions (50+ lines)\nrg -U 'def \\w+.*\\n(.*\\n){50,}' -t py\n\n# Security audit\nrg 'password|api_key|secret|token' -i -g '!*.{lock,log}'","type":"text"}]},{"type":"heading","attrs":{"level":2},"content":[{"text":"This makes rg the preferred tool for fast, powerful code search in development workflows.","type":"text"}]}]},"metadata":{"date":"2026-06-05","name":"rg-code-search","model":"sonnet","author":"@skillopedia","source":{"stars":35,"repo_name":"claude-plugins","origin_url":"https://github.com/laurigates/claude-plugins/blob/HEAD/tools-plugin/skills/rg-code-search/SKILL.md","repo_owner":"laurigates","body_sha256":"820c03e19a277d96f9936c6d9477ba9d18755923cc5da33f7db67555d7f5e035","cluster_key":"d0c1307585e793794ccba6b0b490822badf71e5193354370c71ebf0ea7a2be20","clean_bundle":{"format":"clean-skill-bundle-v1","source":"laurigates/claude-plugins/tools-plugin/skills/rg-code-search/SKILL.md","bundle_sha256":"0efc9067ab06e24171c2b2b3e503c0c51bc08e176e0bf76efdc7caf01637528a","attachment_count":0,"text_attachments":0,"binary_attachments":0},"cluster_size":1,"skill_md_path":"tools-plugin/skills/rg-code-search/SKILL.md","import_metadata":{"date":"2026-06-05","author":"@skillopedia","version":"v1","category":"software-engineering","category_label":"Engineering"},"exact_dupes_collapsed_into_this":0},"created":"2025-12-16T00:00:00.000Z","version":"v1","category":"software-engineering","modified":"2026-05-04T00:00:00.000Z","reviewed":"2026-04-25T00:00:00.000Z","import_tag":"clean-skills-v1","description":"ripgrep (rg) fast code search: smart defaults, regex, file filtering. Use when searching for text patterns, code snippets, or doing multi-file analysis.","allowed-tools":"Bash(rg *), Read, Grep, Glob","user-invocable":false}},"renderedAt":1782979504675}

rg Code Search Expert knowledge for using (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 ( , ) | Filtering files by mtime, size, or | | Multi-line pattern matching across source files | Locating files to feed into another tool | | Use this skill when... | Use binary-analysis instead when... | |---|---| | Searching s…