講座 › 分野1 エージェントアーキテクチャとオーケストレーション
1.5 フックによる介入とデータ正規化
配点 3.9%Hooks for interception and normalization
フックは、ツールの呼び出しの前後に割り込むプログラム。方針違反を止め、バラバラな形式の結果をそろえる。
未読
フックとは:決まった時点で動くコード 読了

フックは、ツールを呼ぶ直前や、結果が返った直後など、決まった時点で動くコードです。実行を許可する・止める・入力を書き換える・文脈に情報を足す、のいずれかを返せます。
出典:Intercept and control agent behavior with hooks
your callback returns an output object that tells the agent what to do: allow the operation, block it, modify the input, or inject context into the conversation.https://code.claude.com/docs/en/agent-sdk/hooks.md(取得 2026-11-20)
出典:Intercept and control agent behavior with hooks
PreToolUse | Yes | Yes | Tool call request (can block or modify)https://code.claude.com/docs/en/agent-sdk/hooks.md(取得 2026-11-20)
出典:Intercept and control agent behavior with hooks
PostToolUse | Yes | Yes | Tool execution resulthttps://code.claude.com/docs/en/agent-sdk/hooks.md(取得 2026-11-20)
呼び出しの前:方針違反を止める 読了

呼び出しを横取りするフックで、上限を超える返金のような、方針に反する操作を止められます。止めたあとは、人への引き継ぎなど別の手順に回します。
出典:Claude Certified Architect – Foundations Exam Guide v1.0(英語)
Implementing tool call interception hooks that block policy-violating actions (e.g., refunds exceeding $500) and redirect to alternative workflows (e.g., human escalation)https://everpath-course-content.s3-accelerate.amazonaws.com/instructor…(取得 2026-11-20)
出典:Intercept and control agent behavior with hooks
Block dangerous operations before they execute, like destructive shell commands or unauthorized file accesshttps://code.claude.com/docs/en/agent-sdk/hooks.md(取得 2026-11-20)
結果の後:形式をそろえる 読了

ツールごとに、日時が Unix 時刻だったり ISO 8601 だったり、状態が数字のコードだったりと、形式が違います。結果の直後に動くフックで形式をそろえてから、エージェントに読ませます。
出典:Claude Certified Architect – Foundations Exam Guide v1.0(英語)
Implementing PostToolUse hooks to normalize heterogeneous data formats (Unix timestamps, ISO 8601, numeric status codes) from different MCP tools before the agent processes themhttps://everpath-course-content.s3-accelerate.amazonaws.com/instructor…(取得 2026-11-20)
出典:Hooks reference
PostToolUse: updatedToolOutput replaces the tool's result.https://code.claude.com/docs/en/hooks.md(取得 2026-11-20)
入口と出口の使い分け、効かない場合 読了

外に出ていく入力は呼び出しの前、成功した結果は呼び出しの後で、手を入れます。対象を絞る指定が書き込みと編集のツールだけだと、別の道具で同じことをされたときにフックは動きません。
出典:Hooks reference
intercept at PreToolUse for outbound tool inputs and PostToolUse for the results of successful calls.https://code.claude.com/docs/en/hooks.md(取得 2026-11-20)
出典:Intercept and control agent behavior with hooks
If Claude writes .env with a Bash command, the hook doesn't run.https://code.claude.com/docs/en/agent-sdk/hooks.md(取得 2026-11-20)
確実に守らせたいなら、フック 読了

業務の決まりを確実に守らせたいときは、フックの出番です。フックは確定した動きをし、プロンプトの指示は確率的にしか守られません。
出典:Claude Certified Architect – Foundations Exam Guide v1.0(英語)
The distinction between using hooks for deterministic guarantees versus relying on prompt instructions for probabilistic compliancehttps://everpath-course-content.s3-accelerate.amazonaws.com/instructor…(取得 2026-11-20)
試験のポイント
- 呼び出しの前のフックで方針違反を止め、別の手順に回す。
出典:Claude Certified Architect – Foundations Exam Guide v1.0(英語)
Implementing tool call interception hooks that block policy-violating actions (e.g., refunds exceeding $500) and redirect to alternative workflows (e.g., human escalation)
https://everpath-course-content.s3-accelerate.amazonaws.com/instructor…(取得 2026-11-20) - 結果の後のフックで、日時や状態コードの形式をそろえる。
出典:Claude Certified Architect – Foundations Exam Guide v1.0(英語)
Implementing PostToolUse hooks to normalize heterogeneous data formats (Unix timestamps, ISO 8601, numeric status codes) from different MCP tools before the agent processes them
https://everpath-course-content.s3-accelerate.amazonaws.com/instructor…(取得 2026-11-20) - 確実さが要る決まりは、プロンプトではなくフックで守らせる。
出典:Claude Certified Architect – Foundations Exam Guide v1.0(英語)
The distinction between using hooks for deterministic guarantees versus relying on prompt instructions for probabilistic compliance
https://everpath-course-content.s3-accelerate.amazonaws.com/instructor…(取得 2026-11-20)