Skip to content
BENIBIX Learn

FileChanged vs PostToolUse

People think a PostToolUse hook on Edit sees every change made to a file in the project. It sees only Claude's own tool calls. A script Claude runs, or your own editor, can change the file and it never fires. FileChanged watches the file itself, so it fires whatever wrote it. But only PostToolUse knows which tool call did it.

AI⌨️ Claude Code

FileChanged Hook

The event when a watched file changes, no matter what changed it.

FileChanged is the hook event that fires when a watched file changes on disk. It does not care what changed it: an edit by Claude, a script, or another program. The matcher lists the file names to watch, split by |, such as .envrc|.env. These are plain names in the working folder, not patterns. It runs after the change and cannot block it.

Example
Jack edits .env in his own editor while Claude works. His FileChanged hook reloads it, so Claude's next command sees the new value.
Why it matters
A hook that matches Edit or Write misses changes made by a script. This one sees them all.
Full entry
AI⌨️ Claude Code

PostToolUse Hook

The event right after a tool works. It is often used to tidy code.

PostToolUse is the hook event that fires right after a tool call works. It is the usual place to tidy code, lint it or run a quick test after Claude edits a file. The tool has already run, so the hook cannot undo it. It can send Claude a note to act on. It does that by exiting 2, or with a block decision and a reason.

Example
After each edit, Emma's hook runs the linter. When it finds an error, Claude sees the message and fixes it at once.
Why it matters
It catches mistakes the moment they are made, while Claude still has the file in mind.
Full entry

In one line

FileChanged Hook
The event when a watched file changes, no matter what changed it.
PostToolUse Hook
The event right after a tool works. It is often used to tidy code.