This skill should be used when the user asks about "ripgrep", "rg command", "fast grep", "search files", "code search", "regex search in files", "find in files", "search codebase", "grep replacement", or needs guidance on file content searching, pattern matching, or recursive text search. Provides command reference, usage patterns, and best practices for ripgrep (rg).
Provides command reference and usage patterns for ripgrep (rg) file searching.
/plugin marketplace add alexeldeib/clode/plugin install clode@clodeThis skill inherits all available tools. When active, it can use any tool Claude has access to.
references/advanced.mdripgrep is a line-oriented search tool that recursively searches directories for regex patterns. It respects .gitignore rules by default and automatically skips hidden files, directories, and binary files.
# Search for pattern in current directory (recursive)
rg 'pattern'
# Search specific file
rg 'pattern' file.txt
# Search specific directory
rg 'pattern' src/
# Multiple paths
rg 'pattern' src/ tests/ docs/
| Flag | Short | Description |
|---|---|---|
--ignore-case | -i | Case-insensitive search |
--smart-case | -S | Case-insensitive unless pattern has uppercase |
--word-regexp | -w | Match whole words only |
--fixed-strings | -F | Treat pattern as literal string (no regex) |
--count | -c | Show count of matches per file |
--files-with-matches | -l | Show only filenames with matches |
--files-without-match | -L | Show only filenames without matches |
--line-number | -n | Show line numbers (default when output is terminal) |
--no-line-number | -N | Suppress line numbers |
--only-matching | -o | Print only the matched text |
--invert-match | -v | Show non-matching lines |
--multiline | -U | Enable multiline matching (. matches newlines) |
# Show 3 lines after each match
rg -A 3 'pattern'
# Show 3 lines before each match
rg -B 3 'pattern'
# Show 3 lines before and after (context)
rg -C 3 'pattern'
# Search only in Rust files
rg 'pattern' --type rust
rg 'pattern' -trust
# Exclude JavaScript files
rg 'pattern' --type-not js
rg 'pattern' -Tjs
# List all available types
rg --type-list
# Define custom type
rg --type-add 'web:*.{html,css,js}' -tweb 'pattern'
Common built-in types: py, js, ts, rust, go, java, c, cpp, html, css, json, yaml, md, sh
# Include only .toml files
rg 'pattern' -g '*.toml'
# Include files in specific directory
rg 'pattern' -g 'src/**/*.rs'
# Exclude files (prefix with !)
rg 'pattern' -g '!*.min.js'
# Multiple globs
rg 'pattern' -g '*.rs' -g '*.toml'
ripgrep automatically ignores:
.gitignore, .ignore, .rgignore patterns# Disable .gitignore filtering
rg --no-ignore 'pattern'
# Search hidden files
rg --hidden 'pattern'
rg -. 'pattern'
# Search binary files as text
rg --text 'pattern'
rg -a 'pattern'
# Shorthand for disabling filters
rg -u 'pattern' # --no-ignore
rg -uu 'pattern' # --no-ignore --hidden
rg -uuu 'pattern' # --no-ignore --hidden --text
ripgrep uses Rust regex syntax by default.
# Word characters followed by digits
rg '\w+\d+'
# Start/end of line anchors
rg '^start'
rg 'end$'
# Character classes
rg '[A-Z][a-z]+'
# Alternation
rg 'foo|bar'
# Quantifiers
rg 'colou?r' # 0 or 1
rg 'a+' # 1 or more
rg 'a*' # 0 or more
rg 'a{2,4}' # 2 to 4 times
# Non-greedy matching
rg 'a+?'
# Lookahead/lookbehind (requires PCRE2)
rg -P '(?<=prefix)\w+' # Lookbehind
rg -P '\w+(?=suffix)' # Lookahead
Enable PCRE2 for advanced regex features:
# Enable PCRE2
rg -P 'pattern'
rg --pcre2 'pattern'
# Auto-detect when PCRE2 is needed
rg --engine auto 'pattern'
# Basic multiline (dot matches newline)
rg -U 'start.*end'
# Match across lines with PCRE2
rg -UP 'function\s+\w+\s*\([^)]*\)\s*\{'
ripgrep never modifies files. The --replace flag transforms output only.
# Simple replacement
rg 'old' -r 'new'
# With capture groups
rg '(\w+)@(\w+)' -r '$2:$1'
# Named capture groups
rg '(?P<user>\w+)@(?P<domain>\w+)' -r '$domain:$user'
# JSON output (for parsing)
rg --json 'pattern'
# Null-separated filenames (for xargs -0)
rg -l --null 'pattern'
# Show only matching files
rg -l 'pattern'
# Show files that would be searched
rg --files
# Show files matching glob
rg --files -g '*.rs'
# Limit search depth
rg --max-depth 3 'pattern'
# Limit results
rg --max-count 5 'pattern' # Per file
rg 'pattern' | head -n 100 # Total
# Disable memory maps (for consistency)
rg --no-mmap 'pattern'
# Sort results by path
rg --sort path 'pattern'
# Rust
rg '^(pub\s+)?(async\s+)?fn\s+\w+'
# Python
rg '^def \w+|^class \w+'
# JavaScript/TypeScript
rg '(function|const|let|var)\s+\w+\s*='
rg 'TODO|FIXME|XXX|HACK' -g '!*.min.*'
# Python
rg '^(import|from)\s+\w+'
# JavaScript
rg "^(import|require\()"
# Go
rg '^import\s+'
# IP addresses (approximate)
rg '\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}'
# Email addresses (simple)
rg '\w+@\w+\.\w+'
# URLs
rg 'https?://[^\s]+'
Set default options via RIPGREP_CONFIG_PATH:
export RIPGREP_CONFIG_PATH="$HOME/.ripgreprc"
Example ~/.ripgreprc:
--smart-case
--hidden
--glob=!.git/*
--max-columns=150
--max-columns-preview
# Show what files would be searched and why others are ignored
rg --debug 'pattern'
# Disable config file
rg --no-config 'pattern'
| Feature | ripgrep | GNU grep |
|---|---|---|
| Recursive by default | Yes | No (-r required) |
| Respects .gitignore | Yes | No |
| Skips binary files | Yes | No |
| Unicode by default | Yes | Depends on locale |
| Parallel search | Yes | No |
| Memory-mapped files | Yes | No |
For advanced features, see:
This skill should be used when the user asks to "create a slash command", "add a command", "write a custom command", "define command arguments", "use command frontmatter", "organize commands", "create command with file references", "interactive command", "use AskUserQuestion in command", or needs guidance on slash command structure, YAML frontmatter fields, dynamic arguments, bash execution in commands, user interaction patterns, or command development best practices for Claude Code.
This skill should be used when the user asks to "create an agent", "add an agent", "write a subagent", "agent frontmatter", "when to use description", "agent examples", "agent tools", "agent colors", "autonomous agent", or needs guidance on agent structure, system prompts, triggering conditions, or agent development best practices for Claude Code plugins.
This skill should be used when the user asks to "create a hook", "add a PreToolUse/PostToolUse/Stop hook", "validate tool use", "implement prompt-based hooks", "use ${CLAUDE_PLUGIN_ROOT}", "set up event-driven automation", "block dangerous commands", or mentions hook events (PreToolUse, PostToolUse, Stop, SubagentStop, SessionStart, SessionEnd, UserPromptSubmit, PreCompact, Notification). Provides comprehensive guidance for creating and implementing Claude Code plugin hooks with focus on advanced prompt-based hooks API.