Back to articles
39 Claude Code Hooks That Run Automatically: The Complete Pattern Library
How-ToTools

39 Claude Code Hooks That Run Automatically: The Complete Pattern Library

via Dev.toWEDGE Method Dev

Claude Code hooks are scripts that execute automatically when specific events occur - before or after tool calls, on notifications, or when the session starts. I've built 39 hooks that automate my entire development workflow. Here are 10 of the most impactful patterns. How Hooks Work Hooks fire on three event types: PreToolUse - Before Claude executes a tool (edit, bash, write) PostToolUse - After a tool completes Notification - When Claude sends a notification Configure in .claude/settings.json : { "hooks" : { "PreToolUse" : [ { "matcher" : "Edit" , "command" : "bash .claude/hooks/lint-check.sh" } ] } } Hook 1: Auto-Lint on Every Edit #!/bin/bash # .claude/hooks/lint-check.sh # Runs ESLint on any file being edited FILE = $( echo " $CLAUDE_TOOL_INPUT " | jq -r '.file_path // empty' ) if [[ " $FILE " == * .ts || " $FILE " == * .tsx ]] ; then npx eslint " $FILE " --fix 2>/dev/null fi Hook 2: Secret Scanner #!/bin/bash # Blocks any edit that would introduce a secret INPUT = $( echo " $CLA

Continue reading on Dev.to

Opens in a new tab

Read Full Article
2 views

Related Articles