// 12 tips tagged "hooks"
The SessionStart hook fires when any session begins or resumes, making it ideal for loading environment variables and running one-time setup scripts.
A PreToolUse hook can intercept test runner commands and filter output to show only failures, cutting thousands of tokens from Claude's context.
Run Claude Code's initialization hooks and exit immediately, reusing your hook infrastructure for CI setup and environment preparation without starting a session.
Use prompt hooks to evaluate tool calls with an LLM instead of bash scripts, describing your safety policies in plain English rather than brittle regex patterns.
Send POST requests to external services on every tool call using HTTP hooks, with header authentication and the ability to block actions from a remote endpoint.
The PreToolUse hook fires before every tool call and supports blocking via exit code 2, letting you write custom scripts that intercept dangerous commands before Claude executes them.
Attach a FileChanged hook to your .envrc or .env file so Claude Code automatically reloads your environment variables the moment it edits them.
Add the Slack MCP server to let Claude post deployment updates, incident alerts, or standup summaries directly to your channels.
Configure a Stop hook to play a system sound the moment Claude finishes, so you can step away without constantly checking the terminal.
Ask Claude to set up lint-staged and Husky for your project — it handles the config, hook files, install commands, and the edge cases you'd otherwise debug for an hour.
You don't need a teammate to catch issues before committing — pipe your diff to Claude for a fast, targeted review.
Claude Code hooks let you run shell commands automatically before or after tool calls.