Expand description
mushroomdb impact-hook — the optional PreToolUse hook body for edits.
Claude Code runs this before an Edit, a Write or a MultiEdit, handing
it the tool call as JSON on stdin. The file about to change has a blast
radius the graph already knows — what imports it, what usually changes with
it, which tests cover it — and that is exactly the thing an assistant
otherwise finds out by reading half the repository, or does not find out at
all. So the hook says it, in one line, before the edit lands.
§Why it never blocks
Unlike crate::intercept, this hook has no opinion about whether the
edit should happen: it exits 0 always, and the only thing it can do is put
a sentence in front of the change. That is what makes the budget the real
constraint rather than the accuracy — a wrong redirect costs a tool call, a
wrong line of context costs MAX_CONTEXT_BYTES bytes of attention.
Every failure is silence: a payload that will not parse, a store that is
missing or busy, a path the graph has no File for. Silence here means the
edit proceeds exactly as it would with no hook installed.
Constants§
- MAX_
CONTEXT_ BYTES - The most this hook may add to a turn. It fires before every edit, so the line has to be worth reading at a glance and cheap enough to pay for on a long editing session; past this it stops being a nudge and becomes something to skim past.
Functions§
- run
- The whole hook body: parse the payload, open the store, render the radius.