Follow Discord
Sweep 03 Dec 2026 · 19:13Z Build v2.1.336 553 read Stable v2.1.332 Latest v2.1.336 Next v2.1.336 Feeds RSS JSON llms.txt llms-full.txt Unofficial
One change · claude-code

React to events with a mod changedplugins/mods/events

Nearest release: v2.1.333, published an hour after upstream edited the page. Shown because the two are within 24 hours of each other. Nothing here says the release caused the edit.

Upstream edited this page at 30 Nov 2026 17:58 UTC, give or take a minute or two: the time comes from Anthropic’s own sitemap rather than from a commit. This site recorded the change at 30 Nov 2026 18:07 UTC.

Upstream edited
Recorded here
Lines+9added
Lines−7removed
From line 4 where the diff opens
First seen 1 Oct 2026 this site's first read of the page
Recorded edits34to this page, all time

The whole hunk

from line 4, old and new numbered
/
lines
from line 4
44 
55A hook is an event handler: a function that Claude Code runs when a named event happens. Claude Code fires an event at each point where it's about to act, such as when it runs a tool, submits a prompt, sends a request to the model, or starts or ends a session. Your hook runs before Claude Code acts, so it can observe the event, rewrite it, or answer it in Claude Code's place. You register a hook with [`on(eventName, handler)`](https://code.claude.com/docs/en/plugins/mods/reference#the-hook-function).
66 
7Build your [first mod](https://code.claude.com/docs/en/plugins/mods/create.md) before you start here. For every event and its exact fields, see the [reference](https://code.claude.com/docs/en/plugins/mods/reference.md#events) or read [the types for your build](https://code.claude.com/docs/en/plugins/mods/create.md#get-the-types-for-your-build).
7Build your [first mod](https://code.claude.com/docs/en/plugins/mods/create.md) before you start here. For every event and its exact fields, see the [type declarations](https://code.claude.com/docs/en/plugins/mods/reference.md#look-up).
88 
99## How a hook handles an event
1010 
from line 66
6666})
6767```
6868 
69When Claude tries a Bash command, the command doesn't run, and Claude reads the `deny` text as the tool's result. Each event has its own result shape, which the [events reference](https://code.claude.com/docs/en/plugins/mods/reference.md#events) lists.
69When Claude tries a Bash command, the command doesn't run, and Claude reads the `deny` text as the tool's result. Each event has its own result shape, which the [type declarations](https://code.claude.com/docs/en/plugins/mods/reference.md#look-up) list.
7070 
7171### Filter which events a hook handles
7272 
from line 101
101101 
102102## Hook what Claude is doing
103103 
104Handle these events to see or change a tool call, a prompt, a turn, or a settings read as it happens. For every event and what a hook can return, see the [events reference](https://code.claude.com/docs/en/plugins/mods/reference.md#events).
104Handle these events to see or change a tool call, a prompt, a turn, or a settings read as it happens. For every event and what a hook can return, see the [type declarations](https://code.claude.com/docs/en/plugins/mods/reference.md#look-up).
105105 
106106### Guard or change a tool call
107107 
from line 193
193193 
194194#### Approve or refuse a tool call before the user is asked
195195 
196To decide whether a tool call may run, handle [`tool.check`](https://code.claude.com/docs/en/plugins/mods/reference#tools), the event where Claude Code makes that decision.
196To decide whether a tool call may run, handle `tool.check`, the event where Claude Code makes that decision.
197197 
198198For a fixed command or path, use a [permission rule](https://code.claude.com/docs/en/permissions.md#permission-rule-syntax) such as `Bash(npm test)`, which takes no code. Handle `tool.check` when the decision depends on what's true at that moment, such as the current Git branch or a value another hook recorded.
199199 
from line 300
300300 
301301#### Change system prompt, context, or skill text
302302 
303[Other events](https://code.claude.com/docs/en/plugins/mods/reference.md#prompts-and-what-claude-reads) cover the rest of what Claude reads: `prompt.section` for each section of the system prompt, `prompt.context` for the context sent with the first message, and `skill.prompt` for a skill's text. To change a section after a conversation has started, see [Send a changed system prompt section or tool description](https://code.claude.com/docs/en/plugins/mods/reference.md#break-prompt-cache). In a `skill.prompt` hook, you can also read [which plugin or file the skill came from](https://code.claude.com/docs/en/plugins/mods/reference.md#skill-prompt-fields).
303[Other events](https://code.claude.com/docs/en/plugins/mods/reference.md#prompts-and-what-claude-reads) cover the rest of what Claude reads: `prompt.section` for each section of the system prompt, `prompt.context` for the context sent with the first message, and `skill.prompt` for a skill's text. To change a section after a conversation has started, see [Send a changed system prompt section or tool description](https://code.claude.com/docs/en/plugins/mods/reference.md#break-prompt-cache).
304304 
305In a `skill.prompt` hook, you can also read which plugin or file the skill came from, in `e.pluginName` and `e.path`. Those fields require Claude Code v2.1.299 or later.
306 
305307### Follow a turn
306308 
307309A turn is everything Claude does in answer to one prompt. Handle `turn.start`, `turn.step`, and `turn.complete` to follow one:
from line 480
478480 
479481The handler has a shorter [time limit](https://code.claude.com/docs/en/plugins/mods/reference.md#limits) of its own. If the handler itself throws or times out, Claude Code skips the hook as if it had no handler. When `guard` hadn't called `next`, the command then goes on as it would without the mod.
480482 
481The same handler shape fits a guard on `prompt.submit` or `config.set`. When `next.called` is false, return the refusal that the [events reference](https://code.claude.com/docs/en/plugins/mods/reference.md#events) lists for that event: `{ drop: 'the reason' }` for `prompt.submit`, `{ deny: 'the reason' }` for `config.set`.
483The same handler shape fits a guard on `prompt.submit` or `config.set`. When `next.called` is false, return the refusal for that event: `{ drop: 'the reason' }` for `prompt.submit`, `{ deny: 'the reason' }` for `config.set`.
482484 
483485At `tool.check` and `plugin.register`, a refusal returned after `next` resolved still holds, so return it without testing `next.called`:
484486 
from line 494
492494* [Use the mods API](https://code.claude.com/docs/en/plugins/mods/api.md): add commands and tools, call a model, and run work on a timer
493495* [Draw in the interface](https://code.claude.com/docs/en/plugins/mods/interface.md): show what your hooks collect in a pane or above the prompt
494496* [Test a mod](https://code.claude.com/docs/en/plugins/mods/test.md): fire any of these events from a test
495* [Mods reference](https://code.claude.com/docs/en/plugins/mods/reference.md): every event, every mods API method, and the limits
497* [Mods reference](https://code.claude.com/docs/en/plugins/mods/reference.md): where to look up an event, and the limits
496498 
Feedback