Skip to main content

Extending with MCP & Hooks

Building Custom Workflows

0:00
LearnStep 1/3

The Smart Refactor Workflow

Combining MCP and Hooks

Let's build a workflow that checks analytics before removing code.

The Setup

  1. MCP: Connect analytics-db server
  2. Hook: PreToolUse on delete_file

The Process

  1. User: "Remove the LegacyLogin component"
  2. Before deletion, Claude checks analytics: "Query analytics-db for 'LegacyLogin' usage in last 30 days"
  3. If count > 0: Claude aborts and reports findings
  4. If count == 0: Claude proceeds, post-hook runs build

This turns Claude from a text editor into a context-aware engineer!