# Automations (hooks) for Claude Code

> Find event automations (hooks) for Claude Code in the Doutor AI Library. Make your applications more efficient.

- Source: https://doutorai.pt/en/claude-code/hooks
- Site: Doutor AI (https://doutorai.pt/en) - AI tools for small businesses

Event automations, also known as hooks, are essential tools for anyone who works with Claude Code. They let developers add reactive functionality to their applications, responding to specific events efficiently.

Installing hooks from the Doutor AI Library gives you access to a wide range of 81 automations, which makes developing and customizing your applications easier. Our library is a reliable source that helps you optimize your workflow and maximize productivity.

## Explore automations

- [agents-md-loader](https://doutorai.pt/en/components/hooks__agents-md-loader): Automatically loads AGENTS.md configuration file content at session start to ensure Claude Code follows project-specific agent behavior. Only loads if AGENTS.md
- [ai-bash-guard](https://doutorai.pt/en/components/hooks__ai-bash-guard): AI-powered bash command security guard. Before any Bash command runs, a lightweight Claude subagent evaluates it for destructive or irreversible patterns - recu
- [auto-git-add](https://doutorai.pt/en/components/hooks__auto-git-add): Automatically stage modified files with git add after editing. Helps maintain a clean git workflow by staging changes as they're made.
- [backup-before-edit](https://doutorai.pt/en/components/hooks__backup-before-edit): Create automatic backup of files before any Edit operation for safety. This hook creates a timestamped backup copy (filename.backup.timestamp) of any existing f
- [build-on-change](https://doutorai.pt/en/components/hooks__build-on-change): Automatically trigger build processes when source files change. Detects common build tools and runs appropriate build commands.
- [change-logger](https://doutorai.pt/en/components/hooks__change-logger-2): Log every file mutation to CSV for demo prep. Records timestamp, tool, file path, action, and details for Edit, MultiEdit, Write, and Bash operations. Output: .
- [change-tracker](https://doutorai.pt/en/components/hooks__change-tracker): Track file changes in a simple log. Records which files were modified and when for easy tracking of Claude Code activity.
- [command-logger](https://doutorai.pt/en/components/hooks__command-logger): Log all Claude Code commands to a file for audit and debugging purposes. Simple logging that records tool usage with timestamps.
- [console-log-cleaner](https://doutorai.pt/en/components/hooks__console-log-cleaner): Warns about console.log statements when editing files on production branches (main/master). Helps prevent debug code from reaching production.
- [context-timeline](https://doutorai.pt/en/components/hooks__context-timeline-2): Real-time browser visualization of Claude Code's context window and subagent/tool execution as a git-graph timeline. Opens http://localhost:7878 on SessionStart
- [conventional-commits](https://doutorai.pt/en/components/hooks__conventional-commits): Enforce conventional commit message format for all git commits. Validates commit messages follow the pattern: type(scope): description. Supported types: feat, f
- [dangerous-command-blocker](https://doutorai.pt/en/components/hooks__dangerous-command-blocker): for pattern, desc in critical_paths: if re.search(pattern, cmd, re.IGNORECASE): print(f'🛑 BLOCKED: Critical path protection activated!', file=sys.stderr) print(
- [dangerous-command-blocker](https://doutorai.pt/en/components/hooks__dangerous-command-blocker-2): Advanced protection against dangerous shell commands with multi-level security. Blocks catastrophic operations (rm -rf /, dd, mkfs), protects critical paths (.c
- [debug-window](https://doutorai.pt/en/components/hooks__debug-window): Auto Debug Log Viewer. Opens a live-tailing debug log window when Claude Code starts with --debug or -d flag. The window closes automatically on session end. To
- [dependency-checker](https://doutorai.pt/en/components/hooks__dependency-checker): Advanced dependency analysis and security checking. Monitors for outdated packages, security vulnerabilities, and license compatibility.
- [deployment-health-monitor](https://doutorai.pt/en/components/hooks__deployment-health-monitor): Monitor deployment status, error rates, and performance metrics, sending notifications for failed deployments or performance degradation. Tracks Vercel deployme
- [desktop-notification-on-stop](https://doutorai.pt/en/components/hooks__desktop-notification-on-stop): Sends a native desktop notification when Claude Code finishes responding. Uses the Stop hook event so you get a single notification per response instead of one 
- [discord-detailed-notifications](https://doutorai.pt/en/components/hooks__discord-detailed-notifications): Send detailed Discord notifications with session information when Claude Code finishes. Includes working directory, session duration, and system info with rich 
- [discord-error-notifications](https://doutorai.pt/en/components/hooks__discord-error-notifications): Send Discord notifications when Claude Code encounters long-running operations or when tools take significant time. Helps monitor productivity and catch potenti
- [discord-notifications](https://doutorai.pt/en/components/hooks__discord-notifications): Send Discord notifications when Claude Code finishes working. Requires DISCORD_WEBHOOK_URL environment variable. Get webhook URL from Discord Server Settings ->
- [edit-audit-log](https://doutorai.pt/en/components/hooks__edit-audit-log): Log all file edits to a project-local audit file with timestamps. Records every Edit tool usage to .claude/edit-log.txt for tracking changes across sessions. Re
- [env-file-protection](https://doutorai.pt/en/components/hooks__env-file-protection): Prevent writing to .env files using the if condition for lightweight filtering. Blocks any Write tool call targeting .env* files, protecting secrets from accide
- [file-backup](https://doutorai.pt/en/components/hooks__file-backup): Automatically backup files before editing. Creates timestamped backups in a .backups directory when files are modified.
- [file-protection](https://doutorai.pt/en/components/hooks__file-protection): Protect critical files from accidental modification. Prevents editing of important system files, configuration files, and production code.
- [force-push-blocker](https://doutorai.pt/en/components/hooks__force-push-blocker): Block git force push commands using the if condition for efficient filtering. Prevents accidental force pushes that can overwrite remote history. Covers --force
- [format-javascript-files](https://doutorai.pt/en/components/hooks__format-javascript-files): Automatically format JavaScript/TypeScript files after any Edit operation using prettier. This hook runs 'npx prettier --write' on any .js, .ts, .jsx, or .tsx f
- [format-python-files](https://doutorai.pt/en/components/hooks__format-python-files): Automatically format Python files after any Edit operation using black formatter. This hook runs 'black' on any .py file that Claude modifies, ensuring consiste
- [git-add-changes](https://doutorai.pt/en/components/hooks__git-add-changes): Automatically stage changes in git after file modifications for easier commit workflow. This hook runs 'git add' on any file that Claude edits or writes, automa
- [index](https://doutorai.pt/en/components/hooks__index): Claude is planning... Dino Runner Snake Flappy Bird aitmpl.com | GitHub
- [langsmith-tracing](https://doutorai.pt/en/components/hooks__langsmith-tracing): Automatically send Claude Code conversation traces to LangSmith for monitoring and analysis. Prerequisites: jq (brew install jq on macOS or sudo apt-get install
- [langsmith-tracing](https://doutorai.pt/en/components/hooks__langsmith-tracing-2): posts_batch=$(echo "$posts_batch" | jq --argjson data "$assistant_data" '. += [$data]')
- [lint-on-save](https://doutorai.pt/en/components/hooks__lint-on-save): Automatically run linting tools after file modifications. Supports ESLint for JavaScript/TypeScript, Pylint for Python, and RuboCop for Ruby.
- [nextjs-code-quality-enforcer](https://doutorai.pt/en/components/hooks__nextjs-code-quality-enforcer): Enforce Next.js best practices, proper file structure, component patterns, and TypeScript usage with automated code reviews and suggestions. Validates Next.js A
- [notify-before-bash](https://doutorai.pt/en/components/hooks__notify-before-bash): Show notification before any Bash command execution for security awareness. This hook displays a simple echo message '🔔 About to run bash command...' before Cla
- [performance-budget-guard](https://doutorai.pt/en/components/hooks__performance-budget-guard): Monitor bundle size and Core Web Vitals metrics during development, blocking deployments that exceed performance budgets with detailed reports. Automatically an
- [performance-monitor](https://doutorai.pt/en/components/hooks__performance-monitor): Monitor system performance during Claude Code operations. Tracks CPU, memory usage, and execution time for performance optimization.
- [plan-gate](https://doutorai.pt/en/components/hooks__plan-gate-2): Planning gate that warns when editing production code without an approved specification. Checks for recent .spec.md files in the project directory (last 14 days
- [plan-mode-game](https://doutorai.pt/en/components/hooks__plan-mode-game): Play games while Claude plans. Launches a browser game (Dino Runner, Snake, or Flappy Bird) automatically when Claude enters Plan Mode via EnterPlanMode or /pla
- [prevent-direct-push](https://doutorai.pt/en/components/hooks__prevent-direct-push): Git Flow workflow: 1. Create a feature branch: /feature
- [prevent-direct-push](https://doutorai.pt/en/components/hooks__prevent-direct-push-2): Prevent direct pushes to protected branches (main, develop). Blocks git push commands targeting main or develop branches to enforce Git Flow workflow. Requires 
- [run-tests-after-changes](https://doutorai.pt/en/components/hooks__run-tests-after-changes): Automatically run quick tests after code modifications to ensure nothing breaks. This hook executes 'npm run test:quick' silently after any Edit operation and p
- [scope-guard](https://doutorai.pt/en/components/hooks__scope-guard): Scope guard that detects files modified outside the declared scope of a specification. When a .spec.md file contains a 'Files to Create/Modify' section, this ho
- [secret-scanner](https://doutorai.pt/en/components/hooks__secret-scanner): print('❌ COMMIT BLOCKED: Remove secrets before committing', file=sys.stderr) print('', file=sys.stderr) print('How to fix:', file=sys.stderr) print(' 1. Move se
- [secret-scanner](https://doutorai.pt/en/components/hooks__secret-scanner-2): Automatically detects hardcoded secrets before git commits. Scans for API keys from 30+ providers (Anthropic: sk-ant-..., OpenAI: sk-..., AWS: AKIA..., Stripe: 
- [security-scanner](https://doutorai.pt/en/components/hooks__security-scanner): Scan code for security vulnerabilities and secrets after modifications. Uses multiple security tools to detect potential issues.
- [shell-wrapper-guard](https://doutorai.pt/en/components/hooks__shell-wrapper-guard-2): Detects destructive commands hidden inside shell wrappers (sh -c, bash -c, python3 -c, node -e, perl -e, ruby -e). Complements dangerous-command-blocker by catc
- [simple-notifications](https://doutorai.pt/en/components/hooks__simple-notifications): Send desktop notifications when Claude Code finishes working or needs user input. Works on macOS and Linux systems.
- [slack-detailed-notifications](https://doutorai.pt/en/components/hooks__slack-detailed-notifications): Send detailed Slack notifications with session information when Claude Code finishes. Includes working directory, session duration, and system info. Requires SL
- [slack-error-notifications](https://doutorai.pt/en/components/hooks__slack-error-notifications): Send Slack notifications when Claude Code encounters long-running operations or when tools take significant time. Helps monitor productivity and catch potential
- [slack-notifications](https://doutorai.pt/en/components/hooks__slack-notifications): Send Slack notifications when Claude Code finishes working. Requires SLACK_WEBHOOK_URL environment variable. Get webhook URL from Slack App settings -> Incoming
- [smart-commit](https://doutorai.pt/en/components/hooks__smart-commit): Intelligent git commit creation with automatic message generation and validation. Creates meaningful commits based on file changes.
- [smart-formatting](https://doutorai.pt/en/components/hooks__smart-formatting): Smart code formatting based on file type. Automatically formats code using Prettier, Black, gofmt, rustfmt, and other language-specific formatters.
- [tdd-gate](https://doutorai.pt/en/components/hooks__tdd-gate-2): Test-Driven Development enforcement hook. Blocks editing production code files (.cs, .py, .ts, .go, .rs, .rb, .php, .java, .kt, .swift, .dart) unless a correspo
- [telegram-detailed-notifications](https://doutorai.pt/en/components/hooks__telegram-detailed-notifications): Send detailed Telegram notifications with session information when Claude Code finishes. Includes working directory, session duration, and system info. Requires
- [telegram-error-notifications](https://doutorai.pt/en/components/hooks__telegram-error-notifications): Send Telegram notifications when Claude Code encounters long-running operations or when tools take significant time. Helps monitor productivity and catch potent
- [telegram-notifications](https://doutorai.pt/en/components/hooks__telegram-notifications): Send Telegram notifications when Claude Code finishes working. Requires TELEGRAM_BOT_TOKEN and TELEGRAM_CHAT_ID environment variables. Get bot token from @BotFa
- [telegram-pr-webhook](https://doutorai.pt/en/components/hooks__telegram-pr-webhook): Send Telegram notification when a new PR is created via gh pr create. Includes PR URL and Vercel preview URL. Requires TELEGRAM_BOT_TOKEN and TELEGRAM_CHAT_ID e
- [test-runner](https://doutorai.pt/en/components/hooks__test-runner): Automatically run relevant tests after code changes. Detects test files and runs appropriate test commands based on file extensions and project structure.
- [update-search-year](https://doutorai.pt/en/components/hooks__update-search-year): Automatically adds current year to WebSearch queries when no year is specified. This hook intercepts WebSearch tool usage and appends the current year to querie
- [validate-branch-name](https://doutorai.pt/en/components/hooks__validate-branch-name): Validate Git Flow branch naming conventions before checkout. Ensures branches follow the pattern: feature/*, release/v*.*.*, hotfix/*. Prevents creation of bran
- [validate-branch-name](https://doutorai.pt/en/components/hooks__validate-branch-name-2): Git Flow branches must follow these patterns: • feature/ • release/v . . • hotfix/
- [vercel-auto-deploy](https://doutorai.pt/en/components/hooks__vercel-auto-deploy): Automatically trigger Vercel deployments when code changes are committed, with environment-specific deployment strategies and rollback on failure. Setup: Export
- [vercel-environment-sync](https://doutorai.pt/en/components/hooks__vercel-environment-sync): Synchronize environment variables between local development and Vercel deployments, ensuring consistency across all environments. Detects changes to .env files 
- [worktree-ghostty](https://doutorai.pt/en/components/hooks__worktree-ghostty-2): Worktree Ghostty Layout. Opens a 3-panel Ghostty layout when creating worktrees: Claude Code (left) | lazygit (top-right) / yazi (bottom-right). Creates worktre

## How to install hooks for Claude Code

Installing hooks in your Claude Code application is a simple process. First, open the Doutor AI Library and look for the automations section. Once you find the hook you want, follow the installation instructions, which include integrating it with your project and the configuration it needs.

## Practical use cases for automations in Claude Code

Hooks are extremely versatile and can be used in many scenarios, such as monitoring user events, managing state or running tasks in the background. For example, a hook can send a notification whenever a user performs a specific action in the application, which improves interactivity.

## The difference between hooks and other automations in Claude Code

Hooks differ from other automations, such as scripts or functions, because they are triggered automatically in response to specific events. This makes them ideal for situations that need dynamic behavior without constant manual intervention.

## By use case

If you already know the task you want to solve, start from a hand-picked selection: we chose the components that are really worth it and explain why. [Code review](https://doutorai.pt/en/for/code-review) · [Automated testing](https://doutorai.pt/en/for/automated-testing) · [Security and auditing](https://doutorai.pt/en/for/security-audit) · [DevOps and deployment](https://doutorai.pt/en/for/devops-and-deployment). [See all use cases](https://doutorai.pt/en/for).

## Frequently asked questions

### What are hooks in Claude Code?

Hooks are automations that let your application respond to events reactively. They simplify development by running specific actions automatically.

### How can I find hooks in the Doutor AI Library?

You can find hooks in the Doutor AI Library by browsing the automations section. You can filter the search by category and specific function to find what you need faster.

### Are hooks compatible with every version of Claude Code?

Yes, the hooks available in the Doutor AI Library are built to be compatible with the latest versions of Claude Code, so you can use them without compatibility problems.

### Can hooks be customized for specific needs?

Yes, many of the available hooks can be customized to meet your specific needs. The documentation in the Doutor AI Library offers guidance on how to make these customizations.

### What are the benefits of using hooks in Claude Code?

The benefits include more efficient development, the ability to respond to events in real time and simpler state management in your application, resulting in a smoother user experience.

## Save hours every week with AI, no hassle

**Doutor AI** gives you 1,859 ready-to-copy AI prompts, by industry and in plain English - plus a complete technical library for those who want to go further. [See plans →](https://doutorai.pt/en/pricing)

---
Content by Doutor AI (https://doutorai.pt/en). When quoting, please cite the source: https://doutorai.pt/en/claude-code/hooks
