Skip to main content

Extending with MCP & Hooks

Hooks for Automation

0:00
LearnStep 1/3

The Hook Lifecycle

Intercepting Claude's Actions

Hooks allow you to run custom code at specific points in Claude's workflow:

  • PreToolUse: Before a tool executes (great for safety checks)
  • PostToolUse: After a tool completes (great for formatting)
  • Notification: For logging and monitoring

Configuration Example

json

In this example, every time Claude writes a file, Prettier automatically formats it.