
5 Claude Code hooks I use on every project
Claude Code hooks let you run scripts at key points in the agent's lifecycle: before tool use, after tool use, on stop, on error. Here are the 5 I reach for on every project. What hooks actually do Hooks are shell scripts (or any executable) that Claude Code calls at lifecycle events. They can: Block an action (non-zero exit code stops the tool call) Log what happened Run side effects (format code, send a notification) Inject context back into the agent They live in .claude/settings.json under the hooks key. Hook 1: Read before Edit enforcer { "PreToolUse" : [{ "matcher" : "Edit|Write" , "hooks" : [{ "type" : "command" , "command" : "bash .claude/hooks/read-before-edit.sh" }] }] } #!/bin/bash # read-before-edit.sh # Warn if Edit is called without a recent Read of the same file echo "[hook] Make sure you've read this file before editing" exit 0 # advisory only — doesn't block Simple advisory hook. Reminds the agent to check current state. You can make it blocking for stricter enforcemen
Continue reading on Dev.to Tutorial
Opens in a new tab




