karanb192/claude-code-hooks

🪝 Claude Code hooks + an installable plugin marketplace: safety, cost, observability, productivity.

Overview

claude-code-hooks is a collection of ready‑to‑use hooks that plug into Claude Code, Anthropic‑based AI‑assistant software that can run shell commands, edit files … and even install packages — all autonomously. The hooks act as safety‑guards and automation helpers that intercept the agent’s actions before or after they happen, allowing you to block, modify, or log them. The project ships a marketplace of 22 individual plugins that you can install with a single Claude Code command.

What the project provides

Feature What it does How you use it
Safety guards Blocks dangerous commands (rm -rf ~, `curl sh`), prevents secret‑file reads, enforces git‑branch rules, stops test‑hiding tricks, protects the agent’s own configuration, limits sub‑agent spawning, etc.
Logging & audit Session‑level markdown logs, stand‑up auto‑generation, personal flight‑recorder of failures, compliance scorecards, per‑file “context‑cost” leaderboards. Install a logger plugin such as session-logger and view the generated markdown or command‑line cards.
Automation helpers Auto‑stage edited files, auto‑format code after edits, stamp provenance info into PR bodies, turn repo TODOs into bounty‑board quests. Install the helper plugin and invoke its slash‑command (e.g. /auto-stage).
Notification Sends Slack alerts when Claude needs user permission. Install notify-permission and configure Slack webhook.
Developer utilities event-logger.py helps you inspect the payload of any hook event when building your own. Run the Python script while a Claude session is active.

All hooks are ordinary Node‑JS scripts (*.js) that run outside the model process, so prompt‑injection attacks cannot bypass them. Each hook can be installed individually or, for the seven core guards, bundled via the guard-pack plugin for a single‑process startup.

How to get started

  1. Add the marketplace (once):
    /plugin marketplace add karanb192/claude-code-hooks
    
  2. Install a hook you need, for example:
    /plugin install protect-secrets@claude-code-hooks
    
  3. Restart Claude Code so the hook becomes active.
  4. Use the provided slash‑commands (e.g. /protect-secrets) or check generated logs/boards.

Configuration is done through environment‑style variables such as HOOK_SAFETY_LEVEL=high or CONFIG_GUARD_ALLOW=true to relax a guard for a specific call.

Who might find this useful?

  • Developers using Claude Code who want to keep the assistant from accidentally deleting files, leaking credentials, or making destructive git operations.
  • Teams with compliance requirements that need audit trails of AI‑driven code changes.
  • Ops / security engineers looking to sandbox AI agents in CI/CD pipelines.
  • Anyone building custom Claude Code extensions who can reuse the provided event-logger and example hooks as templates.

Limitations / considerations

  • The guards only work with Claude Code versions that emit the documented hook events (PreToolUse, PostToolUse, etc.).
  • Enabling config-guard also blocks the plugin manager itself, so you must install all other plugins before turning it on or temporarily set CONFIG_GUARD_ALLOW=true.
  • Hooks run as separate processes; they add a small overhead (≈35 ms per call for the bundled guard‑pack).
  • Safety levels (critical, high, strict) determine whether a hook silently denies, warns, or asks the user before proceeding.

In short: claude-code-hooks is a practical toolbox that brings least‑privilege, logging, and automation to Claude Code agents, letting you safely harness AI‑driven coding while keeping tight control over what the model can actually do on your machine.

Related

  • Project
  • Project
  • Project
  • Project
  • Project