◉CLAUDE LABJP
●2.1.296 — Subagents can set their own autoCompactWindow, and an env var pins the model used by workflow agents●HAIKU 5.5 — Since 2.1.293 (Oct 7), claude-haiku-5-5 is the default Haiku model on the Anthropic API●SONNET 4.5 — Retires on the Claude API on 11/30, 47 days left. Migrate to Sonnet 5.5●Q&A — A write-up shows three places to look when a Mod draws nothing and reports no error●AGENTS.MD — One write-up explains how to split the entry points when Codex and Claude Code share a folder: AGENTS.md and CLAUDE.md●NEW — Approval prompts for "cd, git add, commit" every time: not a missing setting, but how it works●2.1.296 — Subagents can set their own autoCompactWindow, and an env var pins the model used by workflow agents●HAIKU 5.5 — Since 2.1.293 (Oct 7), claude-haiku-5-5 is the default Haiku model on the Anthropic API●SONNET 4.5 — Retires on the Claude API on 11/30, 47 days left. Migrate to Sonnet 5.5●Q&A — A write-up shows three places to look when a Mod draws nothing and reports no error●AGENTS.MD — One write-up explains how to split the entry points when Codex and Claude Code share a folder: AGENTS.md and CLAUDE.md●NEW — Approval prompts for "cd, git add, commit" every time: not a missing setting, but how it works
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 Code262GrepripgrepContextBenchmark

✦ 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-10-13
The Same Approval Prompt for 'cd, git add, git commit' Every Time — Following It to a Design Choice, Not a Missing Setting
With a compound command like cd /path && git add && git commit, Claude Code keeps asking for approval even with allow rules in place. Reading the official permissions page next to a GitHub report shows that cd combined with git prompts by design. Here is how to tell, in what order to check, and four ways to cut the prompts.
⟐ Claude Code2026-10-12
After Moving to SPM, My App Died the Moment It Launched — Reading One dyld Line with Claude Code
Right after moving from CocoaPods to Swift Package Manager, the build passed but the app died on launch. Here is how I traced one dyld line to its cause, the fix, and how to verify it.
⟐ Claude Code2026-10-05
I Wrote "I'll Do the Commits" in CLAUDE.md. The Next Morning git log Had One More Line.
When Claude Code commits despite being told not to: undo with git reset --soft, then stop it physically with permissions.deny plus a PreToolUse hook. Covers the git -c form that deny rules let through, and how to test the hook without starting Claude Code.