Learn · Permissions, hooks & security · CCAR-F

Hooks: events, matchers and exit codes

Hooks are handlers Claude Code runs at lifecycle events. Learn the events, matcher syntax, the stdin JSON and what exit code 2 does.

Key ideas

Worked example: Load today's tickets at session start

On SessionStart, plain text a command hook prints to stdout with exit 0 is added to Claude's context, so the session starts with the open tickets already known.

Exam traps

Official docs

Practise CCAR-F questions · Next lesson: Prompt injection and sandboxing