速報 11:01
フックで危ない操作を止めているつもりでも、スクリプトのパスを間違えた日は全部通っています。
ほとんどのイベントでは、フックが失敗や時間切れになっても操作はそのまま実行されます。
止めるには、command と http のフックに onFailure を block と書きます。
v2.1.295 以降で使えます。
今日は自分の PreToolUse のフックに onFailure を書き足してください。
出典の原文(引用)
On most events, when a hook fails or times out, Claude Code still carries out the action. A policy hook with a wrong path or a crashing script then lets everything through. To block the action instead, set "onFailure": "block" on a command or http hook. Requires Claude Code v2.1.295 or later.— code.claude.com
この話題のきっかけ
https://github.com/anthropics/claude-code/releases/tag/v2.1.317
題材を見つけた場所です。記事の根拠は上の出典です。
