ripgrep
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).
What this skill does
# ripgrep (rg) CLI Reference
ripgrep 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.
## Basic Usage
```bash
# 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/
```
## Essential Flags
| 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) |
## Context Lines
```bash
# 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'
```
## File Filtering
### By File Type
```bash
# 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`
### By Glob Pattern
```bash
# 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'
```
## Automatic Filtering Control
ripgrep automatically ignores:
1. Files matching `.gitignore`, `.ignore`, `.rgignore` patterns
2. Hidden files and directories
3. Binary files
```bash
# 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
```
## Regex Patterns
ripgrep uses Rust regex syntax by default.
```bash
# 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
```
### PCRE2 Mode
Enable PCRE2 for advanced regex features:
```bash
# Enable PCRE2
rg -P 'pattern'
rg --pcre2 'pattern'
# Auto-detect when PCRE2 is needed
rg --engine auto 'pattern'
```
## Multiline Search
```bash
# Basic multiline (dot matches newline)
rg -U 'start.*end'
# Match across lines with PCRE2
rg -UP 'function\s+\w+\s*\([^)]*\)\s*\{'
```
## Replacements (Output Only)
ripgrep never modifies files. The `--replace` flag transforms output only.
```bash
# 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'
```
## Output Formats
```bash
# 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'
```
## Performance Options
```bash
# 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'
```
## Common Patterns
### Find function definitions
```bash
# 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*='
```
### Find TODO/FIXME comments
```bash
rg 'TODO|FIXME|XXX|HACK' -g '!*.min.*'
```
### Find imports/requires
```bash
# Python
rg '^(import|from)\s+\w+'
# JavaScript
rg "^(import|require\()"
# Go
rg '^import\s+'
```
### Search specific patterns
```bash
# 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]+'
```
## Configuration File
Set default options via `RIPGREP_CONFIG_PATH`:
```bash
export RIPGREP_CONFIG_PATH="$HOME/.ripgreprc"
```
Example `~/.ripgreprc`:
```
--smart-case
--hidden
--glob=!.git/*
--max-columns=150
--max-columns-preview
```
## Debugging
```bash
# Show what files would be searched and why others are ignored
rg --debug 'pattern'
# Disable config file
rg --no-config 'pattern'
```
## Key Differences from grep
| 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 |
## Reference
For advanced features, see:
- [references/advanced.md](references/advanced.md) - Preprocessors, encoding, binary handling
Related in Writing & Docs
jax-development
IncludedUse this skill when the user is writing, debugging, profiling, refactoring, reviewing, benchmarking, parallelising, exporting, or explaining JAX code, or when they mention JAX, jax.numpy, jit, grad, value_and_grad, vmap, scan, lax, random keys, pytrees, jax.Array, sharding, Mesh, PartitionSpec, NamedSharding, pmap, shard_map, Pallas, XLA, StableHLO, checkify, profiler, or the JAX repo. It helps turn NumPy or PyTorch-style code into pure functional JAX, fix tracer/control-flow/shape/PRNG bugs, remove recompiles and host-device syncs, choose transforms and sharding strategies, inspect jaxpr/lowering/IR, and benchmark compiled code correctly.
nature-article-writer
IncludedDrafts, rewrites, diagnostically critiques, and style-calibrates primary research manuscripts for Nature and Nature Portfolio journals. Use when the user wants a Nature-style title, summary paragraph or abstract, introduction, results, discussion, methods, figure legends, presubmission enquiry, cover letter, reviewer response, or when a scientific draft sounds generic, jargon-heavy, structurally weak, or AI-ish and needs precise, broad-reader-friendly prose without inventing data, analyses, or references. Best for primary research articles and letters rather than reviews or press releases unless explicitly adapting one.
deckrd
IncludedDocument-driven framework that derives requirements, specifications, implementation plans, and executable tasks from goals through structured AI dialogue. Use when user says "write requirements", "create spec", "plan implementation", "derive tasks", "structure this feature", "break down into tasks", or "document this module". Also use for reverse engineering existing code into docs (/deckrd rev). Do NOT use for direct code writing — use /deckrd-coder after tasks are generated. Do NOT use when the user only wants to run or fix existing code without planning.
clinical-decision-support
IncludedGenerate professional clinical decision support (CDS) documents for pharmaceutical and clinical research settings, including patient cohort analyses (biomarker-stratified with outcomes) and treatment recommendation reports (evidence-based guidelines with decision algorithms). Supports GRADE evidence grading, statistical analysis (hazard ratios, survival curves, waterfall plots), biomarker integration, and regulatory compliance. Outputs publication-ready LaTeX/PDF format optimized for drug development, clinical research, and evidence synthesis.
handling-sf-data
IncludedSalesforce data operations with 130-point scoring. Use this skill to create, update, delete, bulk import/export, generate test data, and clean up org records using sf CLI and anonymous Apex. TRIGGER when: user creates test data, performs bulk import/export, uses sf data CLI commands, needs data factory patterns for Apex tests, or needs to seed/clean records in a Salesforce org. DO NOT TRIGGER when: SOQL query writing only (use querying-soql), Apex test execution (use running-apex-tests), or metadata deployment (use deploying-metadata).
accelint-ac-to-playwright
IncludedConvert and validate acceptance criteria for Playwright test automation. Use when user asks to (1) review/evaluate/check if AC are ready for automation, (2) assess if AC can be converted as-is, (3) validate AC quality for Playwright, (4) turn AC into tests, (5) generate tests from acceptance criteria, (6) convert .md bullets or .feature Gherkin files to Playwright specs, (7) create test automation from requirements. Handles both bullet-style markdown and Gherkin syntax with JSON test plan generation and validation.