⌨️Hook Matcher
Also known as matcher
The field that picks which tools or events a hook runs on.
Think of it like
It is like a sign on a door. It says who may come in.
Example
Jack wrote Edit.* to match edits. His hook also ran on NotebookEdit. He changes it to ^Edit$ and it stops.
Why it matters
It is the main way to keep a hook from running on everything.
Definition
Example code
json
{
"hooks": {
"PostToolUse": [
{ "matcher": "Edit|Write", "hooks": [{ "type": "command", "command": "npm run lint" }] }
]
}
}Common mistake
Key takeaways
- 1Empty matches all. Or a star.
- 2Plain is exact. Edit|Write.
- 3Else a pattern. Part match.