| name | ripgrep-cli |
| description | Use ripgrep (rg) for extremely fast recursive regex search across codebases. Respects .gitignore, supports file type filtering, and produces structured output. |
ripgrep (rg)
Blazing fast line-oriented search tool. Recursively searches directories with regex, respecting .gitignore.
Common Commands
Basic Search
rg "pattern"
rg "pattern" src/
rg "pattern" file.txt
rg -i "pattern"
rg -w "word"
rg -F "literal string"
Regex
rg "fn\s+\w+"
rg "import .* from"
rg "TODO|FIXME|HACK"
rg "error" --multiline
File Type Filtering
rg "pattern" -t py
rg "pattern" -t js -t ts
rg "pattern" -T test
rg "pattern" -g "*.json"
rg "pattern" -g "!node_modules"
rg --type-list
Context
rg "pattern" -C 3
rg "pattern" -B 2
rg "pattern" -A 5
Output Control
rg "pattern" -l
rg "pattern" -c
rg "pattern" --json
rg "pattern" -n
rg "pattern" -o
rg "pattern" --stats
Replacement
rg "old" -r "new"
rg "(\w+)@(\w+)" -r '$2/$1'
Advanced
rg "pattern" --hidden
rg "pattern" --no-ignore
rg "pattern" -z
rg "pattern" --sort modified
rg "pattern" -m 5
Agent Best Practices
- Use
--json for machine-parseable output
- Use
-l (files only) when you need file paths, not content
- Use
-t for file types instead of glob patterns when possible
- Use
-F for literal strings to avoid regex escaping issues
- Use
--stats to understand search scope and match counts
- Combine
-c (count) with --sort-files for finding files with most matches
- rg respects .gitignore by default - use
--no-ignore to override
Example Workflows
Find all TODO comments in source code
rg "TODO|FIXME" -t py -t js -t ts --stats
Find files containing a function definition
rg "def process_payment" -l