rusty-hooks
A PostToolUse validation hook for Claude Code that blocks Edit and Write
operations when the on-disk file content diverges from what the tool reported writing.
What it does
Claude Code supports hooks — shell commands that run before or after tool calls. rusty-hooks installs as
a PostToolUse hook and validates every Edit and Write by reading the file back from disk and comparing
it to the content the tool claimed to write. If they differ, the hook emits a block decision with a reason,
preventing the divergence from being silently accepted.
Installation
Then add to your Claude Code settings (~/.claude/settings.json):
How it works
The hook reads a JSON payload from stdin (the Claude Code hook protocol), extracts the tool_name and
tool_input, and for Edit/Write calls reads the target file from disk. If the on-disk content does not
match tool_input.content, it exits with code 2 and emits:
A successful validation exits with code 0 and no output.
License
MIT