feature
Hooks
Small commands that fire automatically at set moments — like running your formatter every time Claude saves a file.
A hook is an action the tool runs *for* you at a specific point: before a command, after an edit, when a session starts. Use them to enforce a rule ("never let it touch the main branch"), keep things tidy ("format every file Claude edits"), or log activity. Set it once; it just happens.
A hook is a command the tool runs for you, automatically, at a specific moment in
the work. The moments are named: a PreToolUse hook fires before Claude runs a
command or edits a file; a PostToolUse hook fires after; others fire when a
session starts or ends. You pick the moment, you supply the command, and from then on
it just happens.
That gives you three useful jobs. Enforce a rule — a PreToolUse hook can inspect
what’s about to happen and block it (“never let it touch the main branch”), so the
guardrail is mechanical, not a thing you have to remember. Tidy — run your
formatter on every file Claude edits, and the diff is always clean. Log — record
what happened, for an audit trail or just peace of mind.
One rule of thumb keeps hooks pleasant: keep the command fast. Hooks run inline,
in the flow of the work, so a slow hook slows down every action it’s attached to. See
what you’ve got configured with /hooks. Where a scheduled agent
runs on the clock, a hook runs on an event — the “always do this, right when X
happens” chore you’d otherwise forget.
Generator
Build a settings.json
Pick permission rules and hooks, then copy out a settings.json for your .claude/ folder.
Permissions
allow run without asking
ask always confirm first
deny never, full stop
Hooks
{
"permissions": {
"allow": [
"Bash(npm run test:*)"
],
"deny": [
"Read(./.env)",
"Bash(rm -rf:*)"
]
},
"hooks": {
"PostToolUse": [
{
"matcher": "Edit|Write",
"hooks": [
{
"type": "command",
"command": "npx prettier --write ."
}
]
}
]
}
}
A starting point — copy it into your project and adapt.
why it helps Automate the 'always do this after' chores so you never forget them.
examples
After every edit, run `prettier --write` on the changed file. /hooks tips & best practices
- Hooks are for the 'always do this' chores — formatting, linting, logging — that you'd forget.
- Use a
PreToolUsehook to block risky actions (like touchingmain) before they happen. - Keep hook commands fast; they run inline, so a slow hook slows every action it's attached to.