Claude Code
Today
Explore
Practice
Library
Exam
Certificate
Search
⌘K
ខ្មែរ
◐
Sign in
Today
Explore
Practice
Library
Profile
Hooks and Guarantees
Today
4. Optional: Extensions · 3 of 4
Mark read
Prev
Next
Orient
Event, matcher, exit code
Turn a prose rule into a guarantee
Predict
Write one hook and prove it fires
Close
Practice
Related
Hooks and Guarantees
Advanced
☆
📑
The only layer that runs whether the model agrees or not
Orient
Event, matcher, exit code
Turn a prose rule into a guarantee
Predict
Write one hook and prove it fires
Close
Practice
Related
Practice activities and scenarios are optional. Mark the lesson complete after reading, and return to practice whenever it helps.
Restoring your saved work…
07
Optional practice
🧠 Optional scenario practice
Q1
A hook script exits with code 2 during PreToolUse. What happens?
A
The tool call proceeds and the error is logged in the transcript
B
The action is blocked and stderr is sent to Claude
C
Claude Code restarts the session
D
Stdout is parsed as JSON and used as the tool result
Q2
Your PreToolUse hook returns permissionDecision "allow", but a deny rule matches the same call. What is the outcome?
A
The hook wins because it is more specific
B
The call is blocked — hook decisions cannot override deny or ask rules
C
The user is prompted to break the tie
D
The call proceeds but is logged as a policy violation
08
Up Next
Intermediate
MCP Without the Sprawl
Advanced
Subagents and Context Isolation
Advanced
Designing a Custom Subagent
📝 Notes
Mark lesson complete
Next: MCP Without the Sprawl →