docs(claude): warn that rg's -r is --replace, not a bundled short flag#322
Merged
Conversation
`rg -rn "yolo"` does not mean "recursive + line numbers". `-r` takes an
argument, so the cluster silently consumes `n` as a replacement string and rg
rewrites every match in its output. The result is fabricated lines that look
exactly like real file contents:
rg -rn "yolo" .
./conf/cli_clients/gemini.json: "--n" ← the file actually says "--yolo"
No error, no warning, well-formed output — it just doesn't match the file on
disk. Observed 2026-07 while auditing a clink config: the doctored line built a
false picture of the file that was nearly acted on, and was caught only because
it contradicted an earlier direct Read of the same file.
The trap is the muscle memory of `grep -r`. rg is recursive by default, so there
is no `-r` to add — and the Grep tool has no --replace surface at all, which is
the durable way to avoid the class.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019wryFZuz4HEs1oqY9EJfGo
Contributor
|
| Status | Count |
|---|---|
| 🔍 Total | 170 |
| ✅ Successful | 159 |
| ⏳ Timeouts | 1 |
| 🔀 Redirected | 0 |
| 👻 Excluded | 9 |
| ❓ Unknown | 0 |
| 🚫 Errors | 1 |
Errors per input
Errors in exact_dot_claude/docs/prds/daily-catchup.PRD.md
- [404] https://docs.anthropic.com/claude-code/commands | Failed: Network error: Not Found
Errors in docs/adrs/0013-nixos-declarative-system-configuration.md
- [TIMEOUT] https://nixos.org/manual/nixos/stable/ | Timeout
Full Github Actions output
Please fix the broken links before merging.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds a section to
~/.claude/rules/tool-use-patterns.mdon a silent, confident failure mode:rg -ris--replaceand takes an argument, so bundling it into a short-flag cluster makes ripgrep rewrite every match in its own output.Why
No error, no warning, and the output is well-formed — it simply does not match the file on disk. That makes it worse than a crash: the fabricated lines read as ground truth.
Observed 2026-07 while auditing a
clinkCLI config inpal-mcp-server. The doctored output built a false picture of the file that was nearly acted on, and was caught only because the rewritten line contradicted an earlier directReadof the same file.The root cause is imported muscle memory from
grep -r. ripgrep is recursive by default, so there is no-rto add — the habit produces a flag that means something else entirely.The durable fix
The rule ends by pointing at the structural answer rather than just "be careful": prefer the Grep tool over
rgin Bash. It has no--replacesurface, so this class of error cannot occur at all.Also adds the diagnostic heuristic: if an
rgresult contradicts something you read directly, suspect the flags before you suspect the file.🤖 Generated with Claude Code
https://claude.ai/code/session_019wryFZuz4HEs1oqY9EJfGo