Config Generator

Claude Code Hooks Generator

Choose a lifecycle template, adjust the event, matcher, command, and timeout, then copy a Claude Code hooks settings JSON block.

Last updated: July 26, 2026

.claude/settings.json
{
  "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, approvals, and guardrails that should run at a known point in Claude Code's workflow.

Best Starter Templates

Start with one visible hook: lint after Edit, MultiEdit, or Write; block reads of secret-looking files with a PreToolUse guard; notify when Claude Code asks for permission; or print git status when a turn stops. Keep every command easy to run manually.

Official Claude Code Reference

Anthropic's Claude Code hooks reference documents lifecycle events, settings JSON, input and output formats, exit codes, async hooks, HTTP hooks, prompt hooks, MCP tool hooks, and security considerations.

Matcher And Command Rules

Use matchers to narrow hook scope to the tool or event that matters. A PostToolUse lint hook should usually target edit tools, while a PreToolUse guard should inspect tool input and return a clear decision instead of hiding policy in a vague shell command.

Common Mistakes

Avoid broad matchers, destructive commands, long-running tests on every tool call, hidden network calls, local-only absolute paths, 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.