Skip to content
CCCA Prep
← All lessons
Claude Code~16 min

Hooks and the settings.json Event Model

Wire deterministic, harness-run hooks to lifecycle events, read their stdin JSON, and control behavior with exit codes and matchers.

What you will be able to do

  • Map common hook events (PreToolUse, PostToolUse, UserPromptSubmit, Stop, PreCompact) to the right use case
  • Explain how a hook receives event data (JSON on stdin) and how exit code 2 blocks with feedback to Claude
  • Choose the correct event-plus-matcher pair for auto-formatting and pre-tool guardrails
  • Configure a hook in settings.json with the proper event/matcher structure
3 concepts·5 hands-on exercises·3-question check