# Claude Hook Config Guide

Configure automated behaviors in `.claude/settings.json` using hooks.

## Hook Types

| Hook | Fires when |
|------|-----------|
| `PreToolUse` | Before Claude calls a tool |
| `PostToolUse` | After a tool completes |
| `Notification` | When Claude sends a notification |
| `Stop` | When Claude finishes a turn |

## Basic Format

```json
{
  "hooks": {
    "PostToolUse": [
      {
        "matcher": "Edit|Write",
        "hooks": [
          {
            "type": "command",
            "command": "npm run lint --fix"
          }
        ]
      }
    ]
  }
}
```

## Common Patterns

**Auto-lint on file edit:**
```json
{ "matcher": "Edit|Write", "hooks": [{ "type": "command", "command": "eslint --fix $CLAUDE_TOOL_INPUT_FILE_PATH" }] }
```

**Auto-format on write:**
```json
{ "matcher": "Write", "hooks": [{ "type": "command", "command": "prettier --write $CLAUDE_TOOL_INPUT_FILE_PATH" }] }
```

**Run tests after bash:**
```json
{ "matcher": "Bash", "hooks": [{ "type": "command", "command": "npm test -- --passWithNoTests" }] }
```

## Available Environment Variables

- `$CLAUDE_TOOL_NAME` — name of the tool that fired
- `$CLAUDE_TOOL_INPUT_FILE_PATH` — file path (Edit/Write hooks)
- `$CLAUDE_TOOL_INPUT_COMMAND` — command (Bash hooks)
