Hook
An event-driven interception mechanism in Claude Code that allows developers to insert custom inspection logic at specific execution points, such as before tool calls or when a task stops. Rules can be described in natural language, which the model interprets and enforces at runtime.
Timeline (last 90 days)
v2.1.295 fixes the issue where a mod's Hook received truncated deeply nested tool input without any error, as well as the vulnerability where a guard Hook with .catch was bypassed during plugin worker restarts.
Previously, a Hook failure was a soft failure (the operation continued to proceed); onFailure: "block" allows a Hook to declare a hard failure, defaulting to a fail-closed rather than fail-open strategy when infrastructure failures occur.
Claude Code v2.1.295 introduces the onFailure: "block" option for command-type and HTTP-type Hooks, which allows a failed Hook to directly block the corresponding operation.
For hook injection, the recommended first choice is automatic Hook injection; if the IDE does not support hooks, writing to a rules file (such as agents.md) serves as the fallback solution.
Without hook injection, even if the Skill files are in place, the Agent will not actively call them.
Root or hook solutions are the fastest and most stable, but require flashing the device, carry the risk of account bans, and hook implementations often break after WeChat upgrades.
For high-risk operations such as deleting data, charging fees, and mass messaging, lifecycle hooks should be designed to automatically pause and return control to a human when triggered.
The cross-framework portability of the Ledger depends on the Agent framework providing Hook capabilities, with the remaining functionality implemented through contracts and tools, decoupled from the specific orchestration engine.
The two pathways for data to enter the Ledger are: automatic capture of tool errors via a Hook mechanism, and manual retrospectives initiated by user commands.
Hook技术在JavaScript逆向中的常用方式包括重写document.cookie的setter/getter、重写XMLHttpRequest或fetch方法、使用Object.defineProperty劫持特定对象的属性访问
3 more timeline events
All Facts (14)
Claude Code内置了Hook机制,允许开发者在请求发送到模型之前拦截并处理输入内容
60%Unverifiedv2.1.295 fixes the issue where a mod's Hook received truncated deeply nested tool input without any error, as well as the vulnerability where a guard Hook with .catch was bypassed during plugin worker restarts.
50%UnverifiedClaude Code v2.1.295 introduces the onFailure: "block" option for command-type and HTTP-type Hooks, which allows a failed Hook to directly block the corresponding operation.
50%UnverifiedPreviously, a Hook failure was a soft failure (the operation continued to proceed); onFailure: "block" allows a Hook to declare a hard failure, defaulting to a fail-closed rather than fail-open strategy when infrastructure failures occur.
50%UnverifiedFor hook injection, the recommended first choice is automatic Hook injection; if the IDE does not support hooks, writing to a rules file (such as agents.md) serves as the fallback solution.
50%UnverifiedWithout hook injection, even if the Skill files are in place, the Agent will not actively call them.
50%UnverifiedRoot or hook solutions are the fastest and most stable, but require flashing the device, carry the risk of account bans, and hook implementations often break after WeChat upgrades.
50%UnverifiedFor high-risk operations such as deleting data, charging fees, and mass messaging, lifecycle hooks should be designed to automatically pause and return control to a human when triggered.
50%UnverifiedThe two pathways for data to enter the Ledger are: automatic capture of tool errors via a Hook mechanism, and manual retrospectives initiated by user commands.
50%UnverifiedThe cross-framework portability of the Ledger depends on the Agent framework providing Hook capabilities, with the remaining functionality implemented through contracts and tools, decoupled from the specific orchestration engine.
50%UnverifiedHook技术在JavaScript逆向中的常用方式包括重写document.cookie的setter/getter、重写XMLHttpRequest或fetch方法、使用Object.defineProperty劫持特定对象的属性访问
50%UnverifiedHook 是确定性的机制,由 Claude Code 软件强制执行,不依赖模型判断,能保证100%执行
50%UnverifiedHook 设定档使用 JSON 格式,通常放在专案资料夹的 .claude/settings.json 中
50%UnverifiedHook 的三层架构为 Event(决定何时触发)、Matcher(决定拦截哪个操作)、Handler(决定执行什么动作)
50%