Release v0.3.0 - Strongly-Typed Hooks & Production-Grade Quality banner
ZhangHanDong ZhangHanDong

Release v0.3.0 - Strongly-Typed Hooks & Production-Grade Quality

Development community intermediate

Description

**Release Date**: 2025-10-21 **Type**: Major Release (Breaking Changes) **Status**: ✅ Ready for Release ---

Installation

Terminal
claude install-skill https://github.com/ZhangHanDong/claude-code-api-rs

README

Release v0.3.0 - Strongly-Typed Hooks & Production-Grade Quality

**Release Date**: 2025-10-21 **Type**: Major Release (Breaking Changes) **Status**: ✅ Ready for Release


🎯 Overview

Version 0.3.0 is a **major release** that introduces a complete strongly-typed hooks system, eliminates all compiler warnings, and achieves production-grade code quality through modern Rust patterns.

Key Highlights

    undefined

⚠️ Breaking Changes

HookCallback Trait Signature Change

**This is a breaking change that requires code updates.**

Before (v0.2.0)

#[async_trait]
impl HookCallback for MyHook {
    async fn execute(
        &self,
        input: &serde_json::Value,  // Untyped JSON
        tool_use_id: Option<&str>,
        context: &HookContext,
    ) -> Result {  // Untyped JSON
        // Manual JSON parsing required
        let tool_name = input.get("tool_name")
            .and_then(|v| v.as_str())
            .unwrap_or("");
        
        Ok(serde_json::json!({
            "continue": true
        }))
    }
}

After (v0.3.0)

use cc_sdk::{HookInput, HookJSONOutput, SyncHookJSONOutput};

#[async_trait]
impl HookCallback for MyHook {
    async fn execute(
        &self,
        input: &HookInput,  // Strongly typed enum
        tool_use_id: Option<&str>,
        context: &HookContext,
    ) -> Result {  // Strongly typed output
        match input {
            HookInput::PreToolUse(pre_tool_use) => {
                // Type-safe field access
                println!("Tool: {}", pre_tool_use.tool_name);

                Ok(HookJSONOutput::Sync(SyncHookJSONOutput {
                    continue_: Some(true),  // Field name conversion handled
                    ..Default::default()
                }))
            }
            _ => Ok(HookJSONOutput::Sync(SyncHookJSONOutput::default()))
        }
    }
}

Hook Event Names Must Be PascalCase

**Critical**: The Claude CLI only recognizes PascalCase event names.

// ❌ Wrong - Will not work
hooks.insert("pre_tool_use".to_string(), vec![...]);

// ✅ Correct
hooks.insert("PreToolUse".to_string(), vec![...]);

**All Valid Event Names**:

    undefined

See [`docs/HOOK_EVENT_NAMES.md`](docs/HOOK_EVENT_NAMES.md) for complete reference.


✨ New Features

Strongly-Typed Hook Input Types

pub enum HookInput {
    #[serde(rename = "PreToolUse")]
    PreToolUse(PreToolUseHookInpu