fix(claude-code): narrow PostToolUse hook matcher from .* to Bash|Write|Edit|MultiEdit (sable-h0ah) - #183
Merged
Conversation
…te|Edit|MultiEdit rafter agent init --with-claude-code (and agent enable claude-code.hooks) registered the `rafter hook posttool` redaction hook with a catch-all `.*` matcher, so it fired after EVERY Claude Code tool call — including Read and MCP tools, which never produce secrets to redact — adding latency to every operation. Narrow the matcher to the tools whose output is worth scanning: shell output (Bash) and file writes (Write/Edit/MultiEdit). Changed in both install paths per language (init/legacy + component spec), keeping Node and Python identical. PreToolUse matchers are unchanged. Scope is Claude Code only. Codex (.* PostToolUse) and Gemini (.* AfterTool) have the same broad-matcher latency issue and are tracked separately in sable-4alt for platform-correct narrow matchers. Docs (SKILL.md, PLATFORM_PARITY_AUDIT.md, CHANGELOG) and test expectations updated; a PostToolUse-matcher assertion added to the Python install test to mirror the Node coverage. Closes sable-h0ah Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Merged
Rome-1
added a commit
that referenced
this pull request
Jun 28, 2026
Patch release bundling the unreleased changes on main since 0.8.9: - Claude Code PostToolUse matcher narrowed .* -> Bash|Write|Edit|MultiEdit (#183) - Hooks tolerate harness-appended flags, e.g. --hook-json (#180) - Dependency CVE re-lock (axios, hono, tar, js-yaml, +transitives) and remote-skill tarball extraction hardening (#184) Bumps node/package.json + python/pyproject.toml to 0.8.10 (parity), the rafter-security skill resource version (node + python), and finalizes the CHANGELOG 0.8.10 section. Refs sable-ehb1 Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
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.
Problem
rafter agent init --with-claude-code(andrafter agent enable claude-code.hooks) registered therafter hook posttoolsecret-redaction hook with a catch-all.*matcher. That firesrafter hook posttoolafter every Claude Code tool call — includingReadand MCP tools, which never produce secrets to redact — adding latency to every operation for every rafter-cli user.posttoolwas designed for shell output + file writes.Fix
Narrow the Claude Code
PostToolUsematcher from.*toBash|Write|Edit|MultiEdit— the tools whose output is actually worth scanning (shell output + file writes).PreToolUsematchers (Bash,Write|Edit) are unchanged.Changed in both install paths per language for parity:
src/commands/agent/init.ts(init/legacy) +src/commands/agent/components.ts(component spec)rafter_cli/commands/agent.py(legacy) +rafter_cli/commands/agent_components.py(component spec)Docs (
SKILL.md,shared-docs/PLATFORM_PARITY_AUDIT.md,CHANGELOG.md) and test expectations updated. APostToolUse-matcher assertion was added to the Python install test to mirror existing Node coverage.Scope
Claude Code only. Codex (
.*PostToolUse) and Gemini (.*AfterTool) have the same broad-matcher latency issue but need platform-correct tool names (CodexBash|apply_patch, Geminirun_shell_command|write_file|replace|edit) — tracked separately in sable-4alt, not touched here.Security review
This is rafter's own install path, so it went through
rafter-code-review:.*.Read/MCP outputs — a reduction in defense-in-depth breadth. Acceptable because the actual security control (PreToolUse command interception) is untouched, and redaction still covers the highest-value channels (shell output + file writes). If MCP-output redaction is later wanted, it should return as a targeted matcher, never.*.rafter secrets .is clean for this diff (the 106 repo hits are intentional test fixtures). Remoterafter run(SAST/SCA) was not run here —RAFTER_API_KEYis unset in this environment; please let CI / the merger run it.Testing
agent-compatibility,platform-integration): 132 passed.test_agent_init,test_agent_components,test_suppression): 112 passed.tsc): clean. Ruff: zero new errors from this diff.git stash— they fail without this diff too), tracked in sable-6udz: a Node AuditLogger test (error-handling-gauntlet.test.ts) and a Python version-match test that invokes a stale globalrafterbinary.Closes sable-h0ah.
🤖 Generated with Claude Code