Hooks — Runtime layer
🌐 日本語
NOTE
Hooks are scripts that fire at defined lifecycle events (PreToolUse, PostToolUse, UserPromptSubmit, etc.). They run outside the LLM's context — deterministic checks and side effects that the model never sees.
How it works
- Defined in
settings.jsonunderhooks.<event>. - The LLM cannot disable, bypass, or even read its own hooks — that's the point.
- Best used for guardrails (lint, secret scan, format) that you want to be unskippable.
Related chapters
- Part 7 — Runtime Layer (overview)
- settings.json
- Hooks Lifecycle
- Why Not in Context
- Configuration Reference
Structural problems it addresses
- Instruction Decay — enforcement happens regardless of memory drift.
- Sycophancy — the LLM can't talk its way past a hook.
- Prompt Sensitivity — phrasing doesn't change what the script does.
See also
- Topic: CLAUDE.md — for instructions the LLM is expected to follow voluntarily.
- Topic: Plugins — for distributing hooks alongside skills and MCPs.
- Feature Index