Boris Cherny4/ Use Hooks to Deterministically Run Logic
Source snapshot: 2026-11-09Independent editorial note
When this pattern helps
Treat this as an extension point with an explicit trigger, inputs, permissions, and failure behavior. Start with a narrow workflow, document prerequisites, and verify the action in a disposable project before making it part of a team routine.
把它当作扩展点来设计:明确触发条件、输入、权限和失败处理。先从窄流程开始,写清前置条件,并在临时项目验证后再纳入团队日常。
Use hooks to run logic as part of the agent lifecycle. For example:
- Dynamically load in context each time you start Claude (
SessionStart)
- Log every bash command the model runs (
PreToolUse)
- Route permission prompts to WhatsApp for you to approve/deny (
PermissionRequest)
- Poke Claude to keep going whenever it stops (
Stop)
Original source on X