Posted on

Here's a question worth pondering: when every AI coding tool is rushing to implement vector databases and embeddings, why did Anthropic choose a command-line grep replacement instead?

Claude Code, Anthropic's agentic coding assistant, relies on ripgrep for code search. Not embeddings. Not RAG pipelines. Just fast, reliable text search written in Rust.

This isn't a minor implementation detail. It reveals something important about how effective AI coding assistants actually work.

What Makes ripgrep Different

ripgrep (command: rg) is a line-oriented search tool created by Andrew Gallant. He first released it in September 2016 after spending 2.5 years working on text search in Rust. The tool combines the usability of The Silver Searcher with the raw performance of GNU grep.

The performance comes from deliberate engineering decisions:

  • Rust's regex engine uses finite automata, SIMD instructions, and aggressive literal optimizations
  • Smart defaults: respects .gitignore files, skips binary files, and ignores hidden directories automatically
  • Intelligent search strategy: automatically chooses between memory mapping (better for single files) and buffered reads (better for large directories)
  • UTF-8 decoding built into the DFA: maintains full Unicode support without the typical performance penalty

The regex engine alone represents a significant effort. It guarantees linear time matching on all inputs through its finite automata implementation. No pathological inputs that cause exponential blowup.

Takeaways:

  • 2.5 years of focused work on a single problem produced something exceptional
  • Smart defaults matter as much as raw speed
  • Linear time guarantees eliminate entire categories of edge cases

How Claude Code Uses ripgrep

Claude Code's "Grep" tool is powered by ripgrep out of the box. No configuration needed. The naming is somewhat misleading since it's not GNU grep at all. The system prompt explicitly instructs Claude:

"If you still need to run grep, STOP. ALWAYS USE ripgrep at rg first, which all Claude Code users have pre-installed."

Claude Code bundles ripgrep via the @vscode/ripgrep npm package. This is the same package VS Code uses for its search functionality. It works automatically on all supported platforms.

Takeaways:

  • ripgrep is enabled by default, no setup required
  • Claude Code ships ripgrep as a bundled dependency
  • The same battle-tested package that powers VS Code search

Why Not Vector Search?

This is the interesting part. Most AI coding tools use RAG (Retrieval-Augmented Generation) with embeddings. You chunk the codebase, create vector embeddings, store them in a database, and do similarity search.

Claude Code took a different approach: just search the text directly.

The advantages are significant:

  • No indexing required: ripgrep works immediately on any codebase
  • Exact matches: regex search finds precisely what you're looking for
  • Git-aware: automatically respects .gitignore
  • Predictable: you know exactly what it's searching

One Hacker News commenter noted this is still technically a form of RAG. It just uses Information Retrieval techniques that have existed for decades rather than vector search. Sometimes the old approaches work better.

Takeaways:

  • Zero indexing time means instant productivity on new codebases
  • Exact text matching avoids the semantic drift of embeddings
  • Proven techniques often beat newer alternatives

The VS Code Connection

ripgrep's adoption in Claude Code follows an established pattern. In March 2017, Visual Studio Code (version 1.11) switched to ripgrep for its text search functionality. This was a significant endorsement. VS Code's search now handles millions of searches daily across codebases of all sizes.

Microsoft maintains the vscode-ripgrep npm package specifically for this integration. Claude Code uses this same package, essentially inheriting years of production testing.

Takeaways:

  • VS Code validated ripgrep at massive scale
  • Claude Code benefits from that battle-testing
  • Reusing proven infrastructure reduces risk

Configuration Tips

ripgrep works out of the box with Claude Code. No configuration is required for most users.

For Alpine Linux and musl-based distributions, the bundled ripgrep binary doesn't work. You'll need to install ripgrep separately and tell Claude Code to use it:

apk add libgcc libstdc++ ripgrep
export USE_BUILTIN_RIPGREP=0

Optional performance optimization: By default, Claude Code uses a bundled ripgrep that runs through a Node.js wrapper. Community members report that using your system's ripgrep directly can be faster in large codebases. To try this:

# Install ripgrep
brew install ripgrep  # macOS
apt install ripgrep   # Ubuntu/Debian

# Tell Claude Code to use system ripgrep instead of bundled
export USE_BUILTIN_RIPGREP=0

# Add to ~/.zshrc or ~/.bashrc for persistence

Note: This optimization is not officially documented by Anthropic and results may vary.

Build Your Own grep

If you want to understand how tools like ripgrep work under the hood, CodeCrafters offers a "Build your own grep" challenge where you implement a regex engine from scratch.

The challenge covers:

  • Character classes and quantifiers
  • Anchors and wildcards
  • Backreferences
  • File search and recursive directory traversal
  • Match highlighting

It's available in 16 languages including Rust. The stages progress from matching literal characters (5 minutes) to implementing nested backreferences (1+ hours). A solid way to understand both regex internals and Rust's approach to systems programming.

The Rust Ecosystem Effect

ripgrep is one of the clearest examples of Rust delivering on its promise: C-level performance with memory safety and a pleasant developer experience. The tool has nearly 59,000 GitHub stars and powers search in some of the most widely-used developer tools.

For the Rust ecosystem, this creates a virtuous cycle:

  1. High-profile tools like ripgrep demonstrate Rust's capabilities
  2. These tools become dependencies for other projects (VS Code, Claude Code)
  3. More developers encounter Rust through these tools
  4. The ecosystem grows

Andrew Gallant continues to maintain ripgrep along with several other foundational Rust crates: the regex crate, aho-corasick, bstr, and the recently released jiff datetime library.

Takeaways:

  • ripgrep demonstrates Rust's value proposition clearly
  • Foundational tools drive ecosystem adoption
  • One maintainer's consistent work can have outsized impact

The choice of ripgrep over vector search in Claude Code reminds us that sometimes the best solution isn't the newest one. It's the one that's been battle-tested and does exactly what you need.

Links