Claude Code hook

Claude Hooks

A Ruby DSL for creating Claude Code hooks

41 stars 2 forksHooks Source

Install

From source
git clone https://github.com/gabriel-dehan/claude_hooks.git

From the README

Ruby DSL for Claude Code hooks

v1.4.0 just released and is introducing a great number of changes. Please read the CHANGELOG for more information.

A Ruby DSL (Domain Specific Language) for creating Claude Code hooks. This will hopefully make creating and configuring new hooks way easier.

Why use this instead of writing bash, or simple ruby scripts?
You might also be interested in my other project, a Claude Code statusline that shows your Claude usage in realtime, inside Claude Code โœจ.

๐Ÿ“– Table of Contents

- Ruby DSL for Claude Code hooks
  - ๐Ÿ“– Table of Contents
  - ๐Ÿš€ Quick Start
  - ๐Ÿ“ฆ Installation
  - ๐Ÿ—๏ธ Architecture
  - ๐Ÿช Hook Types
  - ๐Ÿš€ Claude Hook Flow
  - ๐Ÿ“š API Reference
  - ๐Ÿ“ Example: Tool usage monitor
  - ๐Ÿ”„ Hook Output
  - ๐Ÿ”Œ Plugin Hooks Support
  - ๐Ÿ› ๏ธ MCP Tools Integration
  - ๐Ÿšจ Advices
  - โš ๏ธ Troubleshooting
  - ๐Ÿงช CLI Debugging
  - ๐Ÿ› Debugging
  - ๐Ÿงช Development \& Contributing

๐Ÿš€ Quick Start

Examples are available in example_dotclaude/hooks/. The GithubGuard in particular is a good example of a solid hook. You can also check Kyle's hooks for some great examples

Claude Code supports two types of hooks:
- Command hooks (type: "command") - Execute Ruby/bash scripts (what this DSL is for)
- Prompt-based hooks (type: "prompt") - Delegate decisions to an LLM (see guide)

Here's how to create a simple command hook with this DSL:

1. Install the gem:

1. Create a simple hook script

3. โš ๏ธ Make it executable

4. Register it in your .claude/settings.json

That's it! Your hook will now add context to every user prompt. ๐ŸŽ‰

Need to run multiple hooks for the same event and merge their outputs? See Multi-hook structure below.

๐Ÿ“ฆ Installation

Install it globally (simpler):

Using a Gemfile

Unless you use bundle exec in the command in yourโ€ฆ
Read the full README on GitHub

How hooks work

  • Hooks are shell commands Claude Code runs at fixed points: before or after a tool call, when you submit a prompt, when Claude stops, on notifications and at session start.
  • They are set in the hooks section of ~/.claude/settings.json (or .claude/settings.json for a project), or come bundled in a plugin.
  • A hook can block a tool call, add context, or run a formatter or test. Read the scripts before you install them: they run on your machine with your permissions.
Claude Code docs

Details

Type
Hooks
Language
Ruby
Last updated
2 November 2026

FAQ

What is Claude Hooks?

A Ruby DSL for creating Claude Code hooks It is a hook for Claude Code, from gabriel-dehan/claude_hooks on GitHub.

How do I install Claude Hooks?

Clone gabriel-dehan/claude_hooks from GitHub and follow the setup steps in its README.

Is Claude Hooks popular?

gabriel-dehan/claude_hooks has 41 GitHub stars and 2 forks, and is included in 1 curated Claude Code list. It was last updated on 2 November 2026.

More hooks

Browse the most popular Claude Code mods, all hooks, or the skills and MCP server directories.