Loading...
Loading...
Use when searching text in files, codebases, books, or documents. Use when finding files by pattern, searching large files that are too big to read fully, extracting specific content from many files, or when grep/find is too slow. Triggers on "search for", "find occurrences", "look for pattern", "search in files".
npx skill4agent add ratacat/claude-skills ripgrep.gitignore| Task | Command |
|---|---|
| Basic search | |
| Case insensitive | |
| Smart case (auto) | |
| Whole word only | |
| Fixed string (no regex) | |
| Show context lines | |
| Show line numbers | |
| Only filenames | |
| Files without match | |
| Count matches | |
| Only matching part | |
| Invert match | |
| Multiline search | |
-t-T# Search only Python files
rg -t py "def main"
# Search only JavaScript and TypeScript
rg -t js -t ts "import"
# Exclude test files
rg -T test "function"
# List all known types
rg --type-listpyjstsrustgojavaccpprbphphtmlcssjsonyamlmdtxtsh# Only .tsx files
rg -g "*.tsx" "useState"
# Exclude node_modules (in addition to gitignore)
rg -g "!node_modules/**" "pattern"
# Only files in src directory
rg -g "src/**" "pattern"
# Multiple globs
rg -g "*.js" -g "*.ts" "pattern"
# Case insensitive globs
rg --iglob "*.JSON" "pattern"# Skip files larger than 1MB
rg --max-filesize 1M "pattern"# Limit depth
rg --max-depth 2 "pattern"
# Search hidden files (dotfiles)
rg --hidden "pattern"
# Follow symlinks
rg -L "pattern"
# Ignore all ignore files (.gitignore, etc.)
rg --no-ignore "pattern"
# Progressive unrestricted (-u can stack up to 3 times)
rg -u "pattern" # --no-ignore
rg -uu "pattern" # --no-ignore --hidden
rg -uuu "pattern" # --no-ignore --hidden --binary# Lines after match
rg -A 5 "pattern"
# Lines before match
rg -B 5 "pattern"
# Lines before and after
rg -C 5 "pattern"
# Print entire file on match (passthrough mode)
rg --passthru "pattern"# Just filenames with matches
rg -l "pattern"
# Files without matches
rg --files-without-match "pattern"
# Count matches per file
rg -c "pattern"
# Count total matches (not lines)
rg --count-matches "pattern"
# Only the matched text (not full line)
rg -o "pattern"
# JSON output (for parsing)
rg --json "pattern"
# Vim-compatible output (file:line:col:match)
rg --vimgrep "pattern"
# With statistics
rg --stats "pattern"# Alternation
rg "foo|bar"
# Character classes
rg "[0-9]+"
rg "[a-zA-Z_][a-zA-Z0-9_]*"
# Word boundaries
rg "\bword\b"
# Quantifiers
rg "colou?r" # 0 or 1
rg "go+gle" # 1 or more
rg "ha*" # 0 or more
rg "x{2,4}" # 2 to 4 times
# Groups
rg "(foo|bar)baz"
# Lookahead/lookbehind (requires -P for PCRE2)
rg -P "(?<=prefix)content"
rg -P "content(?=suffix)"# Enable multiline mode
rg -U "start.*\nend"
# Dot matches newline too
rg -U --multiline-dotall "start.*end"
# Match across lines
rg -U "function\s+\w+\([^)]*\)\s*\{"# Simple replacement
rg "old" -r "new"
# Using capture groups
rg "(\w+)@(\w+)" -r "$2::$1"
# Remove matches (empty replacement)
rg "pattern" -r ""# Search in gzip, bzip2, xz, lz4, lzma, zstd files
rg -z "pattern" file.gz
rg -z "pattern" archive.tar.gz# Include binary files
rg --binary "pattern"
# Treat binary as text (may produce garbage)
rg -a "pattern"# Search and show only matching lines
rg "specific pattern" large_file.txt
# Limit matches to first N per file
rg -m 10 "pattern" huge_file.log
# Show byte offset for large file navigation
rg -b "pattern" large_file.txt
# Use with head/tail for pagination
rg "pattern" large_file.txt | head -100-t py-g "*.py"-F--max-depth--no-ignore-w# Python
rg "def \w+\(" -t py
# JavaScript/TypeScript
rg "(function|const|let|var)\s+\w+\s*=" -t js -t ts
rg "^\s*(async\s+)?function" -t js
# Go
rg "^func\s+\w+" -t go# Python
rg "^(import|from)\s+" -t py
# JavaScript
rg "^(import|require\()" -t js
# Go
rg "^import\s+" -t gorg "(TODO|FIXME|HACK|XXX):"# Python
rg "except\s+\w+:" -t py
# JavaScript
rg "\.catch\(|catch\s*\(" -t js# Python
rg "^class\s+\w+" -t py
# JavaScript/TypeScript
rg "^(export\s+)?(default\s+)?class\s+\w+" -t js -t ts# Find chapter headings
rg "^(Chapter|CHAPTER)\s+\d+" book.txt
# Find quoted text
rg '"[^"]{20,}"' document.txt
# Find paragraphs containing word
rg -C 2 "keyword" book.txt# Find files, then search
rg --files | xargs rg "pattern"
# Search and count by file
rg -c "pattern" | sort -t: -k2 -rn
# Search and open in editor
rg -l "pattern" | xargs code
# Extract unique matches
rg -o "\b[A-Z]{2,}\b" | sort -u
# Search multiple patterns from file
rg -f patterns.txt| Code | Meaning |
|---|---|
| 0 | Matches found |
| 1 | No matches found |
| 2 | Error occurred |
if rg -q "pattern" file.txt; then
echo "Found"
fi| Mistake | Fix |
|---|---|
| Pattern has special chars | Use |
| Can't find hidden files | Add |
| Missing node_modules | Add |
| Regex too complex | Try |
| Output too long | Use |
| Binary file skipped | Add |
| Need to see full line | Remove |
| Task | Better Tool |
|---|---|
| Structured JSON queries | |
| Column-based text processing | |
| Stream editing/substitution | |
| Find files by name only | |
| Simple file listing | |
| Full file content needed | Read tool |