ripgrep
61.4k stars
official open-source macOS Linux Cross-platform Actively maintained
The fastest code search tool. Search files recursively with regex, structured JSON output, and automatic .gitignore respect. The search engine behind Claude Code and VS Code.
Part of the ripgrep CLI tools for AI agents
What your agent can do
You need to find every file that imports a deprecated function. `grep -r "oldFunction" .` takes 12 seconds and returns binary file matches, node_modules results, and .git directory contents. `rg "oldFunction"` takes 0.3 seconds and automatically skips everything in `.gitignore`. That performance difference is why every AI coding agent uses ripgrep as its search backend.Claude Code's Grep tool is ripgrep. VS Code's workspace search is ripgrep. When an AI agent searches your codebase, it's running `rg` under the hood. This makes ripgrep the single most important tool in agent-native development — not because agents use the CLI directly, but because it's the infrastructure that makes code-aware agents fast enough to be useful.The `--json` flag is what separates ripgrep from grep for agent workflows. Each match is a JSON object with the file path, line number, byte offset, and submatch positions. Your agent knows exactly where each match is, not just what line it's on. `rg --json "function\s+\w+" src/` returns structured data that an agent can programmatically navigate, filter, and act on.Type-aware searching is built in. `rg --type ts "interface"` searches only TypeScript files. `rg --type py "def "` searches only Python files. No glob patterns needed. ripgrep knows 100+ file types and respects `.gitignore`, `.ignore`, and `.rgignore` files automatically. Your agent searches what matters and skips what doesn't.The speed comes from Rust and a parallel directory walker. ripgrep searches faster than `grep`, `ag` (The Silver Searcher), `ack`, and `git grep` on every benchmark. On large codebases (100K+ files), the difference is orders of magnitude. This is why it became the default search backend for code editors and AI agents — interactive-speed search on any codebase size.
Limitations
Search-only with no file modification capabilities (use `sed` or editor integrations for find-and-replace). The `--replace` flag previews replacements but doesn't write changes to disk. No built-in MCP server since ripgrep is already the infrastructure layer that MCP-capable agents use internally. Regex-only pattern matching (no fuzzy/approximate search).
Key Commands
rg --json Search with structured JSON output including match positions and line numbers
rg -l List only the file paths containing matches
rg -c Count matches per file
rg --type Search only files of a specific type
rg -g Search files matching a glob pattern
rg --replace Preview text replacements across files
rg --stats Show search statistics (files searched, matches found, time elapsed)
GitHub Stats
repo BurntSushi/ripgrep
stars 61.4k
language Rust
license Unlicense
last commit Feb 27, 2026
FAQ
- Is ripgrep free?
- Yes. ripgrep is free and open-source under the Unlicense (public domain equivalent). No restrictions on commercial use. Install with `brew install ripgrep` on macOS, `apt install ripgrep` on Ubuntu, or `cargo install ripgrep` from source.
- Why do AI agents use ripgrep?
- Speed and structured output. ripgrep searches codebases 10-100x faster than grep by using parallel directory walking, automatic .gitignore respect, and Rust's zero-cost abstractions. Claude Code, VS Code, and most AI coding agents use ripgrep as their search backend. The `--json` flag provides structured match data (file, line, column, submatch offsets) that agents parse programmatically.
- What is the difference between ripgrep and grep?
- ripgrep is faster (parallel, SIMD-optimized), smarter (.gitignore respect, type awareness), and more agent-friendly (--json output, Unicode support by default). grep is universal (pre-installed on every Unix system) and supports more regex flavors. For agent workflows, ripgrep wins on speed, output structure, and sensible defaults. For one-off system administration on a remote server, grep is always available.
- How does ripgrep compare to The Silver Searcher (ag)?
- ripgrep is faster than ag on every benchmark, especially on large repositories. Both respect .gitignore and skip binary files. ripgrep adds `--json` structured output, 100+ built-in file types, and better Unicode handling. ag was the generational improvement over ack. ripgrep is the generational improvement over ag.
- Does ripgrep modify files?
- No. ripgrep is read-only. The `--replace` flag shows what replacements would look like but doesn't write to disk. For actual find-and-replace, pipe ripgrep's `--files-with-matches` output to `sed` or use editor integrations. This read-only design is intentional — it makes ripgrep safe to run on any codebase without side effects.
Last verified: Mar 25, 2026