Skip to content
PluginStats

cc-hooks-ts weekly downloads statistics

By sushichan044 · npm · Claude Code

Write claude code hooks with type safety

View on npm Fresh · Oct 27, 2026 · data Oct 22, 2026

cc-hooks-ts has 1,404 recorded weekly downloads on npm.

Weekly downloads
1,404
Official API · Oct 22, 2026
7-day growth
—
Insufficient history
30-day growth
—
Insufficient history
90-day growth
—
Insufficient history
Rank
—
Among tracked npm listings

About cc-hooks-ts

cc-hooks-ts

Define Claude Code hooks with full type safety using TypeScript.

See examples for more usage examples.

<!-- TOC --> <!-- /TOC -->

[!NOTE] Starting with versions 2.0.42, we will raise our version number to match Claude Code whenever Hook-related changes occur.

This ensures we can adopt newer type definitions while maintaining compatibility.

Installation

# npm
npm i cc-hooks-ts

# yarn
yarn add cc-hooks-ts

# pnpm
pnpm add cc-hooks-ts

# Bun
bun add cc-hooks-ts

# Deno
deno add npm:cc-hooks-ts

Basic Usage

Define a Hook
import { defineHook } from "cc-hooks-ts";

const hook = defineHook({
  // Specify the event(s) that trigger this hook.
  trigger: {
    SessionStart: true,
  },
  // Implement what you want to do.
  run: (context) => {
    // Do something great here
    return context.success({
      messageForUser: "Welcome to your coding session!",
    });
  },
});

// import.meta.main is available in Node.js 24.2+ and Bun and Deno
if (import.meta.main) {
  const { runHook } = await import("cc-hooks-ts");
  await runHook(hook);
}
Configure Claude Code

Then, load defined hooks in your Claude Code settings at ~/.claude/settings.json.

{
  "hooks": {
    "SessionStart": [
      {
        "hooks": [
          {
            "type": "command",
            "command": "bun run -i --silent path/to/your/sessionHook.ts"
          }
        ]
      }
    ]
  }
}

Tool Specific Hooks

In PreToolUse, PostToolUse, PostToolUseFailure, PermissionRequest, and PermissionDenied events, you can define hooks specific to tools by specifying tool names in the trigger configuration.

For example, you can create a hook that only runs before the Read tool is used:

const preReadHook = defineHook({
  trigger: { PreToolUse: { Read: true } },
  run: (context) => {
    // context.input.tool_input is typed as { file_path: string; limit?: number; offset?: number; }
    const { file_path } = context.input.tool_input;

    if (file_path.includes(".env")) {
      return context.blockingError("Cannot read environment files");
    }

    return context.success();
  },
});

if (import.meta.main) {
  const { runHook } = await import("cc-hooks-ts");
  await runHook(preReadHook);
}

Then configure it in Claude Code settings:

{
  "hooks": {
    "PreToolUse": [
      {
        "matcher": "Read",
        "hooks": [
          {
            "type": "command",
            "command": "bun run -i --silent path/to/your/preReadHook.ts"
          }
        ]
      }
    ]
  }
}

The same trigger shape also works for permission hooks:

const permissionRequestHook = defineHook({
  trigger: { PermissionRequest: { Bash: true } },
  run: (context) => {
    // context.input.tool_input is typed as BashInput
    const { command } = context.input.tool_input;

    if (command.includes("rm -rf")) {
      return context.blockingError("Refusing destructive command");
    }

    return context.success();
  },
});
Custom Tool Types Support

You can add support for custom tools by extending the tool type definitions.

This is useful when you want to your MCP-defined tools to have type-safe hook inputs.

import { defineHook } from "cc-hooks-ts";

// Example: type-safe hooks for DeepWiki MCP Server tools
declare module "cc-hooks-ts" {
  interface ToolSchema {
    mcp__deepwiki__ask_question: {
      input: {
        question: string;
        repoName: string;
      };
      response: unknown;
    };
  }
}

