Notes on building software.
A personal blog of technical articles about software development.
What Hooks Are and Why They're Deterministic
Hooks are shell commands Claude Code runs at set points in a session, giving you rules that always fire instead of hoping the model remembers.
Your First PreToolUse Hook
Build a simple PreToolUse hook that logs every Bash command Claude is about to run, and learn how event data arrives on stdin.
Formatting Code Automatically with a PostToolUse Hook
Wire up a PostToolUse hook so every file Claude edits gets formatted right away, keeping your diffs clean without asking.
Blocking Dangerous Commands with Hooks
Use a PreToolUse hook and exit code 2 to stop Claude from running commands you never want it to touch.
Controlling Claude with Hook Exit Codes and JSON
Exit codes give hooks blunt control; JSON on stdout gives them structured decisions like denying a tool call with a reason.
Notifying Yourself with Notification Hooks
A Notification hook can send a desktop alert or sound when Claude needs your attention, so you can step away and still stay in the loop.