Hooks (Claude Code)

Claude Code

Definition

Shell scripts or commands configured in .claude/settings.json that run at defined lifecycle points: PreToolUse (before tool execution), PostToolUse (after tool execution), Stop (before ending), SubagentStop (when subagent finishes). Used for code quality gates, notifications, logging, and safety checks.

Example Usage

Configure a PostToolUse hook to run 'npm test' automatically after every file edit, giving Claude immediate feedback on whether changes broke tests.