const deepWikiHook = defineHook({
  trigger: { PreToolUse: { mcp__deepwiki__ask_question: true } },
  run: (context) => {
    // context.input.tool_input is typed as { question: string; repoName: string; }
    const { question, repoName } = context.input.tool_input;

    if (question.length > 500) {
      return context.blockingError("Question is too long");
    }

    return context.success();
  },
});

Advanced Usage

Conditional Hook Execution

You can conditionally execute hooks based on runtime logic using the shouldRun function. If shouldRun returns false, the hook will be skipped.

import { defineHook } from "cc-hooks-ts";

const hook = defineHook({
  trigger: {
    Notification: true,
  },
  // Only run this hook on macOS
  shouldRun: () => process.platform === "darwin",
  run: (context) => {
    // Some macOS-specific logic like sending a notification using AppleScript
    return context.success();
  },
});
Advanced JSON Output

Use context.json() to return structured JSON output with advanced control over hook behavior.

For detailed information about available JSON fields and their behavior, see the official documentation.

Async JSON Output (Experimental)

[!WARNING] This behavior is undocumented by Anthropic and may change.…

Description from the npm listing.

  • anthropic
  • claude
  • claude-code
  • hooks
  • type-safety
  • typescript

README badge

Show your rank in a README or on your website. The badge updates automatically.

Charts

Images: 30d · 1y · all time · 1600×900 dark

Adoption over time

cc-hooks-ts weekly downloads on npm, last 90 days: 1,404 weekly downloads as of Oct 22, 2026.cc-hooks-tsWeekly downloads on npm · Last 90 days1,404downloads / week1.3K1.3K1.4K1.4K1.5K1.5K1.6KJul 24Aug 8Aug 23Sep 7Sep 22Oct 7Oct 22downloads / weekOct 22, 2026 – Oct 22, 2026 · 1 observations · Updated Oct 22, 2026pluginstats.com
cc-hooks-ts weekly downloads on npm, last 90 days: 1,404 weekly downloads as of Oct 22, 2026.

7/30/90-day growth

cc-hooks-ts weekly downloads growth on npm: 7-day growth unavailable, 30-day growth unavailable, 90-day growth unavailable.cc-hooks-tsWeekly downloads growth on npm1,404downloads / week now7-day growthinsufficient historyInsufficient history30-day growthinsufficient historyInsufficient history90-day growthinsufficient historyInsufficient historyGrowth vs. nearest observation to each baseline date · Updated Oct 22, 2026pluginstats.com
cc-hooks-ts weekly downloads growth on npm: 7-day growth unavailable, 30-day growth unavailable, 90-day growth unavailable.

Ranking history

cc-hooks-ts has no ranking history on npm yet.cc-hooks-tsnpm ranking · by weekly downloads · Last 90 daysNo ranking observations in this periodno observations · 0 observations · Updated Oct 22, 2026pluginstats.com
cc-hooks-ts has no ranking history on npm yet.

Listing placement

All npm2,577 listings · 129 pages · 1,290 shown · page 78, #10 (overall #1,550)
All npm: every listing in weekly downloads order

Listing placement

Claude Code351 listings · 18 pages · page 11, #17 (overall #217)
Claude Code: every listing in weekly downloads order

Filled points are observed values; hollow points come from Internet Archive snapshots of the listing page. Dashed segments span periods with no observations — values between points are not interpolated.

Each band is one page of 20. Weekly downloads on a linear scale. Placement is projected from weekly downloads, so it can differ from the marketplace's own sort order. Hover a dot to see the listing.

Recent observations

Full history (2)
Recent weekly downloads observations for cc-hooks-ts
Date (UTC)Weekly downloadsChange vs. previous
1,404-2.4K
3,789—

Similar npm Claude Code plugins

All 20 cc-hooks-ts alternatives

Data source

Weekly downloads (trailing 7 complete days) come from the official npm downloads API. Downloads include CI and mirrors and are not equivalent to installs or users. npm publishes no ratings.

Listing: https://www.npmjs.com/package/cc-hooks-ts. First seen Oct 26, 2026; last successful collection Oct 27, 2026. See the methodology.