rg and fd: Modern grep and find for AI Coding

Posted by Michael S. on February 14, 2026

I spent a week watching Claude Code run grep commands that took four seconds to complete.

Four seconds doesn't sound like much. But when you're running twenty searches per session, that's eighty seconds of just... waiting. For grep to crawl through node_modules. Again.

Here's why your CLAUDE.md probably mentions rg and fd—and why you should actually install them.


The Problem with grep and find

They're not bad. They're just old.

grep was written in 1974. find dates back to Unix Version 5. Both were designed for filesystems with hundreds of files, not modern repos with 50,000.

They search everything. Hidden directories. Build artifacts. Git history. That entire .git folder with 10,000 objects? grep will happily scan every one.

Classic.


What rg and fd Actually Do

ripgrep (rg) is grep, but:

  • Multi-threaded by default (uses all your CPU cores)
  • Respects .gitignore automatically
  • Skips hidden files and binary blobs
  • Smart-case search (case-insensitive until you use an uppercase letter)

fd is find, but:

  • Parallel directory traversal (much faster on deep trees)
  • Also respects .gitignore
  • Clean syntax (fd pattern instead of find . -name "*pattern*")
  • Colorized output that doesn't hurt your eyes

Both tools are written in Rust. Both are stupid fast.


Side-by-Side Comparison

ripgrep vs. grep

Feature grep (Standard) rg (ripgrep)
Speed Fast for single files; slow for deep directories Blazing fast; multi-threaded by default
Default Logic Searches everything (including .git, node_modules) Respects .gitignore; skips hidden files by default
Ease of Use Often requires flags like -r or -E for basic tasks Clean, modern syntax; automatic recursive search
Smart Case Requires -i Switches to case-sensitive only if you use an uppercase letter

fd vs. find

Feature find (Standard) fd (fd-find)
Syntax find . -name "*pattern*" (Verbose) fd pattern (Short and intuitive)
Performance Walks the directory tree sequentially Parallelized tree traversal (much faster)
Filtering Includes every temp/build file unless excluded Automatically ignores .git and .gitignore paths
Output Plain text Colorized output by default (easier to read)

Why CLAUDE.md Prefers Them

Your CLAUDE.md file is basically Claude's instruction manual when it operates in your terminal. It prioritizes rg and fd for three reasons:

1. Context Window Efficiency

Claude has a finite memory. When it runs grep -r "function" . in a repo with node_modules, it gets back 8,000 lines of garbage.

With rg "function", it gets maybe 200—all relevant.

Less noise means more room for actual code context.

2. Speed & Latency

In a 100,000-file repo, find can take ten seconds. fd finishes in under one.

When Claude is running twenty searches to understand your codebase, that difference compounds. Fast tools make the AI feel snappier.

3. Accuracy

These tools are built for code.

They ignore minified libraries, build artifacts, temporary log files. Claude doesn't waste time suggesting edits to bundle.min.js or a five-month-old debug log.


Installation

If you don't have them yet:

macOS:

brew install ripgrep fd

Ubuntu/Debian:

sudo apt install ripgrep fd-find

Note: on Ubuntu, the command is fdfind instead of fd due to a naming conflict. Your CLAUDE.md should handle that automatically.

Other platforms: check the ripgrep and fd repos.


Real-World Example

Here's the difference in practice.

Before (grep):

grep -r "import React" .
# 4.2 seconds
# 12,000 matches (mostly in node_modules)

After (rg):

rg "import React"
# 0.3 seconds
# 47 matches (all in src/)

That's 14x faster and 99.6% less noise.

When you're iterating with Claude, that gap matters.


The Gotcha

Both tools respect .gitignore by default. That's great 99% of the time.

But if you need to search everything (including ignored files), you need flags:

  • rg --no-ignore "pattern"
  • fd --no-ignore pattern

I forgot this once while debugging a vendor script that was gitignored. Wasted twenty minutes convinced the file didn't exist.

Your mileage may vary.


Should You Actually Install These?

If you use Claude Code (or Cursor, or any AI coding tool), yes.

The speed boost is nice for you. But the context window savings are huge for the AI. Less garbage in the results means Claude has more room to think about your actual code.

Plus, once you get used to fd instead of find, you won't want to go back. The syntax is just... better.


Enjoyed this post?

Get notified when I publish something new. No spam, unsubscribe anytime.