Stop API

August 29, 2025 ยท View on GitHub

Available when inheriting from ClaudeHooks::Stop:

Input Helpers

Input helpers to access the data provided by Claude Code through STDIN.

๐Ÿ“š Shared input helpers

MethodDescription
stop_hook_activeCheck if Claude Code is already continuing as a result of a stop hook

Hook State Helpers

Hook state methods are helpers to modify the hook's internal state (output_data) before yielding back to Claude Code.

๐Ÿ“š Shared hook state methods

Note

In Stop hooks, the decision to "block" actually means to "force Claude to continue", we are "blocking" the blockage. This is counterintuitive and the reason why the method block! is aliased to continue_with_instructions!

MethodDescription
continue_with_instructions!(instructions)Block Claude from stopping and provide instructions to continue
block!(instructions)Alias for continue_with_instructions!
ensure_stopping!Allow Claude to stop normally (default behavior)

Output Helpers

Output helpers provide access to the hook's output data and helper methods for working with the output state.

๐Ÿ“š Shared output helpers

MethodDescription
output.should_continue?Check if Claude should be forced to continue (decision == 'block')
output.should_stop?Check if Claude should stop normally (decision != 'block')
output.continue_instructionsGet the continue instructions (alias for reason)
output.reasonGet the reason for the decision

Hook Exit Codes

Exit CodeBehavior
exit 0Agent will stop
STDOUT shown to user in transcript mode
exit 1Non-blocking error
STDERR shown to user
exit 2Blocks stoppage
STDERR shown to Claude