gitwtfhub

wtf is claude-code-hooks-cookbook?

rongtnt/claude-code-hooks-cookbook — explained in plain English

Analysis updated 2026-05-18

5PythonAudience · developerComplexity · 2/5LicenseSetup · easy

TL;DR

A set of copy-paste Claude Code hook recipes that auto-format files, block risky commands, gate on tests, and send notifications.

Mindmap

mindmap
  root((claude-code-hooks-cookbook))
    What it does
      Ready made hooks
      Copy paste recipes
    Tech stack
      Python scripts
      Shell commands
    Use cases
      Block dangerous commands
      Auto-format edits
      Test gate before stop
      Notify on finish
    Audience
      Claude Code users
      Developers
    Design
      Dependency free
      Current hook schema

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Why would anyone build with this?

REASON 1

Stop an AI coding assistant from running destructive commands like force pushes or mass deletes.

REASON 2

Automatically format any file the assistant edits using the project's existing formatter.

REASON 3

Get notified on desktop or Slack when a coding assistant session finishes or needs input.

REASON 4

Require passing tests before the assistant is allowed to consider a task done.

What's in the stack?

PythonShell

How it stacks up

rongtnt/claude-code-hooks-cookbook1ncendium/aibusteraaronmayeux/ha-hurricane-tracker
Stars555
LanguagePythonPythonPython
Setup difficultyeasymoderateeasy
Complexity2/53/52/5
Audiencedeveloperops devopsgeneral

Figures from each repo's GitHub metadata at analysis time.

How do you spin it up?

Difficulty · easy Time to first run · 5min
Use freely for any purpose, including commercial use, as long as you keep the copyright notice.

Wtf does this do

This project is a collection of ready to use configuration recipes for Claude Code, the AI coding assistant tool. Claude Code has a feature called hooks, which are small shell commands that the tool runs automatically at certain moments while it works, such as right before it runs a command, right after it edits a file, or when a coding session starts or ends. This repository gives copy and paste examples of hooks that solve common, practical problems, rather than just demonstrating the feature. The repository includes eight separate recipes. One automatically formats any file the assistant edits, using whichever code formatter is already installed in the project. Another blocks dangerous commands, such as commands that could delete large amounts of files or force push over other people's changes, and explains to the assistant why the action was refused. A third recipe protects sensitive files, like environment variable files or password certificates, from being edited, and also prevents the assistant from writing files outside the current project folder. Another recipe checks that a project's automated tests pass before allowing the assistant to consider its work finished. There is also a recipe for sending a desktop or messaging notification when a session finishes or needs the user's attention, one that adds useful background information about the project when a session begins, one that automatically approves harmless read only commands so the user is not asked to confirm them every time, and one that keeps a log file recording every action the assistant took. Each recipe includes both a short configuration snippet to add to a settings file and a matching script file. The project has no external dependencies beyond what is already available on a typical computer, and it is released under the MIT license, meaning anyone can use or modify it freely.

Yoink these prompts

Prompt 1
Help me install the block-dangerous-commands hook from this repo into my project's Claude Code settings.
Prompt 2
Explain how the test-gate hook prevents Claude Code from stopping on a failing test suite.
Prompt 3
Walk me through setting up the notify.py hook to send me a Slack message when a run finishes.
Prompt 4
Show me how to combine several of these hooks in one settings.json file.

Frequently asked questions

wtf is claude-code-hooks-cookbook?

A set of copy-paste Claude Code hook recipes that auto-format files, block risky commands, gate on tests, and send notifications.

What language is claude-code-hooks-cookbook written in?

Mainly Python. The stack also includes Python, Shell.

What license does claude-code-hooks-cookbook use?

Use freely for any purpose, including commercial use, as long as you keep the copyright notice.

How hard is claude-code-hooks-cookbook to set up?

Setup difficulty is rated easy, with roughly 5min to a first successful run.

Who is claude-code-hooks-cookbook for?

Mainly developer.

View the repo → Decode another repo

This repo across BitVibe Labs

Don't trust strangers blindly. Verify against the repo.