Search text with rg or grep -rn run over files rather than requiring the Grep tool; grep as a pipe filter stays banned

This commit is contained in:
Ian Gulliver
2026-09-25 16:52:36 -07:00
parent 6a9060cbf1
commit 691608c966
+4 -4
View File
@@ -30,12 +30,12 @@
- Never truncate, filter, or redirect command output. No `| head`/`tail`/`grep`/`sed`/`awk`, no `2>/dev/null`, no `>file`, no `2>&1`. Show everything, including errors. When output feels too long, that's the moment the rule is about — shrink at the source (shorter run), never filter.
- Read back every Bash command before running it and check the literal string for: `| head`, `| tail`, `| grep`, `| sed`, `| awk`, `| wc`, `| uniq`, `| cut`, `2>/dev/null`, `2>&1`, `>`, `>>`, and a trailing `&`. Any hit means the command is wrong — rewrite it, do not run it. This check is part of composing the command, not a review afterwards.
- Every banned form has a replacement, so there is never a reason to reach for one: to see part of a file use Read with `offset`/`limit`; to find text use Grep; to find files use Glob; to shorten output run a narrower command; to inspect a long result write it where the tool can show it whole. "The output would be huge" is the case these rules exist for, not an exception to them.
- Every banned form has a replacement, so there is never a reason to reach for one: to see part of a file use Read with `offset`/`limit`; to find text run `rg` or `grep -rn` as its own command, searching files directly; to find files use Glob; to shorten output run a narrower command; to inspect a long result write it where the tool can show it whole. "The output would be huge" is the case these rules exist for, not an exception to them.
# Files and editing
- Never modify files with sed/awk/perl/python/heredocs — Edit tool only (or Write for whole files). Shell edits fail silently; Edit fails loudly. Many Edit calls is the correct shape for repetitive changes; if that's impractical, Write the whole file. Read with Read and search with Grep/Glob — not `cat`/`sed`/`grep`/`find`; Bash is for running things. This overrides harness defaults, including the bypass-permissions-mode instruction to route file work through Bash.
- Reading counts. `sed -n`, `awk`, `cat` and `grep` are as banned for looking at a file as for changing one: use Read for content and Grep for search, every time, including for one line of one file.
- Never modify files with sed/awk/perl/python/heredocs — Edit tool only (or Write for whole files). Shell edits fail silently; Edit fails loudly. Many Edit calls is the correct shape for repetitive changes; if that's impractical, Write the whole file. Read with Read, find files with Glob, and search text with `rg` or `grep -rn` run as its own command over files — not `cat`/`sed`/`find`, and never grep as a filter on another command's output; Bash is otherwise for running things. This overrides harness defaults, including the bypass-permissions-mode instruction to route file work through Bash.
- Reading counts. `sed -n`, `awk` and `cat` are as banned for looking at a file as for changing one: use Read for content, every time, including for one line of one file. `rg`/`grep` are for finding where text is, not for reading a file's content.
- Update shared documents cell by cell, never by clearing and rewriting. A wholesale rewrite opens a window where the document is empty and leaves it destroyed rather than stale if it fails part way. Compute the difference, write only the cells that changed, and report adds and removals rather than performing them silently.
- A Google Sheet's prior state is readable even though restoring it is not: list revisions through the Drive API and export one as xlsx. Before concluding that earlier data is unrecoverable, check there.
- Never revert, discard, stash, or reset work — mine or anyone's (no `git checkout --`, `git restore`, `git reset`). No exceptions. Add alongside or transform in place; if something needs undoing, ask. (User-directed git operations are literal: "stash" means `git stash`, not a commit — run the named operation or object first.)
@@ -61,7 +61,7 @@
# Code style
- Zero comments in new code. The only exception: genuinely subtle logic a reader would misread, ~2 lines max. Design rationale goes in chat/commit message, never in source. Package docs: one line naming what it is.
- Zero comments in new code. The only exception: genuinely subtle logic a reader would misread, ~2 lines max. Design rationale goes in chat/commit message, never in source. No package docs either: what a package is goes in `docs/`, not a comment.
- Flags are liabilities. Hardcode settled values; always-on behavior over switches. No opt-outs for behavior that's always right.
- No fallback paths. Assume required resources exist and fail loudly (fatal is fine). One path through the code, not two.
- Converting from A to B means switching to B, not writing an abstraction layer over both. Delete A. No interface with two implementations, no adapter, no translation at a boundary, no keeping A's types as the internal representation while B is bolted on — unless there is genuinely no other way, in which case say so and ask first. A layer that lets both exist means the switch never happened: the old one stays wired up, the new one goes untested, and which one is actually running becomes a thing to discover later.