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.
The Hook Lifecycle: Events You Can Tap Into
A tour of every hook event Claude Code fires, from tool calls to session start, so you know where to attach your automation.
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.
Hook Matchers and the if Condition
Matchers decide which tool triggers a hook; learn the patterns and how to add your own conditions inside the command.