Skip to content

ripgrep (rg) for AI Agents — Code Search at Agent Speed

The search infrastructure behind every AI coding agent — find anything in any codebase instantly

Browse all CLI tools for AI agents

What your agent can do

When Claude Code searches your codebase, it runs ripgrep. When VS Code finds matches across 10,000 files in under a second, it runs ripgrep. When any AI coding agent needs to understand your code, it starts with ripgrep. This is the invisible infrastructure that makes code-aware AI agents fast enough to be useful.ripgrep searches recursively through directories with automatic `.gitignore` respect, type-aware filtering, and structured JSON output. It is 10-100x faster than `grep` on real codebases. The speed comes from Rust, a parallel directory walker, and SIMD-optimized regex matching. On a 100,000-file monorepo, ripgrep returns results in under a second. Traditional grep takes minutes.The `--json` flag is what makes ripgrep agent-native. Each match is a JSON object with the file path, line number, byte offset, column position, and submatch boundaries. Your AI agent doesn't just know that a match exists — it knows exactly where in the file, on which line, at which character position. `rg --json "function\s+\w+" src/` returns structured navigation data, not text to parse.Type-aware searching eliminates noise. `rg --type ts "interface"` searches TypeScript files only. `rg --type py "class "` searches Python only. ripgrep knows 100+ file types. Combined with `.gitignore` respect, your agent searches only the code that matters — no `node_modules`, no build artifacts, no binary files, no `.git` directory.

Frequently asked questions

Why do AI coding agents use ripgrep?
Speed and structure. AI agents search codebases constantly — finding definitions, tracing imports, locating test files. ripgrep is 10-100x faster than grep with automatic .gitignore respect and structured JSON output. Claude Code uses it as its Grep tool. VS Code uses it for workspace search. The `--json` flag provides file, line, column, and submatch data that agents parse programmatically. Install with `brew install ripgrep`.
Is ripgrep better than grep?
For code search, yes. ripgrep is faster (parallel + SIMD), smarter (.gitignore respect, Unicode by default, 100+ file types), and more structured (--json output). grep is universal (pre-installed everywhere) and supports more regex dialects. For AI agent workflows, ripgrep is the clear choice. For system administration on a remote server where you can't install tools, grep is always available.
How fast is ripgrep compared to other search tools?
On the Linux kernel source tree (~70K files): ripgrep completes in 0.3 seconds. GNU grep takes 3-5 seconds. ag (The Silver Searcher) takes 1-2 seconds. On larger codebases, the gap widens further. ripgrep's parallel directory walker means it scales linearly with available CPU cores. This speed difference is why every modern code editor and AI agent uses ripgrep.