◉CLAUDE LABJP
●CODE 2.1.319 — Claude Code now moves MCP tasks to the background automatically, and a denyInsteadOfPrompting setting denies calls that would wait on a prompt●FABLE 5.2 — Claude Fable 5.2 and its fast mode are on the Claude API (11/9). Mythos 5.2 is limited to verified organizations●SONNET 4.5 — Retires on the Claude API on 11/30, 20 days left. Migrate to Sonnet 5.5●WINDOWS — Reports say hooks break silently only on Japanese-locale Windows; check the character encoding first●FAST — Opus 4.8 fast mode is deprecated and will be removed on 11/30. Migrate to Opus 5.5●NEW — I Put a Ten-Line Promise File at the To…●CODE 2.1.319 — Claude Code now moves MCP tasks to the background automatically, and a denyInsteadOfPrompting setting denies calls that would wait on a prompt●FABLE 5.2 — Claude Fable 5.2 and its fast mode are on the Claude API (11/9). Mythos 5.2 is limited to verified organizations●SONNET 4.5 — Retires on the Claude API on 11/30, 20 days left. Migrate to Sonnet 5.5●WINDOWS — Reports say hooks break silently only on Japanese-locale Windows; check the character encoding first●FAST — Opus 4.8 fast mode is deprecated and will be removed on 11/30. Migrate to Opus 5.5●NEW — I Put a Ten-Line Promise File at the To…
Articles/Claude Code
⟐ Claude Code/2026-10-14Advanced

Grep's First 250 Lines Touched Only 42 of the 183 Files That Matched

Searching an article repository for the word hook returned 1,312 lines across 183 files. ripgrep, git grep and grep all finished in 11 to 35 ms, so speed was never the issue. Output size and ordering were. A script that estimates what a 250-line cutoff will miss, plus a search order backed by measurements.

Claude Code283GrepripgrepContext3Benchmark

✦ Premium Article

I was building a table to compare search speed. ripgrep, git grep, and plain grep, each run seven times for the same word in the same folder, with the median recorded.

When the table was done, I stopped. The time column sat between 11 and 35 ms for everything, so there was nothing worth arguing about. What caught my eye was the next column, output bytes. For the same word, the output ranged from 15,207 bytes to 771,629 bytes, roughly a 50x spread.

This is a measurement on the article repository of a website I run as an indie developer: 893 MDX files per language, Japanese and English. When comparing search tools, the thing to look at is not speed but how much comes back and how that amount gets cut off. Here is the record.

Setup

Here is the setup, in case you want to reproduce it.

  • A Linux work environment (4 cores), ripgrep 13.0.0, GNU grep, git
  • Target: content/articles/ja (893 files). Pattern: hook, case-insensitive
  • Each command ran 7 times; I took the median time and recorded stdout bytes, line count, and the longest line
  • I did not measure tokens. "Amount" below means bytes and lines

The Python used for the measurement is below. It runs as pasted.

import os
import statistics
import subprocess
import time
 
os.chdir(os.path.expanduser("~/repos/claudelab.net"))  # replace with your own repository
 
def run(cmd, n=7):
    times, out = [], b""
    for _ in range(n):
        t = time.perf_counter()
        # rg exits 1 when nothing matches, so do not use check=True
        out = subprocess.run(cmd, shell=True, capture_output=True).stdout
        times.append((time.perf_counter() - t) * 1000)
    lines = [l for l in out.split(b"\n") if l]
    longest = max((len(l) for l in lines), default=0)
    return statistics.median(times), len(out), len(lines), longest
 
COMMANDS = [
    ("rg -n", "rg -n -i hook content/articles/ja"),
    ("rg -l", "rg -l -i hook content/articles/ja"),
    ("rg -n -m1", "rg -n -m1 -i hook content/articles/ja"),
    ("git grep -n", "git grep -n -i hook -- content/articles/ja"),
    ("grep -rn", "grep -rn -i hook content/articles/ja"),
]
 
print("label\tms\tbytes\tlines\tlongest")
for label, cmd in COMMANDS:
    ms, size, count, longest = run(cmd)
    print(f"{label}\t{ms:.0f}\t{size}\t{count}\t{longest}")

I leave out check=True because ripgrep reports "no match" as exit code 1. Raising on that would stop the measurement on a zero-hit day.

Result 1: speed was never a reason to choose

The actual numbers:

CommandMedianOutput bytesLinesLongest line
rg -n (whole repo)27 ms771,6293,4431,010
rg -n (ja only)17 ms305,3091,3121,010
git grep -n19 ms305,3091,3121,010
grep -rn30 ms305,3091,3121,010
rg -l14 ms15,207183113
rg -c16 ms15,611183116

The three tools produced the same number of output bytes (305,309 each). The widest speed gap is 13 ms, which you will never feel when you hand a search to Claude.

What surprised me was the first row. Just by not scoping to content/articles/ja, the output grew to 771,629 bytes, because the English articles and src came along. Time went up by 10 ms. The amount grew 2.5x.

✦

Thank you for reading this far.

Continue Reading

What follows includes implementation code, benchmarks, and practical content we hope you'll find useful. This site runs without ads — server and development costs are supported entirely by members like you. If it's been helpful, we'd be truly grateful for your support.

WHAT YOU'LL LEARN
✦You can now choose a search order that avoids missed matches and keeps context use down when a query matches hundreds of lines
✦You will be able to estimate the match count and the share of files a 250-line cutoff reaches, in seconds and before reading anything (script included)
✦You can stop spending time on search-tool speed comparisons and fix the thing that actually moves the numbers: how output is narrowed
Secure payment via Stripe · Cancel anytime
✦

Unlock This Article

Get full access to the rest of this article. Buy once, read anytime. This site is ad-free — your support goes directly toward keeping it running.

or
Unlock all articles with Membership →
Share

Thank You for Reading

Claude Lab is ad-free, supported entirely by members like you. We publish practical guides daily with implementation code, benchmarks, and production-ready patterns. If you've found it useful, we'd love to have you on board.

  • ✦Copy-paste ready implementation code
  • ✦New advanced guides published daily
  • ✦$5/mo or $10 for lifetime access
View Membership →

Related Articles

⟐ Claude Code2026-11-08
Before a Nightly Job Hangs on a Prompt: Designing Around denyInsteadOfPrompting
Claude Code 2.1.319 adds permissions.denyInsteadOfPrompting. Here is how it compares with other ways to answer permission prompts unattended, and how to catch what a denial quietly drops.
⟐ Claude Code2026-11-06
When claude doctor Listed Four Warnings, I Sorted Them by Cause Before Fixing Anything
claude doctor ended with "4 warnings found", but I didn't need four fixes. Using the real output, here is how to spot duplicated warnings and sign-in-only info lines, group the rest by cause, and decide the order of repair.
⟐ Claude Code2026-11-06
Claude Code Shipped 21 Releases in Four Weeks. I Counted Before Deciding How Often to Update
Should you check Claude Code updates every day or once a week? I counted npm's publish history with a standard-library Python script and used the last 28 days of counts and gaps to set a rhythm.