{
"hooks": {
"PostToolUse": [
{
"matcher": "Edit|MultiEdit|Write",
"hooks": [
{
"type": "command",
"command": "npm run lint",
"timeout": 120
}
]
}
]
}
}
Use the Claude Code Hooks Generator to create a focused settings JSON block for lifecycle automation. Hooks are a good fit for deterministic checks, notifications, and guardrails that should run at a known point in Claude Code's workflow.
What To Generate First
Start with one fast hook such as PostToolUse linting for edited files, a Notification hook for attention prompts, or a PreToolUse guard for protected commands. Keep the command easy to run manually.
Official Claude Code Reference
Anthropic's Claude Code docs describe hook events, settings JSON, input and output formats, timeouts, async hooks, and security considerations.
Common Mistakes
Avoid broad matchers, destructive commands, long-running tests on every tool call, hidden network calls, and settings JSON that is shared before permissions are reviewed.
FAQ
Where do Claude Code hooks live?
Hooks are configured in Claude Code settings JSON, commonly user, project, local, or managed settings depending on the scope.
Should hooks run tests automatically?
Use fast, targeted checks first. Long test suites are often better as explicit commands or release gates.
Can hooks block risky actions?
Yes, hook configuration can be used for guardrails, but keep the behavior visible and documented for the team.