diff --git a/rust/crates/rusty-claude-cli/src/main.rs b/rust/crates/rusty-claude-cli/src/main.rs index 4015dd0..5f04c7b 100644 --- a/rust/crates/rusty-claude-cli/src/main.rs +++ b/rust/crates/rusty-claude-cli/src/main.rs @@ -1427,16 +1427,16 @@ fn run_worker_state(output_format: CliOutputFormat) -> Result<(), Box { - println!("No worker state file found at {}", state_path.display()) - } - CliOutputFormat::Json => println!( - "{}", - serde_json::json!({"error": "no_state_file", "path": state_path.display().to_string()}) - ), - } - return Ok(()); + // Emit a structured error, then return Err so the process exits 1. + // Callers (scripts, CI) need a non-zero exit to detect "no state" without + // parsing prose output. + // Let the error propagate to main() which will format it correctly + // (prose for text mode, JSON envelope for --output-format json). + return Err(format!( + "no worker state file found at {} — run a worker first", + state_path.display() + ) + .into()); } let raw = std::fs::read_to_string(&state_path)?; match output_format {