◉CLAUDE LABJP
●CC 2.1.332 — 2.1.332 (11/25) is still current. Skills from MCP servers appear as server:skill (beta)●OPUS 4.5 — Opus 4.5 is now scheduled to retire from the Claude API on 2027/1/22. Move to claude-opus-5-5●SONNET 4.5 — Sonnet 4.5 retires from the Claude API tomorrow, 11/30. Last day to check for hard-coded IDs●DISK — Users on Windows report Cowork's session disk filling up with no way to clean it●NEW — New: Asking Cowork for a meeting draft? Hand over old minutes after the outline is set●JETBRAINS — Our guide to using Claude with JetBrains IDEs is still among the most-read pages●CC 2.1.332 — 2.1.332 (11/25) is still current. Skills from MCP servers appear as server:skill (beta)●OPUS 4.5 — Opus 4.5 is now scheduled to retire from the Claude API on 2027/1/22. Move to claude-opus-5-5●SONNET 4.5 — Sonnet 4.5 retires from the Claude API tomorrow, 11/30. Last day to check for hard-coded IDs●DISK — Users on Windows report Cowork's session disk filling up with no way to clean it●NEW — New: Asking Cowork for a meeting draft? Hand over old minutes after the outline is set●JETBRAINS — Our guide to using Claude with JetBrains IDEs is still among the most-read pages
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 Code295GrepripgrepContext3Benchmark

✦ 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

As of November 2026, ripgrep is on its 15.x line. I checked the current manual, and the flags used here (-l, -m, --sort, --max-columns) mean the same thing they did in 13.0.0.

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-26
Per Callback, or Once at the Door? Deciding What Claude Code Should Touch on the Day I Installed an Ads SDK Migration Skill
Android's ads SDK is changing generations, and every callback will now arrive on a background thread. The official migration skill says to switch to the UI thread inside each callback; I chose to switch once, at the entrance of my ad wrapper layer. Three tools — an inventory scanner, an entrance-level normalizer, and a PreToolUse hook that fences Claude Code's edits on the migration branch — and the reasoning behind the choice.
⟐ Claude Code2026-11-26
My Hook Ran in VS Code but Never in Android Studio — Keep One Settings File and Start Claude Code at the Repo Root
Same repository, same Mac, yet hooks and allow rules only worked when Claude Code was opened from VS Code. The cause was the launch directory, not the editor. Here is a script that lists which settings files load from a given folder, plus how I decide what goes in which file.
⟐ Claude Code2026-11-24
When Claude Code Can't Connect, Read the Two Lines in claude doctor's API Connectivity Section Side by Side
Claude Code 2.1.331 added an API connectivity section to claude doctor. Using real output from a machine behind a proxy, this walks through reading the API and Sign-in lines together, what "via https_proxy" tells you, ERR_PROXY_TUNNEL versus ECONNREFUSED, and a small script that adds a first guess.