cc-hooks-ts

Implement type-safe Claude Code hooks in TypeScript with defineHook and runHook.

2|1|Updated Oct 29, 2025
One-click install
npx skills add https://github.com/masseater/claude-code-plugin --skill cc-hooks-ts
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: cc-hooks-ts
Source: https://github.com/masseater/claude-code-plugin/tree/main/plugins/mutils/skills/cc-hooks-ts
Command: npx skills add https://github.com/masseater/claude-code-plugin --skill cc-hooks-ts

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill provides a comprehensive guide and examples for creating type-safe Claude Code hooks using the cc-hooks-ts library. It helps you implement event-driven hooks (PreToolUse/PostToolUse/SessionStart, etc.) in TypeScript, enabling deterministic automation in Claude Code projects and reducing boilerplate across tool integrations.

Core Features & Use Cases

  • Type-safe hook implementation: Use TypeScript to define hooks with compile-time safety.
  • Event-driven automation: Hook into PostToolUse, PreToolUse, SessionStart, and more to automate checks, logging, and policy enforcement.
  • Practical examples: Includes full code snippets showing installation, a basic hook, and real-world scenarios.
  • Plugin.json integration: Learn how to wire hooks into Claude Code plugin.json.

Quick Start

Install: bun add cc-hooks-ts. Create a hook.ts that uses defineHook from "cc-hooks-ts" and run it with bun run -i --silent path-to-your-hook.ts.

Frequently Asked Questions about cc-hooks-ts

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I create type-safe hooks in TypeScript for Claude Code?

Type-safe Claude Code hooks use the cc-hooks-ts library with TypeScript to define hooks via defineHook, providing compile-time safety. Install with bun add cc-hooks-ts, create a hook.ts file using defineHook, and run it with bun. This eliminates boilerplate and catches errors at compile time rather than runtime.

What are PreToolUse and PostToolUse hooks, and when should I use them?

PreToolUse and PostToolUse are event-driven hooks that trigger before and after tool execution. Use them to automate policy checks, logging, validation, or transformations on tool inputs and outputs without modifying tool code itself.

How do I configure hooks in plugin.json for Claude Code?

Wire hooks into Claude Code by defining hook entries in plugin.json with trigger type, handler path, and schema. The cc-hooks-ts guide includes plugin.json configuration examples showing how to register PreToolUse, PostToolUse, and SessionStart hooks with proper context methods.

Can I use event-driven hooks to automate policy enforcement across multiple tools?

Yes. SessionStart, PreToolUse, and PostToolUse hooks let you enforce policies deterministically across tool integrations. Define rules once in a single hook and apply them to all tools without duplicating logic in each integration.

What context methods are available inside a Claude Code hook?

Hooks expose context methods including success for normal completion, blockingError to halt execution with an error, and json for structured logging. These methods control hook behavior and enable deterministic automation patterns.

Do I need prior TypeScript experience to write Claude Code hooks?

Basic TypeScript familiarity helps, but cc-hooks-ts provides practical examples and full code snippets covering installation, basic hooks, and real-world scenarios. The defineHook API and trigger schemas are straightforward to follow.