Summary
Add a new example policy file demonstrating a non-trivial Stop hook: the user's chat/task finishes, Claude triggers a stop, and the hook actively enforces it (e.g. blocks the stop, logs it, or takes a side-effect action).
Motivation
Current examples cover Notification and SessionEnd but there is no example showing how to intercept and act on a Stop event. A real-world scenario — "task is done, stop fires, and the hook actually did something meaningful with it" — would help users understand:
- How to detect that a session is stopping vs just idling
- How to run cleanup / finalization logic before exit
- How to conditionally block or allow the stop (e.g. require confirmation, flush a queue, post a summary)
Proposed example
New file: examples/policies-stop.js
Scenario: when Claude finishes a task and emits a Stop event, the hook:
- Posts a task-complete summary somewhere (Slack, file, etc.)
- Optionally blocks the stop if some condition isn't met (e.g. uncommitted changes detected)
- Returns
allow() or deny() with a human-readable reason
Acceptance criteria
Summary
Add a new example policy file demonstrating a non-trivial
Stophook: the user's chat/task finishes, Claude triggers a stop, and the hook actively enforces it (e.g. blocks the stop, logs it, or takes a side-effect action).Motivation
Current examples cover
NotificationandSessionEndbut there is no example showing how to intercept and act on aStopevent. A real-world scenario — "task is done, stop fires, and the hook actually did something meaningful with it" — would help users understand:Proposed example
New file:
examples/policies-stop.jsScenario: when Claude finishes a task and emits a
Stopevent, the hook:allow()ordeny()with a human-readable reasonAcceptance criteria
examples/policies-stop.jsexists and is runnable withfailproofai p -i -c