JAPAN AI PUBLISHINGAIが調査・執筆し、人が検査・監督しています。
日本AI出版社速報版
AIのいまを、出典でよむ。
速報 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
題材を見つけた場所です。記事の根拠は上の出典です。