Claude Code hook

claude-hooks

Set of hooks that enforce clean-code practices and automate routine checks during Claude Code sessions.

75 stars 3 forksHooks Source

Install

From source
git clone https://github.com/decider/claude-hooks.git

From the README

Claude Code Hooks

A lightweight Python-based hook system for Claude Code that provides automatic validation and quality checks.

Overview

Claude Code Hooks allows you to set up automatic validation, quality checks, and notifications that run during your Claude Code sessions. The system uses Python scripts that integrate seamlessly with Claude's hook events.

Features

- 🐍 Python-based - Simple, portable hook implementation
- ✅ Code Quality Validation - Enforces clean code standards
- 📦 Package Age Checking - Prevents installation of outdated packages
- 🔔 Task Completion Notifications - Get notified when Claude finishes tasks
- 🎯 Easy Installation - One command setup
- 🏗️ Hierarchical Configuration - Different rules for different directories
- 🔍 Hook Introspection - See which hooks apply to any file

Installation

This will:
1. Create a .claude/ directory in your project
2. Copy all hook scripts to .claude/hooks/
3. Generate .claude/settings.json with hook configurations
4. Add .claude/settings.local.json to your .gitignore

How It Works

The hook system uses three main entry points that Claude Code calls:
- PreToolUse - Runs before tools like Bash, Write, or Edit are executed
- PostToolUse - Runs after tools complete
- Stop - Runs when Claude stops or completes a task

Each hook receives event data via stdin and can:
- Provide suggestions and warnings
- Block operations that violate policies
- Send notifications
- Log activities

Available Hooks

Code Quality Validator
Enforces clean code standards on file edits:
- Maximum function length (30 lines)
- Maximum file length (200 lines)
- Maximum line length (100 characters)
- Maximum nesting depth (4 levels)

Package Age Checker
Prevents installation of outdated npm/yarn packages:
- Blocks packages older than 180…
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
Python
License
MIT
Last updated
20 July 2025

FAQ

What is claude-hooks?

Set of hooks that enforce clean-code practices and automate routine checks during Claude Code sessions. It is a hook for Claude Code, from decider/claude-hooks on GitHub.

How do I install claude-hooks?

Clone decider/claude-hooks from GitHub and follow the setup steps in its README.

Is claude-hooks popular?

decider/claude-hooks has 75 GitHub stars and 3 forks, and is included in 1 curated Claude Code list. It was last updated on 20 July 2025.

More hooks

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