Claude Code Hooks Guides
In-depth guides on Claude Code hooks: what they are, when to use PreToolUse vs PostToolUse, and how hooks compare to slash commands and prompt instructions.
What Are Claude Code Hooks? A Practical Guide
Claude Code hooks are commands that run automatically at lifecycle events. See the lifecycle, a complete working hook, and the settings.json that wires it up.
7 min readPreToolUse vs PostToolUse: Which Claude Code Hook to Use
PreToolUse runs before a tool and can block it; PostToolUse runs after and reacts. See two complete hooks, the differing stdin payloads, and a one-line rule.
7 min readClaude Code Hooks vs Slash Commands vs Prompt Instructions
Hooks, slash commands, and prompt instructions steer Claude Code at different levels. See a slash command vs a hook, how they differ from MCP, when to use each.
7 min readClaude Code Hooks Not Working? A Troubleshooting Guide
Claude Code hook not firing, output ignored, or breaking your session? Diagnose the common causes — bad matcher, invalid JSON, wrong exit code, paths — fix each.
8 min readWrite Your First Claude Code Hook in 5 Minutes
A step-by-step tutorial: create the hooks folder, write a Bash command logger, register it in settings.json, test it, and watch it run. No deps beyond Node.
6 min readClaude Code settings.json: The Complete Reference
A complete reference for Claude Code settings.json: where it lives, hooks and permissions blocks, settings.local.json precedence, env, and common mistakes.
8 min read10 Claude Code Hooks Worth Installing (With Examples)
A curated list of useful Claude Code hooks examples: block secrets and destructive commands, lint on save, run tests on stop, and inject conventions.
8 min readHow to Secure Claude Code with Hooks
Secure Claude Code with deterministic hooks: block destructive commands, prevent secrets leaking, protect .env, and guard the main branch every run.
8 min readAutomate Code Quality in Claude Code with Hooks
Automate code quality in Claude Code with hooks: run formatters, lint on write, typecheck after edits, and gate tests at stop. PostToolUse and Stop patterns.
8 min readInject Context into Claude Code with Hooks
Use UserPromptSubmit and SessionStart hooks to inject context into Claude Code — conventions, current date, and git state — on every prompt and at startup.
8 min readSEO & Accessibility Guardrails for Next.js with Hooks
Guarantee SEO metadata, heading hierarchy, next/image, and accessible JSX in your Next.js app with Claude Code hooks that enforce quality automatically.
8 min readIsolate Agent Work with Git Worktrees and Hooks
Isolate Claude Code agent work with git worktree hooks: auto-redirect from main, provision env files, guard against cross-repo edits, and clean up on removal.
8 min readClaude Code Hooks for Python (ruff, pytest, pyright)
Claude Code hooks for Python: run ruff, pyright, and pytest via uv — no virtualenv activation. Each tool fires on every file write and at session end.
8 min readOpenAI Codex Hooks: Setup, Config, and Examples
OpenAI Codex hooks run commands at lifecycle events, just like Claude Code. See the .codex/hooks.json format, how it differs from Claude Code, and a working hook you can install in one command.
6 min read