⌨️PostToolUse Hook
Also known as PostToolUse, post tool use hook
The event right after a tool works. It is often used to tidy code.
Think of it like
It is like a teacher who checks your work. She does it as soon as you hand it in.
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.
Definition
Example code
json
{
"hooks": {
"PostToolUse": [
{ "matcher": "Edit|Write", "hooks": [{ "type": "command", "command": "npm run lint" }] }
]
}
}Common mistake
Key takeaways
- 1After success. Tool already ran.
- 2Format, lint, test. Common uses.
- 3Exit 2 tells Claude. Cannot undo.