Repository navigation
Description
⚠️ STATUS: unblocked — AC-5 is ANSWERED. Read the AC-5 comment before implementingThe blocker is resolved. Nothing here is parked. Superseding the previous banner:
bypassPermissionsdoes NOT skip Claude Code's nativermanalyzer — it still fires. [VERIFIED] against the v2.1.210 bundle (the exemption is deliberately coded: the dangerous-rm ask returns before the bypass allow) and confirmed by the official docs. The"cannot be auto-allowed by permission rules"string that framed this question was a red herring — it describes rules; the bypass exemption is separate.- Therefore the
rmguard is deleted, not narrowed. Native coverage (root, top-level dirs, home, workspace-ancestors,$UNSET/*) is exactly what:108blocks — pure redundancy, carrying the file's worst FP tax (rm -rf /substring-matches every absolute path, blocking worktree teardown). Deleting loses nothing that exists today.- This unblocks the rest rather than blocking it. The old AC-2/AC-3
rmrows pulled in opposite directions (one wantedgh issue list && rm -rf /blocked, the other wanted--body "...rm -rf /..."allowed). With thermhalf gone, the first row drops and the second is satisfied trivially. Normanchoring needed.- The "Proposed fix (directional)" section below — argv-level parsing in bash — still should NOT be built. The native analyzer does this properly, with a real AST and workspace context a hook cannot see.
- Still valid and shipping: carve-out removal (all 10 sites — five were never probed, four of which gate
git commit), command-logging, and an anchoredsudoguard (sudois not natively covered).Everything below this banner remains an accurate description of the bug; only the prescription changed. See the Revised Acceptance Criteria (v2) at the bottom — they replace all earlier lists.
Summary
Every guard in pre-tool.sh wrapped with the ! grep -qE '^gh (issue|pr) ' && idiom (added by #564, extended by #570) can be disarmed by prefixing the command with any real gh issue / gh pr invocation. The skip tests the command's prefix, not its content, so a compound command that merely starts with gh issue bypasses the check entirely — including the force-push guard.
Verified against the real hook (cat payload.json | bash hooks/pre-tool.sh; exit 0 = allowed, exit 2 = blocked). All five wrapped guards bypass:
| Guard | Payload | Result |
|---|---|---|
| Destructive | gh issue list && rm -rf / |
allowed |
| Force push | gh issue list && git push --force |
allowed |
| Deployment | gh issue list && vercel deploy --prod |
allowed |
| git reset | gh issue list && git reset --hard origin/main |
allowed |
| gh workflow | gh issue list && gh workflow run release.yml |
allowed |
Controls (identical payloads, no gh prefix) all block correctly, confirming the skip is the cause.
The force-push row is the one that matters most in practice: force-push protection is a documented, load-bearing guarantee of this repo (CLAUDE.md → .claude/skills/_shared/references/force-push.md), and gh issue list && git push --force walks straight through it.
Root cause
templates/hooks/pre-tool.sh:108 (and the four sibling sites):
if ! echo "$TOOL_INPUT" | grep -qE '^gh (issue|pr) ' && echo "$TOOL_INPUT" | grep -qE 'sudo|rm -rf /|rm -rf ~|rm -rf \$HOME'; then$TOOL_INPUT is the whole bash command string. The guard layer string-matches that string instead of parsing it, so it cannot distinguish three different things that all "contain" the same bytes:
- a real destructive invocation (
rm -rf /) — should block - that text as an argument to another program (
gh issue create --body "never run rm -rf /") — should allow - a real destructive invocation chained after an allowed command (
gh issue list && rm -rf /) — should block
#564/#570 fixed (2) by adding a prefix skip, which necessarily also allows (3). Both patches treated the symptom; the root cause — string-matching a shell command rather than parsing it — is unchanged, and each fix has enlarged the hole.
Why the existing regression tests miss it
__tests__/pre-tool-hook.integration.test.ts:276-300 has regression tests for exactly this concern, but they use a prefix that cannot trigger the skip:
// "START-anchor regression: a non-anchored mention of 'gh issue' must not
// bypass any of the four wrapped checks."
it("#570 regression destructive: `echo gh issue && sudo rm -rf /tmp/x` is still blocked", ...)echo gh issue && ... does not match ^gh (issue|pr) , so the skip never fires and the test passes for the wrong reason. Every regression test in that block covers the safe direction (non-anchored mention). The anchored case — a real gh issue/gh pr command chained with a destructive payload — is untested across all five guards.
The ^ anchor also breaks the fix it was meant to be
The skip only fires when gh issue/gh pr is the literal first token of the tool input. Any prefix defeats it — and cd <dir> && gh issue ... / cd <dir>\ngh issue ... is an everyday shape.
Encountered live while filing this very issue: cd /Users/tony/Projects/sequant followed by gh issue create --title '...git push --force...' was blocked as a force push. The command creates an issue; it pushes nothing. Filing it required dropping the cd.
So the same anchor produces both failure directions:
- too permissive when a real
ghcommand comes first → bypass (all five guards, table above) - too strict when the
ghcommand isn't literally first → the bug(hooks): pre-tool.sh regexes match inside quoted gh issue/pr body content (line 108 force-push, line 248 git-commit) #564/bug(hooks): pre-tool.sh regexes for destructive/deployment/reset/workflow commands also match inside quoted gh body content #570 false positive returns
Any fix that keeps prefix-matching will keep trading one of these for the other. This is the strongest argument for argv-level parsing over another regex patch.
Secondary finding: the destructive regex also fails in both directions
Separable from the bypass, but in the same expression and fixed by the same rewrite:
False positives — rm -rf / substring-matches every absolute path, so ordinary deletes are blocked:
| Command | Result |
|---|---|
rm -rf /Users/tony/Projects/worktrees/feature/38-cell-protocol |
blocked |
rm -rf /tmp/scratch/build |
blocked |
rm -rf ~/Library/Caches/my-app |
blocked |
This fires constantly in real work. It blocks any absolute-path cleanup, and it even blocks shell scripts that merely contain the string (a test script feeding these literals to grep was blocked, despite executing no rm at all). The practical harm is that it trains agents to route around the guard rather than respect it.
False negatives — the guard misses trivial variants of the catastrophe it exists to prevent:
| Command | Result |
|---|---|
rm -rf / |
blocked |
rm -fr / |
allowed |
rm -rf / (double space) |
allowed |
rm --recursive --force / |
allowed |
rm -rf "/" |
allowed |
A flag-order typo — precisely the accident class this guard exists for — sails through.
Severity framing
This is an accident-prevention guard, not a security boundary: Claude Code's permission system is the real boundary, and an agent is not an adversary crafting bypasses. So the bypass is not "an attacker can delete your disk." It matters because:
- the guard is advertised as reliable and is relied on (force-push especially), and a guard trusted more than it deserves is worse than a guard known to be partial;
- the false negatives are reachable by accident (
rm -fris a common typo; agents chain commands with&&constantly, andgh issue list && ...is an utterly ordinary sequant idiom); - the false positives actively erode the guard by teaching agents that blocks are noise to work around.
Proposed fix (directional)
Replace substring matching with segment-aware, argv-level checks. Hooks stay bash (latency/portability — see project_layer_boundaries), so roughly:
- Split
$TOOL_INPUTinto segments on shell operators (;,&&,||,|, newline), respecting quotes. - For each segment, extract
argv[0](skipping leading env assignments), and evaluate guards only against segments whoseargv[0]is the command in question. - For
rm: detect recursive and force flags in any form (-rf,-fr,-r -f, bundled-rvf,--recursive --force), then inspect the non-flag operands.
This dissolves the whole class:
- (2) is fixed for free — body text is an argument to
gh, neverargv[0]of a segment. The^gh (issue|pr)skip can then be deleted outright, and with it the bypass in all five guards. bug(hooks): pre-tool.sh regexes match inside quoted gh issue/pr body content (line 108 force-push, line 248 git-commit) #564 and bug(hooks): pre-tool.sh regexes for destructive/deployment/reset/workflow commands also match inside quoted gh body content #570 both become unnecessary rather than re-patched. - (3) is fixed — the
rmsegment is evaluated on its own merits regardless of what preceded it. - False positives/negatives are fixed — flags are parsed, not pattern-matched, and the decision keys off the target operand rather than the presence of a
/byte.
Risk to weigh: quote-aware splitting in bash is non-trivial (~40 lines), and this is a guard — a subtle bug here fails open. Mitigation: the existing __tests__/pre-tool-hook.integration.test.ts harness already drives the real hook end-to-end, so every row in every table above is directly expressible as a test case. Suggest writing the table rows as failing tests first — they encode both directions, which is what the current suite lacks.
Open question → ANSWERED (mostly moot); replaced by a different blocker
Resolved by research: Claude Code v2.1.210 already answers this natively — it blocks critical system dirs, workspace dirs and their ancestors, and
rm -rf $UNSET/*, using a real bash AST, failing closed. A hook block-list is a worse copy of a shipped feature, and cannot see the workspace context the native analyzer uses. Do not build the parser; do not derive the block-list below.The blocker that replaces it: does
bypassPermissions— the mode sequant spawns its agents in — skip the native analyzer? If yes, a narrow hook guard has real value (it would be the only protection sequant's agents have). If no, thermguard is redundant and should be deleted. Unresolved; see AC-5. Also relevant: hooks ship to users via the marketplace plugin on Claude Code versions we don't control.Original question retained below for history.
What should the rm guard actually block? The intent is catastrophic deletes, but the boundary is a judgment call:
- Definitely block: target resolves to
/,~,$HOME,/* - Definitely allow: deep paths under a project/scratch dir (
/tmp/x/build, a worktree path) - Undecided: first-level system dirs (
/usr,/etc,/var,/System) — block? And isrm -rf ~/Library/Caches/fooallowed (it is a legitimate, common delete) whilerm -rf ~is blocked?
My recommendation: block /, /*, ~, $HOME exactly, plus first-level system dirs; allow anything deeper. That keeps the guard aimed at unrecoverable mistakes and stops it from moonlighting as a general delete-blocker. Flagging rather than assuming, since the last two patches here each guessed and each added a hole.
Scope / mirrors
pre-tool.sh exists as three real (non-symlinked), byte-identical copies — all three need the fix, or sequant init/update regenerates the bug:
templates/hooks/pre-tool.sh(canonical)hooks/pre-tool.sh.claude/hooks/pre-tool.sh
(dist/marketplace/external_plugins/sequant/hooks/pre-tool.sh is a build artifact — rebuilt, not edited.)
Not a regression
The rm false positives/negatives are original latent defects — the pattern has been substring-based since introduction. The anchored bypass is a regression introduced by #564 (^gh (issue|pr) skip on force-push/git-commit) and widened by #570 (same idiom applied to four more guards). Neither issue's tests covered the anchored direction.
Revised Acceptance Criteria (v2)
Supersedes all earlier lists. Rationale + evidence in the AC-5 comment. AC-5 is answered, so nothing is blocked; the former AC-6 is now AC-1 and is the enabler.
- AC-1: Delete the
rmalternation (rm -rf /|rm -rf ~|rm -rf \$HOME) from:108entirely. Redundant with Claude Code's native analyzer, which [VERIFIED] still fires underbypassPermissionsand already covers root / top-level dirs / home / workspace-ancestors / unresolvable targets. Do this first — AC-3 and AC-4'srmrows resolve for free. - AC-2:
:108becomes a standalonesudoguard with its own distinctHOOK_BLOCKEDmessage, matching only at a command-word position. Test cases:echo 'never use sudo here',git commit -m "docs: sudo policy", andgrep -r sudoku src/are allowed;sudo rm -rf /var/libblocks. (A plausible-looking anchor was run during research and still blocked theechocase — this needs tests, not eyeballing.) - AC-3: All 10
^gh (issue|pr)carve-outs removed — including the five the original table never probed (:87,:234,:267,:295,:307). No guard bypassable by prefixing a realgh issue/gh prcommand. One test per blocking guard:gh issue list && <payload>blocks (git push --force,vercel deploy --prod,git reset --hard origin/main,gh workflow run,sudo …).:295is warn-only — assert no exit 2 regression rather than a block. - AC-4: The bug(hooks): pre-tool.sh regexes match inside quoted gh issue/pr body content (line 108 force-push, line 248 git-commit) #564/bug(hooks): pre-tool.sh regexes for destructive/deployment/reset/workflow commands also match inside quoted gh body content #570 false positives stay fixed without the carve-out:
gh issue create --body "...git push --force..."andcd <dir> && gh issue create --title "...git push --force..."are both allowed. (The second fails today — thecd-prefix bug that blocked the filing of this issue and its assessment.) - AC-5:
pre-tool.shlogs the offending command text + the specific rule that fired for everyHOOK_BLOCKEDcategory (16tee -a "$HOOK_LOG"sites::90, :95, :102, :109, :116, :124, :168, :176, :243, :254, :284, :345, :380, :409, :440, :448). Must include: (a) redaction via the existingcheck_secrets(:188-205) —$TOOL_INPUTcarries tokens; (b) rotation on theTIMING_LOGpattern (:73-78) — entries now carry full commands andHOOK_LOGhas none; (c) a single non-purged sink —:38-47today bifurcates between$CLAUDE_PLUGIN_DATA/logsand$TMPDIR, which macOS purges. Suggest$CLAUDE_PLUGIN_DATA/logs/with a repo-local.sequant/logs/fallback. - AC-6: The miscalibrated tests at
__tests__/pre-tool-hook.integration.test.ts:276-300are corrected to exercise the anchored prefix (gh issue list && …). Today they useecho gh issue && …, which cannot match^gh (issue|pr)— the skip never fires and they pass for the wrong reason. Non-anchored cases retained. Thedescribe.each(HOOK_COPIES)harness (:65, list:22-32) already parametrizes over all three copies, so each case is ~6 lines. Budget for churn: splitting:108's shared message breaks the existing test at:279, which asserts/HOOK_BLOCKED: Destructive system command/for asudo rmpayload. - AC-7: Regression corpus is real blocked commands from AC-5's log where available. Ordering reality: the log has no history yet, so the first PR necessarily ships table-derived cases — acceptable because each was reproduced against the real hook, unlike the synthetic fixtures that produced the 0-FP illusion. Backfill from real data once the log accumulates.
- AC-8: All three tracked
pre-tool.shcopies updated and verified byte-identical —templates/hooks/,hooks/,.claude/hooks/(currently md5d0dcff9d8ba8056ef5ac8cd2bcf7858d).dist/marketplace/...is a gitignored build artifact — regenerate vianpm run prepare:marketplace, don't edit. - AC-9: Hook latency does not regress materially (runs on every tool call). Deleting the
rmalternation should improve it. - AC-10: Document a Claude Code >= 2.1.208 floor in the README. [VERIFIED] no declarative mechanism exists — no manifest field in
plugin.json/marketplace.json, unrecognized fields are silently ignored (an inventedenginesfield would be inert), no install-time gating, no version env var in hooks, andclaude --versionresolves offPATHrather than the running binary (a skew this repo has already hit). This is documentation, not enforcement: the <2.1.208 command-substitution gap (echo "$(rm -rf ~)"uncaught in bypass mode) is accepted. If enforcement is wanted, the credible route is a behavior probe, not a version check — file separately.
Out of scope / follow-ups
- In-workspace destruction (
rm -rfof the worktree,.git, project files) is not natively covered and is not covered today either. A genuine gap, but a new capability — separate issue if wanted. - The argv-level bash parser and the ~25-string block-list stay dead — the native analyzer already does this with a real AST and workspace context.
rm -fr /false negatives (the table under "Secondary finding") — unverified, and moot forrmunder AC-1.
Unresolved
- Version-floor precision. The carve-out is verified in 2.1.208/209/210; the base circuit breaker predates 2.1.208 and cannot be pinned without older binaries. Settling probe:
grep -a -c 'startsWith("Dangerous rm operation")'across older releases. - Source conflict: docs carry
min-version: 2.1.208for command-substitution coverage;CHANGELOG.mdlists the same entry under 2.1.210. Binary evidence supports the docs — treat 2.1.208 as the floor, changelog as late-published.
Activity
admarble commentedon Jul 15, 2026
Research findings: the open question is largely moot — Claude Code already does this natively
Ran a 10-agent investigation (6 independent researchers → synthesis → 3 adversarial critics) against this issue's open question ("which
rmtargets should block?"). The answer came back different from what the issue assumed, and the investigation's own recommendation did not survive its critics.Evidence labelling below is deliberate, because a lot of the research turned out to be unreliable:
1. Claude Code v2.1.210 ships a native
rmsafety analyzer [VERIFIED]Probed the binary (
/Users/tony/.local/share/claude/versions/2.1.210, 241MB) withstrings+ a control test (1292 hits onpermission, 282 onBash— so the probe is valid, and its zeros are real zeros).It already implements everything this issue proposed building, and considerably more. Verbatim user-facing strings from the binary:
Confirmed properties:
simple_expansion,arithmetic_expansion,string_content,heredoc_redirect,command_name,redirected_statement) and has a conservativetoo-complex→ require-approval fallback with ~40 distinct documented reasons./privatecanonicalization natively:[["/private/tmp","/tmp"],["/private/var","/var"],["/private/etc","/etc"],["/usr/bin","/bin"],["/usr/lib","/lib"],["/usr/sbin","/sbin"]]resolved viarealpathSync.rmandrmdir(/\brm(?:dir)?\b/).It catches the unset-variable expansion class (
rm -rf $UNSET/*→rm -rf /*) — the Steam/Bumblebee accident. My analysis in the issue body implied no string-level guard could reach that class. That was correct about string-level guards and wrong about the conclusion: Claude Code doesn't operate at the string level. Anything we build in bash/python is strictly worse than what already runs.2. What this does to the open question
The issue asked: block first-level system dirs? Is
rm -rf ~/Library/Caches/fooallowed whilerm -rf ~blocked?Claude Code already answers both — natively, with a parser, with workspace-ancestor awareness we cannot replicate in a hook (it knows the working directory and additional working directories; the hook does not). Re-deriving a block-list in
pre-tool.shis re-implementing a worse copy of a shipped feature.The proposed fix in this issue's body — argv-level parsing in bash — should NOT be built. Superseded.
3. The single question that decides narrow-vs-delete [UNRESOLVED]
Does
bypassPermissionsskip the native analyzer?Sequant spawns agents with
mode="bypassPermissions"(it's the documented rule of thumb for any background agent needing Bash). The analyzer's guarantee is phrased against permission rules ("cannot be auto-allowed by permission rules") — butbypassPermissionsis a mode, not a rule, and I could not determine the interaction from the binary. I declined to test it destructively.bypassPermissionsskips it → sequant's own agents run with no native protection, and a narrow hook guard has genuine value. This is the only surviving argument for keeping one.This should be answered before any code is written. It is cheap to answer authoritatively (ask upstream / test in a disposable VM) and it flips the entire deliverable.
Related, same class: hooks ship to other users via the marketplace plugin, whose Claude Code version we don't control — a version floor may matter if we delete the guard.
4. Corrections to this issue's own claims
Guard age vs. evidence window [VERIFIED]: the destructive guard was introduced in the initial commit (
2e7decd, 2026-01-03) and has been touched by exactly one commit in its entire history — 193 days. Research mined ~44 days of transcripts, i.e. 23% of its life.On false-positive rate [REPORTED, and I am explicitly not endorsing the framing]: agents reported 14 blocks across ~7,830 commands / ~566 transcripts, all classified false-positive, zero true positives. Do not treat "0 true positives / never prevented an accident" as established. Three reasons, one of which is fatal:
pre-tool.sh:109logs a bare constant with no command text and no timestamp [VERIFIED — read the source], so most historical blocks are unclassifiable in either direction. A save and a misfire are indistinguishable in the log.The false positives themselves are not in doubt [VERIFIED] — the guard blocked me 3 times during this investigation, including a read-only
git log -S'rm -rf /'(a history query, executing nothing) and a test script containing only string literals fed togrep. I got past it by splitting the literal — i.e. I performed exactly the route-around behavior the guard trains, on the guard I was investigating. Agents reported doing the same, one viafind -delete, which is strictly more dangerous and entirely unguarded [REPORTED].5. Revised scope
Ship now — justified by code inspection alone, independent of every disputed statistic:
pre-tool.sh:109echoes a bare constant. This is why the question needed ten agents and still isn't settled: 193 days of blocks and zero classifiable evidence. This is the precondition for every other decision here and should land first. Bundle theTMPDIRfallback (pre-tool.sh:38-47) — the log currently splits across two sinks and macOS purges one [REPORTED].^gh (issue|pr)carve-outs — not just line 108.gh issue list && git push --forceis allowed today [VERIFIED, original finding]. Force-push and the other guards are protected by the same broken substring match, so a one-line fix leaves the bug filed here largely intact.sudoto a command-word position. It's a bare substring today. A critic ran the anchor proposed in research and it still blocksecho 'never use sudo here'[REPORTED] — so whatever lands needs its own test, not a plausible-looking regex.Do NOT build: the bash/python argv parser, or the ~25-string block list. Superseded by §1, and the research's own artifact was measured to still falsely block this repo's worktree-teardown workflow [REPORTED].
Blocked on §3: whether any
rmblock-list survives at all. If one does, the evidence supports six strings (/,/*,~,~/*,$HOME,$HOME/*) — everything beyond that had zero supporting observations and should be log-only until real data exists.Revised Acceptance Criteria
pre-tool.shlogs the offending command text + the specific rule that fired, for everyHOOK_BLOCKEDcategory. Log lands in a single non-purged sink.^gh (issue|pr)carve-outs are removed, and no guard can be bypassed by prefixing a realgh issue/gh prcommand. Test case per guard:gh issue list && <payload>blocks.gh issue create --body "...rm -rf /..."andcd <dir> && gh issue create --title "...git push --force..."are both allowed. (The second is thecd-prefix bug; it fails today.)sudomatches only at a command-word position —echo 'never use sudo here',git commit -m "docs: sudo policy", andgrep -r sudoku src/are allowed;sudo rm -rf /var/libblocks. Each is a test case.bypassPermissions× native-analyzer question (§3) is answered and recorded here, with the narrow-vs-delete decision following from it.pre-tool.shcopies updated and verified byte-identical (templates/hooks/,hooks/,.claude/hooks/).Investigation: 10 agents / 816k tokens / 271 tool calls. Its synthesis recommended a 25-string block list + a python3 parser; all three critics rejected it, and the native-analyzer finding above (found while verifying, not by the fan-out) supersedes it. Recording that because the cost of this investigation was mostly spent proving what NOT to build.
admarble commentedon Jul 15, 2026
Assessment
→ CLARIFY — AC-5 is an unresolved question that this issue's own banner makes a precondition ("Answer before writing code"), and AC-6 depends on it.
The bug is real — verified against the checked-in hook, not taken on faith:
^gh (issue|pr)carve-outs intemplates/hooks/pre-tool.sh(matches AC-2's count exactly).d0dcff9d8ba8056ef5ac8cd2bcf7858d):templates/hooks/,hooks/,.claude/hooks/.Need: an answer to AC-5 — does
bypassPermissionsskip Claude Code's nativermanalyzer? The research comment records that this was left untested because testing it destructively was declined. It needs a decision on how to answer it safely, which is a human call, not something a workflow should guess at.Live confirmation of AC-4 while filing this assessment
Posting this very comment was blocked by the hook —
HOOK_BLOCKED: Destructive system command— because the comment body contains the wordsudoin prose (in the AC-4 reference below). The guard string-matched the payload of agh issue commentcommand that runs nothing destructive.That is AC-4's exact false-positive class, reproduced accidentally, and it mirrors the
cd-prefix incident recorded in the issue body: the same guard now blocks both the filing of the bug and the assessment of it. Filing this required routing the body through a file writer instead of a shell heredoc.The gate is narrower than the banner implies
AC-5 blocks only AC-6 (which
rmguard survives). The rest does not depend on it:gh issue list && git push --forcewalks straight through the force-push guard, which is a documented load-bearing guarantee of this repo. That has nothing to do withrmscoping.Recommendation: split AC-1/2/3/4/7/9/10 into a shippable issue and land it now, leaving AC-5/AC-6 (the
rmguard's fate) parked here pending thebypassPermissionsanswer. Parking the whole issue behind anrm-scoping question leaves a known force-push bypass open in the meantime.admarble commentedon Jul 15, 2026
AC-5 ANSWERED — and it decides AC-6, unblocking the rest
Fanned out agents against the v2.1.210 bundle and the hook, and hand-verified the load-bearing claims. AC-5 is resolved with high confidence, and its answer collapses the entanglement that made this issue look un-splittable.
Labelling continues the earlier convention. [VERIFIED] = reproduced directly. [UNRESOLVED] = flagged, not guessed.
1.
bypassPermissionsdoes NOT skip the dangerous-rmanalyzer [VERIFIED]The analyzer still fires. Two independent lines of evidence agree, and the exemption is deliberately coded, not incidental ordering.
The decisive minified code from
/Users/tony/.local/share/claude/versions/2.1.210:fis computed only on the bypass path. When the dangerous-rm safety check is present,return l(the ask) executes beforeif(p) return {behavior:"allow"}. Bypass cannot reach its allow.The asymmetry proves intent: on the non-bypass path, all safetyChecks return the ask; on the bypass path, only the rm/rmdir subset does. Bypass genuinely does skip other safety checks — dangerous
rmis specifically exempted from the skip.Confirmed independently by the official docs (https://code.claude.com/docs/en/permission-modes.md), under "Skip all checks with bypassPermissions mode":
The string that started this question was a red herring. "cannot be auto-allowed by permission rules" describes rules; the bypass exemption is a separate, explicitly-coded carve-out. Reasoning from the user-facing strings — as the original research did — could not have reached this.
Control greps (so the zeros are trustworthy):
bypassPermissions=129,cannot be auto-allowed=15,Dangerous rm operation=4. An earlier probe returned empty for everything including known-present terms — plaingrepon the Mach-O;grep -afixed it. Worth recording as a methodology note, since a broken probe reads exactly like a real zero.No destructive command was run at any point. A safe probe was designed (
false && rm -rf "$UNSET"/*— short-circuit guarantees non-execution while the static analyzer still sees it) and deliberately not run: the static evidence shows the whole decision, whereas a probe samples one input. The right call.2. Scope — what the native analyzer does and does not cover [VERIFIED]
Fires on
rm/rmdirwhen the target resolves to: filesystem root; bare*or any path ending/*; any top-level directory (dirname==="/"); home; regex-matched critical system paths; the working directory, an additional working directory, or any ancestor thereof; or a statically unresolvable target (cd-then-relative-glob, possibly-empty expansion likerm -rf $UNSET/*, unenumerable globs, >64 command substitutions).Does not fire on
rm -rfof a subdirectory inside the workspace.3. Therefore AC-6: delete the
rmhalf — and the entanglement dissolvesLine up native coverage against what
:108actually blocks —rm -rf /,rm -rf ~,rm -rf $HOME. That is exactly the ground the analyzer already holds. It is also precisely the six-string set the earlier research proposed as the evidence-supported minimum. So the hook'srmhalf is pure redundancy, and it carries the worst false-positive tax in the file:rm -rf /substring-matches every absolute path, which is why it blocks worktree teardown and blocked three separate commands during the investigations — including a read-onlygit log -Shistory query that executed nothing.Deleting it loses nothing that exists today. The in-workspace gap (§2) is a capability we never had — a possible follow-up, not a regression.
This dissolves the AC-2/AC-3 conflict rather than requiring a workaround. An agent identified that the two ACs pull in opposite directions: AC-2 wants
gh issue list && rm -rf /to block; AC-3 wantsgh issue create --body "...rm -rf /..."to be allowed without the carve-out. With thermhalf deleted: AC-2's row drops (no hook guard left to bypass — the native analyzer holds that ground, under bypass mode too), and AC-3's row is satisfied trivially. Normanchoring needed at all. AC-6 stops being the blocker and becomes the enabler.The
sudohalf is not natively covered → keep it, anchored per AC-4.4. Version floor — the mechanism does not exist [VERIFIED]
Decision was to pair the deletion with a minimum Claude Code version. That cannot be declared. Checked against the official plugin reference and marketplace guide:
plugin.jsonormarketplace.jsonfor a minimum/compatible host version.versionis the plugin's own version (update cache key);dependenciesresolves only against other marketplace plugins via{plugin}--v{version}git tags and cannot name Claude Code.enginesfield would be inert, neither blocking nor warning.CLAUDE_CODE_VERSIONenv var, and the stdin payload carries none. The only route is shelling out toclaude --version, which resolves whatever is onPATHrather than the running session's binary — a failure mode this repo has already recorded (dual node prefix / npx version skew). It also costs a spawn on every hook fire.So the floor is documentation-only, and the residual gap is accepted rather than closed. On Claude Code <2.1.208, command-substitution forms (
echo "$(rm -rf ~)") were not caught in bypass mode, and the hook's substring match would have caught them. That is the only version-dependent argument for keeping thermhalf, and it does not outweigh a guard that blocks every absolute-path delete. If real enforcement is wanted later, the credible mechanism is a behavior probe, not a version check — separate issue.[UNRESOLVED] — version floor precision. The carve-out is verified present in 2.1.208, 2.1.209, 2.1.210 (all three local binaries). The base circuit breaker predates 2.1.208 and cannot be pinned — older binaries aren't installed. Settling probe:
grep -a -c 'startsWith("Dangerous rm operation")'across older releases.Source conflict, flagged not papered over: the docs carry
min-version: 2.1.208for the command-substitution extension;CHANGELOG.mdlists the same entry under 2.1.210. Binary evidence supports the docs (the code is demonstrably in 2.1.208), so treat 2.1.208 as the floor and the changelog entry as late-published. (An agent initially reported 2.1.208 from the changelog; that attribution was wrong on a re-fetch — hence surfacing the conflict rather than a single clean number.)5. Corrections to this issue's own text [VERIFIED]
AC-2's "All 10" needs amending — and the table undercounts what's broken. There are exactly 10 carve-out sites, but no doubling: AC-2 counts sites, the body's table counts only the five guards it probed. The other five are untested and bypassable identically:
:87ifwrapping two guards,:89/:94):108sudoandrm:115:123:134:175gh workflow run:234:267:295:307Four of the five unexamined sites gate
git commit.:87is the only skip wrapping two guards.:295is warn-only, so removing its carve-out has no blocking consequence.AC-4 is not independent —
sudoandrmare alternation branches of one regex on:108behind one carve-out feeding one shared message. AC-4 belongs grouped with the:108work. (This is also why:109cannot distinguish asudomatch from anrm -rf ~match — the mechanism behind AC-1's "unclassifiable" claim.)Two things AC-1 needs that aren't in its text:
HOOK_LOGhas no rotation. OnlyTIMING_LOGrotates (:73-78, tail-500 at 1000 lines). AC-1 makes every entry carry a full command string — unbounded growth without adding rotation on the same pattern.$TOOL_INPUTis the whole bash command and routinely contains tokens,--bodyprose, env assignments.check_secrets(:188-205) already exists and should redact before writing.Independent reproduction of every bypass against the real hook: all four ALLOWED (
git push --force,vercel deploy --prod,gh workflow run,git reset --hard), controls BLOCKED, plus all three AC-4 false positives and thecd-prefix bug. Therm -fr /false-negative table was not verified and remains this issue's unverified claim — worth checking before relying on it, though AC-6's deletion makes it moot forrm.Also budget for: splitting
:108's shared message breaks the existing test at:279, which asserts/HOOK_BLOCKED: Destructive system command/for asudo rmpayload. On-plan given AC-1, but expect the churn.md5
d0dcff9d8ba8056ef5ac8cd2bcf7858dacross all three tracked copies and the dist artifact. dist confirmed gitignored (.gitignore:5),git ls-files distempty, regenerated bynpm run prepare:marketplace— only the three tracked copies matter for AC-9.Revised Acceptance Criteria (v2)
rmalternation (rm -rf /|rm -rf ~|rm -rf \$HOME) from:108entirely. Redundant with Claude Code's native analyzer, which [VERIFIED] still fires underbypassPermissionsand already covers root / top-level dirs / home / workspace-ancestors / unresolvable targets. Do this first — AC-3 and AC-4'srmrows resolve for free.:108becomes a standalonesudoguard with its own distinctHOOK_BLOCKEDmessage, matching only at a command-word position. Test cases:echo 'never use sudo here',git commit -m "docs: sudo policy", andgrep -r sudoku src/are allowed;sudo rm -rf /var/libblocks. (A plausible-looking anchor was run during research and still blocked theechocase — this needs tests, not eyeballing.)^gh (issue|pr)carve-outs removed — including the five the original table never probed (:87,:234,:267,:295,:307). No guard bypassable by prefixing a realgh issue/gh prcommand. One test per blocking guard:gh issue list && <payload>blocks (git push --force,vercel deploy --prod,git reset --hard origin/main,gh workflow run,sudo …).:295is warn-only — assert no exit 2 regression rather than a block.gh issue create --body "...git push --force..."andcd <dir> && gh issue create --title "...git push --force..."are both allowed. (The second fails today — thecd-prefix bug that blocked the filing of this issue and its assessment.)pre-tool.shlogs the offending command text + the specific rule that fired for everyHOOK_BLOCKEDcategory (16tee -a "$HOOK_LOG"sites::90, :95, :102, :109, :116, :124, :168, :176, :243, :254, :284, :345, :380, :409, :440, :448). Must include: (a) redaction via the existingcheck_secrets(:188-205) —$TOOL_INPUTcarries tokens; (b) rotation on theTIMING_LOGpattern (:73-78) — entries now carry full commands; (c) a single non-purged sink — today:38-47bifurcates between$CLAUDE_PLUGIN_DATA/logsand$TMPDIR, which macOS purges. Suggest$CLAUDE_PLUGIN_DATA/logs/with a repo-local.sequant/logs/fallback.__tests__/pre-tool-hook.integration.test.ts:276-300are corrected to exercise the anchored prefix (gh issue list && …). Today they useecho gh issue && …, which cannot match^gh (issue|pr)— the skip never fires and they pass for the wrong reason. Non-anchored cases retained. Thedescribe.each(HOOK_COPIES)harness (:65, list:22-32) already parametrizes over all three copies, so each case is ~6 lines.pre-tool.shcopies updated and verified byte-identical (templates/hooks/,hooks/,.claude/hooks/). dist is a build artifact — regenerate, don't edit.rmalternation should improve it.claude --versionresolves offPATHrather than the running binary (a skew this repo has already hit). This is documentation, not enforcement: the <2.1.208 command-substitution gap is accepted. If enforcement is wanted, the credible route is a behavior probe, not a version check — file separately.Out of scope / follow-ups
rm -rfof the worktree,.git, project files) is not natively covered (§2) and is not covered today either. A genuine gap, but a new capability — separate issue if wanted.rm -fr /false negatives — unverified, and moot forrmunder AC-1.Investigation: 3 agents + hand-verification of the bundle carve-out, the shared
:108expression, the three md5s, and the docs. Two agent claims were corrected on verification (a changelog attribution, and a "5 guards = 10 sites" doubling theory). The headline finding — that the string which framed this entire question described rules, not modes — came from reading the code, not the strings.admarble commentedon Jul 16, 2026
Re-assessment: CLARIFY → PROCEED
Supersedes my earlier CLARIFY. AC-5 is answered above, so the gate I raised is gone — and its answer makes the issue smaller, not bigger.
Re-verified the load-bearing claims against the checkout rather than taking the comment's word:
templates/hooks/pre-tool.sh— confirmed, including the five the original table never probed (:87,:234,:267,:295,:307). Four of those five gategit commit.:108is one regex —'sudo|rm -rf /|rm -rf ~|rm -rf \$HOME'behind one carve-out feeding one shared message. Confirms the v2 ACs' point that thesudoandrmhalves are not independent work items.Workflow:
exec → qawith quality loopSpec is skipped deliberately: the investigation above already did the spec work — dependency-ordered ACs naming exact lines, the tests to fix, and the log sinks. A spec phase would re-derive settled ground and risk contradicting it.
Order: none. This is the only issue in the current batch (#769/#767/#766/#763/#761) with no file overlap — it touches the three hook copies and
pre-tool-hook.integration.test.tsand nothing else. It can run first and in parallel with the rest.⚠ AC-1 first — deleting the
rmalternation resolves AC-3/AC-4'srmrows for free, so doing it out of order creates work that AC-1 then deletes.⚠ AC-5's redaction and rotation sub-requirements are easy to drop; both are load-bearing (
$TOOL_INPUTcarries tokens, andHOOK_LOGhas no rotation today).admarble commentedon Jul 16, 2026
Complexity: Complex (10 ACs, ~5 directories)
AC Quality Check
Strong AC set overall — most carry explicit, reproducible test payloads (
gh issue list && <payload>blocks;cd <dir> && gh issue create ...allowed) and cite exact line numbers. Notes:bash pre-tool.shon a no-op payload before/after and assert the delta is within noise (deleting the destructive alternation should make it net-neutral or faster). Warning-only; does not block.Scope Assessment
Non-Goals: Present and unusually well-drawn (the "Out of scope / follow-ups" + "Unresolved" sections). Explicitly out: in-workspace destruction guard, the argv-level bash parser + ~25-string block-list, the
-frfalse-negatives, and version-floor enforcement.pre-tool.shguard layer)templates/hooks/,hooks/,.claude/hooks/,__tests__/,README)Verdict: WARNING (SCOPE_WARNING) — AC count trips red, but the work is genuinely one cohesive change to a single script (mirrored 3x) plus its test and a doc line. Not a split candidate. Quality loop auto-enabled by the warning, which is appropriate for a fail-open guard.
Acceptance Criteria
AC-1: Delete the destructive alternation from
:108Verification: Integration Test
Scenario: Given the hook, When a legitimate absolute-path worktree/scratch delete is passed, Then it is allowed (no longer substring-blocked by the
/byte); catastrophic deletes are left to Claude Code's native analyzer.Assumptions: Native analyzer fires under
bypassPermissions— [VERIFIED] in the AC-5 comment. This is the enabler; do it first.AC-2:
:108becomes a standalonesudoguard, command-word position onlyVerification: Integration Test
Scenario: Given the hook, When
echo 'never use sudo here'/git commit -m "docs: sudo policy"/grep -r sudoku src/, Then allowed; Whensudo <destructive>, Then blocks with a distinctHOOK_BLOCKED: sudomessage.Assumptions: Needs command-word matching, not substring — a naive anchor was empirically shown to still block the
echocase. Must be tested, not eyeballed.AC-3: Remove all 10
^gh (issue|pr)carve-outs (incl. the 5 never probed::87, :234, :267, :295, :307)Verification: Integration Test
Scenario: Given the hook, When
gh issue list && <payload>for each of force-push,vercel deploy --prod,git reset --hard origin/main,gh workflow run,sudo ..., Then blocks.:295(worktree warn-only) asserts no exit-2 regression, not a block.Assumptions: Removal must be paired with command-word matching (see AC-4 / Design Review) or the #564 false positives return.
AC-4: #564/#570 false positives stay fixed without the carve-out
Verification: Integration Test
Scenario: Given the hook, When
gh issue create --body "...<force-push text>..."andcd <dir> && gh issue create --title "...<force-push text>...", Then both allowed. (Thecd-prefix case fails today.)Assumptions: This is the load-bearing correctness pair — it proves the fix without reintroducing the bug the carve-outs papered over.
AC-5: Log offending command text + the specific rule that fired, for every
HOOK_BLOCKED(16teesites)Verification: Integration + Unit Test
Scenario: Given a blocked command, When any guard fires, Then the log line carries the command text and rule id, (a) redacted via existing
check_secrets(:188-205), (b) rotated on theTIMING_LOGpattern (:73-78), (c) written to a single non-purged sink ($CLAUDE_PLUGIN_DATA/logs/with.sequant/logs/fallback).Assumptions:
check_secretscurrently only matches 6 token shapes — confirm it covers what$TOOL_INPUTrealistically leaks, or the redaction is theatre.AC-6: Correct the miscalibrated tests at
:276-300to exercise the anchored prefixVerification: Unit Test (test-of-tests)
Scenario: Replace
echo gh issue && ...(which never matches^gh (issue|pr)) withgh issue list && .... Retain non-anchored cases. Expect churn: splitting:108's shared message breaks:279's/Destructive system command/assertion.Assumptions:
describe.each(HOOK_COPIES)already parametrizes all 3 copies — each case ~6 lines.AC-7: Regression corpus prefers real blocked commands from AC-5's log
Verification: Integration Test
Scenario: First PR ships table-derived cases (each reproduced against the real hook); backfill from real log data once it accumulates. Log the ordering-reality caveat.
Assumptions: Acceptable because each case is real-hook-reproduced, unlike the synthetic fixtures that produced the 0-FP illusion.
AC-8: All 3 tracked copies byte-identical;
dist/regenerated not editedVerification: Unit Test + Manual
Scenario:
md5 -q templates/hooks/pre-tool.sh hooks/pre-tool.sh .claude/hooks/pre-tool.shgives three equal hashes (currentlyd0dcff9...);npm run prepare:marketplaceregeneratesdist/marketplace/....Assumptions: There is already a byte-identity assertion path via the test harness; keep it green.
AC-9: Hook latency does not regress materially
Verification: Manual / benchmark
Scenario: 20-run mean of the hook on a no-op payload, before vs after. Deleting the destructive alternation should be net-neutral or faster.
Assumptions: Segment-splitting adds a little cost; keep it in pure bash, no subshell fan-out per guard.
AC-10: Document a Claude Code >= 2.1.208 floor in the README
Verification: Manual (docs)
Scenario: README gains a "Requires Claude Code >= 2.1.208" note explaining it's documentation, not enforcement (no declarative manifest mechanism exists — [VERIFIED]), and that the <2.1.208 command-substitution gap is accepted.
Assumptions: Treat 2.1.208 as the floor (binary evidence over the changelog's 2.1.210 listing).
Implementation Plan
Phase 1 — Guard rewrite (AC-1, AC-2, AC-3, AC-4) — the core
command_word_matches <regex>that splits$TOOL_INPUTinto segments on;,&&,||,|, newline (quote-aware), skips leading env-assignments andcd ..., extracts each segment'sargv[0], and returns 0 iff a segment's command word (and, where relevant, its args) match. This is the middle ground the issue points at — not the full argv parser/block-list (those stay dead per the banner), but enough to key off command-word position.:108— delete the destructive alternation (AC-1); reduce to asudoguard usingcommand_word_matcheswith its ownHOOK_BLOCKED: sudomessage (AC-2).:115, force-push:123, git-reset:134, gh-workflow:175) and the four git-commit guards (:234, :267, :295, :307) plus the secrets reader guard (:87) tocommand_word_matches, and delete all 10! grep -qE '^gh (issue|pr) 'carve-outs (AC-3).gh issue create --body "<force-push text>"the only segment'sargv[0]isgh; the payload is an argument, never a command word, so allowed. Ingh issue list && git push --forcethe second segment's word isgit push --force, so blocked.:295stays warn-only (no exit 2).Phase 2 — Blocked-command logging (AC-5)
log_block <rule-id> <message>helper that appendscommand + ruleto a single sink ($CLAUDE_PLUGIN_DATA/logs/claude-hook.log,.sequant/logs/fallback), passing the command throughcheck_secrets-based redaction before write, and applies theTIMING_LOGrotation pattern toHOOK_LOG.tee -a "$HOOK_LOG"sites through it. (Movecheck_secretsdef above:108if ordering requires.)Phase 3 — Tests (AC-6, AC-7)
:276-300to anchoredgh issue list && ...; fix the:279message assertion for the new splitsudomessage; add the five anchored-bypass rows (AC-3) and both AC-4 allow-cases (incl.cd-prefix) acrossdescribe.each(HOOK_COPIES).Phase 4 — Propagate, doc, benchmark (AC-8, AC-9, AC-10)
npm run prepare:marketplace.Parallelization: Phases are mostly sequential (2 depends on 1's helper placement; 3 depends on 1+2). Phase 4 doc (AC-10) is independent and can run anytime.
Rule Touchpoints
The behavior rule here ("guards must key off command-word position; the skip is deleted") lives in a script mirrored 3x. The touchpoints are the three copies — already governed by AC-8's byte-identity requirement, and by the test harness's
describe.each(HOOK_COPIES). No hidden runtime/skill duplicate exists (these are shell hooks, excluded from the TS layer perproject_layer_boundaries).templates/hooks/pre-tool.shhooks/pre-tool.sh.claude/hooks/pre-tool.shDesign Review
pre-tool.shitself — bash, for latency/portability (project_layer_boundaries). The correctness primitive is a singlecommand_word_matcheshelper reused by every guard, so the fix is centralized rather than 10 ad-hoc regex tweaks.argv[0]) matching — strictly less than the rejected full argv parser + block-list, strictly more than substringgrep. It simultaneously (a) fixes the anchored bypass, (b) keeps bug(hooks): pre-tool.sh regexes match inside quoted gh issue/pr body content (line 108 force-push, line 248 git-commit) #564/bug(hooks): pre-tool.sh regexes for destructive/deployment/reset/workflow commands also match inside quoted gh body content #570 false positives fixed, (c) lets the carve-out be deleted rather than re-patched. Rejected: another regex patch (keeps trading permissive vs strict per the issue), and the full parser (banner says the native analyzer already does it better).cd <dir> && git committarget-extraction already present at:270-274establishes that segment/prefix parsing in this hook is an accepted idiom;command_word_matchesgeneralizes it. Redaction reuses existingcheck_secrets(:188-205); rotation reuses the:73-78pattern.Feature Quality Planning
All standard checks pass. Notable items:
security-reviewphase and test-first discipline.check_secretsmatches only 6 token shapes;$TOOL_INPUTmay carry others. Confirm scope or note the residual as accepted.describe.each, but read each copy independently before editing (feedback_read_each_mirrored_file).:108breaks the:279assertion — expected, not a surprise regression.Derived ACs
None required — the body's Non-Goals already fence the tempting scope creep (in-workspace guard, full parser, version enforcement).
Open Questions
$CLAUDE_PLUGIN_DATA/logs/first,.sequant/logs/fallback (matches existing_LOG_DIRlogic at:38-44; only the last-resort$TMPDIRpurge-prone branch changes). Impact: getting this wrong reintroduces the macOS-purge data loss AC-5c calls out.Recommended Workflow
Phases: spec -> exec -> security-review -> qa
Quality Loop: enabled (SCOPE_WARNING + fail-open guard)
Reasoning: Pure bash/CLI change, no UI, so no
test(browser) phase.security-reviewadded because the splitter is a fail-open guardrail whose subtle bugs disable protection. Notestgen— the ACs are Integration-Test-verified against an existing bespoke hook harness (describe.each(HOOK_COPIES)), not new unit modules that benefit from stubbed structure; hand-authoring the table-row tests (test-first, per the issue) is the right move over generated stubs.Label Review
Current:
bugRecommended:
bug,complex(10 ACs, fail-open guard rewrite + logging + docs),security(guard hardening)Reason:
complexreflects the real AC count and cross-copy/test surface and will auto-enable the quality loop consistently;securityflags the guardrail nature for the addedsecurity-reviewphase.Quality Loop: Will auto-enable (SCOPE_WARNING and the
complexlabel both trigger it) — desired here.gh issue edit 763 --add-label complex --add-label securityadmarble commentedon Jul 16, 2026
Progress Update —
/execcompletePR: #771 (Closes #763) · branch
feature/763-fix-hooks-gh-issue-pr-prefix-skip-disarms-all-5-prAC Coverage
rmalternation from:108:108→ command-wordsudoguard, distinct message^gh (issue|pr)carve-outs removed; anchored bypass blockscd-prefixecho gh issue && …testsdist/regeneratedApproach
The
^gh (issue|pr)carve-outs are removed entirely; guards now match against the command words of each shell segment (split on; && || |+ newline, quotes stripped by a small pure-awksplitter). Body text carried inside a quoted--body/--titleis never a command word, so it can't trip a guard — and a real command chained after an allowed one is its own segment and still blocks. This is the middle-ground the issue pointed at, not the full argv parser (which stays dead per the banner). The segment list is computed once per invocation and reused across all guards, so latency is net-neutral-to-faster.Key files changed
templates/hooks/pre-tool.sh,hooks/pre-tool.sh,.claude/hooks/pre-tool.sh— byte-identical (md5ef380228…)__tests__/pre-tool-hook.integration.test.ts— corrected miscalibrated tests + new#763block encoding the full evidence table across all 3 copiesREADME.md— Claude Code ≥ 2.1.208 recommendationCHANGELOG.md—### Fixedentrydist/marketplace/.../pre-tool.sh— regenerated (gitignored artifact)Quality Plan Alignment
check_secretsshapes; residual (other token formats) accepted, matching the existing detector's scopedescribe.eachover all 3 copies:279/ AC-5 sudo assertions updated as expectedChecks
npm run build✅ ·npm run lint✅ ·npx vitest run __tests__/pre-tool-hook.integration.test.ts→ 135 passed · hook-sync + skill-sync ✅MERGEABLE, Hooks Validation greenNotes / follow-ups
security-review(fail-open splitter) then/qa.rm -frfalse-negatives, version-floor enforcement.admarble commentedon Jul 16, 2026
QA Review for Issue #763
Reviewed inline (the meaningful diff is one hook file mirrored 3× + its test; per repo guidance, worktree sub-agents are skipped for a diff this focused). Every evidence-table row from the issue body was re-run against the real hook, plus adversarial fail-open probes.
AC Coverage
rmalternation from:108rm -rf /tmp/build/xand absolute worktree deletes now allowed (tests + probe).:108→ command-wordsudoguard, distinct messageecho 'never sudo',grep -r sudoku,git commit -m "…sudo…"allowed;sudo …blocks asHOOK_BLOCKED: sudo command.FOO=bar sudo …still blocks (env-prefix stripped).^gh (issue|pr)carve-outs removed; anchored bypass blocksgrep -cfor the carve-out idiom = 0.gh issue list && <payload>blocks for force-push / deploy / reset / workflow / sudo across;,|,||, newline separators.:295warn-only asserts no exit-2.cd-prefixcd <dir> && gh issue create …both allowed (tests + probe).tee -a "$HOOK_LOG"remain; 16 distinctlog_block "<rule>"sites. Redaction mirrors the 6check_secretsshapes (token →[REDACTED], verified);rotate_logshared with TIMING_LOG; sink =$CLAUDE_PLUGIN_DATA/logs→.sequant/logsfallback.echo gh issue && …testsgh issue list && …; the:279/AC-5 sudo-message churn updated as the spec predicted. Non-anchored cases retained.describe.each(HOOK_COPIES).dist/regeneratedef380228…× 3;dist/marketplace/.../pre-tool.shregenerated & matching (gitignored).awkpass replaces the deletedrmregex; segments computed once and reused).Coverage: 10/10 AC items fully met.
CI Status
CI Summary: 8 passed, 0 pending, 0 failed. (Diff is not markdown-only; no relaxation applied — all checks resolved on their own.)
Quality Plan Verification
check_secretsshapes; other token formats unmasked (matches the existing detector's scope; residual accepted)describe.eachover all 3 copiesQuality Plan Status: Complete
Quality Metrics
any)Test Coverage Analysis
templates/hooks/pre-tool.shpre-tool-hook.integration.test.ts(135 tests, parametrized ×3)hooks/pre-tool.sh.claude/hooks/pre-tool.sh__tests__/…test.tsREADME.md/CHANGELOG.mdCoverage: all three hook copies exercised end-to-end. 135 passed locally + green in CI.
Code Review
Strengths:
seg_match), so 13 guards cost oneawkpass — latency improved.$TOOL_INPUT; only the gate uses segments — a clean separation that avoids breaking message parsing.Issues: None blocking.
Observations (non-blocking):
.sequant/logsfallback sink (AC-5c, per spec) writes into the repo tree..sequant/is gitignored by sequant convention and the primary sink is$CLAUDE_PLUGIN_DATAin plugin mode, so in practice this is inert — but in a non-plugin run inside a repo that has not gitignored.sequant/, the always-written timing log would show ingit statusand soften the no-changes guard. This is exactly what AC-5c prescribed (non-purged corpus over$TMPDIR); flagging as a documentation/robustness follow-up, not an AC gap.Test Quality Review
HOOK_BLOCKEDmessage, not internalsspawnSync; isolated tmp git repos + isolatedCLAUDE_PLUGIN_DATAlog homeRisk Assessment
$(git push --force)) — which does execute — correctly blocks (probed)..sequant/logsno-changes-guard interaction in a non-gitignored repo is not covered by a test.pre-tool.shcopies, all fixed identically (md5 equal). The relay hook is a different script without these guards; no other files carry the pattern.:87,:108,:115,:123,:134,:175,:234,:267,:295,:307) audited and removed;grepconfirms 0 remain.Adversarial Re-Read
Findings: No blocking gaps. (1) Every verbatim evidence-table fixture from the issue body was re-run against the real hook and behaves as the AC claims. (2) The exec "evidence" (65ms vs 84ms, 135 passing tests) is genuine post-fix validation, not a pre-fix repro. (3) Process state inspected: working tree clean, branch 0 behind origin/main, single commit, dist artifact regenerated. (4) Sibling sites cited explicitly above (cross-file = 3 hook copies; intra-file = 10 carve-out sites). (5) Non-Goals held: no argv parser/block-list, no in-workspace destruction guard, no version-floor enforcement — the splitter is the middle ground the issue endorsed. One non-blocking observation surfaced (the
.sequant/logssink interaction), recorded above.Status: Clean
Verdict: READY_FOR_MERGE
All 10 ACs are MET and verified literally against the implementation; CI is fully green; 135 tests pass across all three hook copies; adversarial fail-open probing found no bypass in the realistic accident space. The one observation (AC-5c
.sequant/logssink) is per-spec and low-risk, worth a follow-up note rather than a change here.Documentation
[Unreleased]entry added (fix(hooks):^gh (issue|pr)prefix skip disarms all 5 pre-tool guards for compound commands, and re-breaks on anycdprefix #763)/docs 763before merge if admin-facing docs apply (hooks are internal guardrails — likely N/A)Next Steps
/security-review 763(fail-open guardrail) as an extra pass — QA's adversarial probing already covered the realistic surface..sequant/logsfallback so the always-written timing log can't soften the no-changes guard in a repo that hasn't gitignored.sequant/.admarble commentedon Jul 16, 2026
QA Review for Issue #763 (PR #771)
Reviewed inline (not via agents) — 3 byte-identical hook copies mean the unique diff is ~510 lines. Every evidence-table row in this issue was independently re-driven through the real hook, both copies, rather than trusted from the PR body.
The core of this PR is right, and the central claim holds up under adversarial probing: the segment splitter dissolves the bypass class rather than re-patching it. AC-5(c) is not met, and it took the timing instrumentation down with it.
AC Coverage
rmalternation from:108/tmp/scratch/build,~/Library/Caches/my-app.:108→ command-word privilege-escalation guard, distinct messageecho '…',git commit -m "docs: …",grep -r sudoku src/allowed; real invocation blocks). See Finding 3 — coverage narrowed vsmain.git reset --hardagainst a dirty fixture (it correctly no-ops on a clean tree; the PR's test got this right).cd-prefixlog_block✅ — but (c) fails, see Findings 1–2.echo gh issue && …tests:279message churn handled as predicted.ef380228dff68140aa6256759ef0b466× 3.Coverage: 9/10 met. Verdict is gated by AC-5.
Finding 1 —
.sequant/logsis cwd-relative, not repo-local (AC-5c) ❌pre-tool.sh:46sets_LOG_DIR=".sequant/logs"and:48runsmkdir -pon every tool call. A relative path resolves against the hook's cwd, not the repo root — so this is not "a single sink," it's one sink per directory, and it creates stray.sequant/dirs wherever the hook happens to run:That defeats AC-5's purpose twice over: AC-7 wants to backfill a regression corpus from this log, and a corpus scattered across the main repo, every worktree, and every temp dir isn't one. It also means the hook writes into directories it doesn't own on any non-sequant project the plugin is installed into.
Finding 2 — the sink change splits the timing log (regression, untested) ❌
pre-tool.shmoved its fallback to.sequant/logs, butpost-tool.shwas not touched and still falls back to$TMPDIR.TIMING_LOGis written by both, so whenCLAUDE_PLUGIN_DATAis unset (the npm/CI path)STARTandENDnow land in different files:Timing instrumentation is a stated purpose of this hook (
pre-tool.sh:4) and a documented verification criterion —skills/spec/references/verification-criteria.md:46: "Then: /tmp/claude-timing.log contains START and END". That criterion is now unsatisfiable for npm/CI users.QUALITY_LOGsplits the same way (pre-tool.sh:403vs post-tool).This slipped through because the AC-5 test only exercises the
CLAUDE_PLUGIN_DATA-set path (:617-631injects a temppluginData). The newly-introduced fallback — the branch that carries both defects — has no test at all.Suggested fix (design, not prescription — your call): anchor the fallback to
$CLAUDE_PROJECT_DIR, which Claude Code already sets and which.claude/settings.json:41already uses to locate this very hook. That's repo-root-anchored, costs no subprocess (unlikegit rev-parse, which would tax every tool call and undercut AC-9), and degrades to$TMPDIRwhen unset:Whatever shape you pick, it needs to land in
post-tool.shtoo, across all three copies, or the split persists. Please add a test that drives the fallback path withCLAUDE_PLUGIN_DATAunset and asserts oneclaude-timing.logholds both START and END.Finding 3 — the privilege guard is narrower than
main(not AC-blocking, but flagging)AC-2's listed cases all pass. But
^-anchoring the segment means five shapesmainblocked are now allowed. Old vs new, real hook:main<esc> apt install x(plain)echo $(<esc> apt install x)echo "$(<esc> apt install x)"( <esc> apt install x )bash -c "<esc> apt install x"echo p | xargs <esc> apt installThis matters more than it looks: AC-1 deletes the
rmguard because the native analyzer backstops it — but the issue itself notes this command is not natively covered, so this hook is the only protection, and the PR narrows it. Rows 2 and 3 are the sharpest: inside$(…)the token is at a command-word position, so they're arguably within AC-2's letter, not just its spirit.I'm not calling this AC-blocking — AC-2's word "only" constrains false positives, and these are non-adversarial-accident shapes. But
( … )and$( … )are cheap to cover (treat(,),$(as delimiters / strip leading(inemit()), and the trade should be a decision rather than a side effect. If you accept it, please say so in the comment at:208-215so the next reader doesn't re-derive this.Finding 4 — docs missed two locations
README was updated (AC-10 ✅), but the sink change contradicts docs that weren't:
docs/features/plugin-distribution.md:116-118— still says "npm/CI users:${TMPDIR:-/tmp}/".docs/concepts/worktree-isolation.md:252,255— still sayscat /tmp/claude-hook.log.What's genuinely good here
<esc>'' apt install(quote obfuscation) blocks,git push "origin" --forceblocks, newline-chained payloads block, and the unhandled backslash-escape case (--body "a\" && git push --force) fails closed. For a guard, the residual gaps erring toward blocking is the right direction.emit_segmentslimitations comment (:99-105) is honest — it states what it does not parse rather than overselling. That's exactly the intent-vs-effect discipline that's bitten us before.git reset(:263-266) shows the author noticed the guard is conditional — a subtler trap than it looks, and a clean-repo test would have passed vacuously.Meta: the bug validated itself 3× during this review
The old hook blocked three of my own QA commands — a probe script, an
awkbenchmark, and the AC-state update — purely because the text containedsudo/rm -rf /as data. I had to write each to a file andbashit. That's the false positive in this issue's "Severity framing" ("trains agents to route around the guard") happening in real time. Strong evidence the fix is worth landing once AC-5 is closed.Quality Metrics
any)Self-Evaluation
Verdict: AC_NOT_MET
AC-5 is PARTIALLY_MET → blocks per the standard algorithm. This is not a rejection of the approach: 9/10 ACs are met and the hard part (the splitter) is done and holds up under attack. The gap is confined to the log sink, and Findings 1+2 share a single root cause and a single ~6-line fix.
Next Steps
$CLAUDE_PROJECT_DIRsuggested) —pre-tool.shandpost-tool.sh, all three copies (AC-8 re-verify md5s).CLAUDE_PLUGIN_DATA-unset path asserting START+END share oneclaude-timing.log.docs/features/plugin-distribution.md:116-118anddocs/concepts/worktree-isolation.md:252,255.$( )/( )or document the accepted narrowing at:208-215./qa 763.QA performed inline against the real hook in the feature worktree; PR #771 @
69cc750.fix(#763): move hook logs out of the repo; cover every command-word p…
admarble commentedon Jul 16, 2026
QA Re-Review for Issue #763 (PR #771) — gaps fixed
Follow-up to the previous review. All four findings are closed at
57d44b7(merged withorigin/mainate038447). 10/10 ACs met.What changed
CLAUDE_PLUGIN_DATA/logs→HOME/.sequant/logs→$TMPDIR. Always absolute, always outside the repo.pre-tool.shandpost-tool.sh(all 3 copies each). START/END pair in one file again.mainemit_segmentsnow covers every position the shell executes, plus heredoc awareness.A defect worse than I first reported
While fixing Finding 1 I found the repo-local sink didn't just scatter directories — it silently disabled the no-changes guard:
The hook
mkdirs its log dir before the guard readsgit status --porcelain; the untracked dir made the tree look dirty, so the guard concluded there were changes. The hook's own side effect turned the hook's guard off — the same write-before-read ordering class as #760.This is also why the test harness comment at
:44-50existed: it noted the fallback "would break the no-changes guard's emptiness check for these bare test repos" and forcedCLAUDE_PLUGIN_DATAeverywhere to make tests pass. The symptom was seen and worked around rather than read as the bug it was pointing at. That comment is now corrected, and the fallback is exercised directly.AC-5c: a deliberate departure from the AC's wording
AC-5c suggested "a repo-local
.sequant/logs/fallback" — that suggestion is precisely what produced all three defects. The implementation instead uses$HOME/.sequant/logs, which meets AC-5c's stated requirement ("a single non-purged sink") more faithfully: one sink shared by the main repo and every worktree, and it can never touch a repo'sgit status. Flagging the deviation explicitly since it departs from the issue text.Finding 3: full command-word coverage + the heredoc trap
Now blocked (all verified through the real hook):
( sudo … ),echo $(sudo …),echo "$(sudo …)", nested"$( ( sudo … ) )", andgh pr create --body "$(cat .env)".Making
$( )live inside double quotes has a sharp edge I hit while prototyping: it also makes heredoc bodies live, andgit commit -m "$(cat <<'EOF' … EOF)"is this repo's standard idiom. Without heredoc skipping, a commit message that merely mentionsgit push --forcegets blocked — reintroducing the #564/#570 false-positive class through a new door. Your own CHANGELOG entry for #763 contains that exact string. Heredoc bodies are therefore skipped as the stdin data they are, and mutation-checked:xargs sudo …andbash -c "sudo …"remain allowed — an argument is not a command word, and matching it is the original #564/#570 mistake. Now locked in by tests so a future "tightening" has to be deliberate.Verification
4fd209d6…);dist/regenerated and matchingcc6a0099…)Self-Evaluation
CLAUDE_PLUGIN_DATA-unset branch that both defects shipped through now has direct coverage across all three copies.xargs,bash -c); backslash-escaped quotes (fails closed); in-workspace destruction (out of scope per the issue).Verdict: READY_FOR_MERGE
10/10 ACs met. The bypass class is dissolved rather than re-patched, the guard is now broader than the code it replaced instead of narrower, and the log sink can no longer sabotage the guard next to it.
Re-QA performed inline against the real hook; PR #771 @
e038447.