Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions cch_cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,20 @@ async fn process_hook_event(cli: &Cli, _config: &config::Config) -> Result<()> {
let debug_config = models::DebugConfig::new(cli.debug_logs, project_config.settings.debug_logs);
let response = hooks::process_event(event, &debug_config).await?;

if !response.continue_ {
// Claude Code hooks protocol: exit code 2 BLOCKS the tool call.
// Only stderr is used as the error message and fed back to Claude.
// Exit code 0 with "continue":false only stops the conversation,
// it does NOT prevent the tool from executing.
let reason = response
.reason
.as_deref()
.unwrap_or("Blocked by CCH policy");
eprintln!("{}", reason);
std::process::exit(2);
}

// For allowed responses (with or without context injection), output JSON to stdout
let json = serde_json::to_string(&response)?;
println!("{}", json);

Expand Down
Loading