AI News DailyTips한국어RSS
← AI tool tips
Claude Code✓ Confirmed in official docsOct 8

Make a crashed hook block instead of pass: onFailure block

Until now, a hook that failed to start or timed out let the action through. A hook you added to protect files stopped protecting anything the moment jq was missing. From v2.1.295 (October 8), onFailure: "block" on a command or HTTP hook turns a failure into a block.

// .claude/settings.json
{
  "hooks": {
    "PreToolUse": [
      {
        "matcher": "Edit|Write",
        "hooks": [
          { "type": "command", "command": ".claude/hooks/protect-files.sh", "onFailure": "block" }
        ]
      }
    ]
  }
}

The key is in the October 8 changelog only; the hooks reference page doesn't list it yet. After adding it, open /hooks to confirm it loaded.

Add it only to hooks whose job is to block. On a formatter hook, a failure would halt every edit.

A day earlier, v2.1.294 closed a hole in instruction-style hooks: prompt and agent hooks written as "Block commands that..." were letting through what they should block. Between the two releases, hooks are now trustworthy over a much wider range.

Get notified when a new tip lands

Tip alerts only go out in the app. Install it and turn notifications on.

Get the app

All tips →