Mods reference
Show diff (482 lines)
--- a/reference.md
+++ b/reference.md
@@ -1,6 +1,16 @@
-Look up any event a [mod](</docs/en/plugins/mods/overview>) can handle, mods API method it can call, or render site it can draw in. Entries cover the Claude Code CLI and the Desktop app as of v2.1.290, and the VS Code extension as of v2.1.299. Each entry gives the name and a one-line description, and links to the guide section that explains it where there is one.
-
-The complete reference is Claude Code’s [TypeScript declarations for mods](<https://github.com/anthropics/claude-code/blob/main/mods/types/claude-code.d.ts>), which describe every event, method, and element, with examples. The copy on GitHub can be older than the Claude Code version you have installed. When the two disagree, trust [the copy Claude Code writes for your version](</docs/en/plugins/mods/create#get-the-types-for-your-build>).
+The [type declarations on GitHub](<https://github.com/anthropics/claude-code/blob/main/mods/types/claude-code.d.ts>) document the events, mods API methods, and props a [mod](</docs/en/plugins/mods/overview>) can use. Start with how to search the declarations, or go to a mod’s files, render sites by app, or limits.
+
+## Look up an event, method, or prop
+
+To look up a name, open the [type declarations on GitHub](<https://github.com/anthropics/claude-code/blob/main/mods/types/claude-code.d.ts>) and search for the name in one of these forms:
+
+ * **An event** : its name in quotes, such as `'tool.call'`. The entry names the type that holds the event’s fields, so search for that type next.
+ * **A hook’s`next` argument**: `type Next<`
+ * **A mods API method** : its namespace, a colon, and a brace, such as `fs: {` for `$.fs.write`. The namespace’s methods follow.
+ * **Arender site’s props**: the site’s name and a colon, such as `AbovePrompt:`
+ * **An element’s props** : the element’s name and `Props`, such as `ButtonProps`
+
+The comment above an entry says what the event, method, or prop does. If your browser’s search misses a name on GitHub, search the [raw file](<https://raw.githubusercontent.com/anthropics/claude-code/main/mods/types/claude-code.d.ts>). The GitHub copy can describe a newer or older Claude Code version than you run. For your version’s declarations, search the [copy Claude Code writes](</docs/en/plugins/mods/create#get-the-types-for-your-build>) into your mod’s directory.
## Files
@@ -16,188 +26,35 @@
`register` receives `on` and `options`. `options` holds the values of the [`userConfig`](</docs/en/plugins/components#user-configuration>) fields the manifest declares, with defaults filled in.
-## The hook function
-
-A mod registers each of its hooks, which are event handlers, by calling `on` inside `register`. `on` takes the event’s name, an optional [matcher](</docs/en/plugins/mods/events#filter-which-events-a-hook-handles>), which is a filter on the event’s fields, and the hook, as in `on('tool.call', { tool: 'Bash' }, async ($, e, next) => next(e))`. `on` returns a registration with one method, `.catch(handler)`, which sets the hook’s [error handler](</docs/en/plugins/mods/events#handle-a-hook-that-fails>).
-
-Argument| What it is
----|---
-[`$`](</docs/en/plugins/mods/events#how-a-hook-handles-an-event>)| The mods API: every method in mods API methods. Write each call in full, namespace then method, as in `$.fs.read('notes.md')`.
-[`e`](</docs/en/plugins/mods/events#how-a-hook-handles-an-event>)| The event’s input. To change it, pass a copy to `next`.
-[`next(e)`](</docs/en/plugins/mods/events#how-a-hook-handles-an-event>)| The next handler, as in middleware. Runs the hooks after this one, then Claude Code’s behavior. Resolves to the event’s result.
-[`next.signal`](</docs/en/plugins/mods/api#stop-background-work>)| An `AbortSignal` that aborts when the event is abandoned
-`next.origin`| `{ plugin, tier }` of whoever fired the event. Claude Code itself is `{ plugin: 'engine', tier: 'core' }`. A mod’s `tier` is its priority group in the [order mods run in](</docs/en/plugins/mods/events#the-order-mods-run-in>): `prepend`, `user`, `append`, or `builtin`.
-`next.budget`| The hook’s time limit in milliseconds: `next.budget.ms` is the whole limit, and `next.budget.remainingMs` is what’s left now
-`next.to(e, tier)`| Skips to a later tier, which is `append`, `builtin`, or `core`. `next.to(e, 'append')` skips the mods a user installed. Only a mod in `prependPlugins` or `appendPlugins` can call it.
-`next.error`| In a `.catch` handler only. `kind` is `throw` or `timeout`, and `message` is the error’s text.
-`next.called`| In a `.catch` handler only. `true` when the hook had called `next`.
-
-## Events
-
-Events are grouped by what they concern, each with when it fires and what a hook on it can return. Hooks on `turn.step` and `process.spawn` are async generators, and other hooks are async functions. The last column of each table uses shorthand. `next(e)` passes the event on unchanged. `next({ ...e, text })` passes on a copy with the named field changed, as in `next({ ...e, text: e.text.trim() })`. An object answers the event without calling `next`, and a word such as `reason` stands for a string you write, as in `{ deny: 'Use the file tools.' }`.
-
-### Tools
-
-Tool events fire around each tool call Claude makes, from the description Claude reads to the decision on whether the call runs:
-
-Event| Fires when| A hook can return
----|---|---
-[`tool.call`](</docs/en/plugins/mods/events#guard-or-change-a-tool-call>)| A tool is about to run| `next(e)`, `{ deny: reason }`, or `{ result }`
-[`tool.check`](</docs/en/plugins/mods/events#where-settings-hooks-run-in-the-order>)| Claude Code decides whether a tool call may run, after the `tool.call` and `PreToolUse` hooks. `next(e)` resolves to the decision the rules, the permission mode, and those hooks reached.| `next(e)` or `{ decision }`, with `decision` set to `allow`, `ask`, or `deny` and an optional `reason`
-`tool.judge`| [Auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>) is about to ask its classifier about a call. Requires Claude Code v2.1.326 or later.| `next(e)` or `{ decision }`
-`tool.run`| An allowed call is about to run. Requires Claude Code v2.1.326 or later.| `next(e)`, `{ deny: reason }`, or `{ result }`
-`tool.describe`| Once for each tool, when its description is first sent to Claude. A second time for an MCP tool when Claude loads it through [tool search](</docs/en/mcp#scale-with-mcp-tool-search>), with `e.description` set to the text Claude reads for the loaded tool.| `{ description }`, optionally with `isDeferred` set to `true` to put the tool behind tool search or `false` to load it upfront. Add `breakPromptCache: true` to send a changed description on the next turn.
-`tool.offer`| Claude Code builds Claude’s tool list, and again when Claude calls a tool. Requires Claude Code v2.1.328 or later.| `next(e)`, or `{ isOffered: false }` to withhold the tool from Claude. See Send a changed tool list.
-
-#### Agent and organization fields on `tool.check`
-
-In a `tool.check` hook, read these fields to tell a subagent’s call from the main conversation’s, and to see whether your organization requires approval for a connector tool:
-
- * **`e.agentId`** : set when a [subagent](</docs/en/sub-agents>) or an [in-process teammate](</docs/en/agent-teams#choose-a-display-mode>) makes the call, and absent when the main conversation does
- * **`e.ceiling`** : `ask` for a connector tool your organization set to `ask`, in [sessions where that setting reaches Claude Code](</docs/en/mcp#organization-controls-on-connector-tools>)
-
-On `tool.check`, `e.agentId` and `e.ceiling` require Claude Code v2.1.290 or later.
-
-#### The `e.isReadOnly` field on `tool.check`
-
-In a `tool.check` hook, `e.isReadOnly` is `true` when the tool reports this call as read-only. Otherwise the field is absent, not `false`. The value is the tool’s own report, so read [Check whether a tool call is read-only](</docs/en/plugins/mods/events#check-whether-a-tool-call-is-read-only>) before you approve a call on this field alone. On `tool.check`, `e.isReadOnly` requires Claude Code v2.1.304 or later.
-
-### Prompts and what Claude reads
-
-Prompt events cover the text the user types and the text Claude Code sends to Claude on its own, such as the system prompt and reminders:
-
-Event| Fires when| A hook can return
----|---|---
-[`prompt.submit`](</docs/en/plugins/mods/events#rewrite-or-add-to-a-prompt>)| A prompt is submitted| `next({ ...e, text })`, `next({ ...e, context })`, or `{ drop: reason }`
-`prompt.fill`, `prompt.suggest`| Text is about to go into the prompt box as a draft, or as a dim suggestion| `next(e)` with changed text
-`prompt.edit`| The user edits the prompt box| `next(e)`
-`prompt.autocomplete`| The user types in the prompt box and a word ends at the cursor. `e.token` is that word. Claude Code doesn’t wait for the hook: its own autocomplete rows show first.| `{ suggestions }`, a list of `{ text, label, description }` rows shown below Claude Code’s own. Choosing a row writes its `text` over the word.
-`prompt.compose`| Claude Code renders a system prompt| `{ sections }`, a list of `{ id, text, scope }` in the order they’re sent
-[`prompt.section`](</docs/en/plugins/mods/events#rewrite-or-add-to-a-prompt>)| Once for each named section of the system prompt. `e.name` is the section’s `id` in `prompt.compose`.| `{ text }`, or `{ text: null }` to omit the section. Add `breakPromptCache: true` to send a changed section on the next turn.
-[`prompt.context`](</docs/en/plugins/mods/events#rewrite-or-add-to-a-prompt>)| Once for each conversation, for the context sent with the first message| `{ blocks }`
-`prompt.attachment`| Claude Code adds a message of its own for Claude, such as a reminder. `e.type` names the kind, and for the kinds the types declare, `e.detail` holds the facts the text was written from.| `{ text }`, or `{ text: null }` to omit it
-`prompt.mention`| Claude Code is about to read a file that a prompt @-mentions. Requires Claude Code v2.1.290 or later.| `next({ ...e, path })` to read a different file, or `{ deny: reason }`
-[`skill.prompt`](</docs/en/plugins/mods/events#rewrite-or-add-to-a-prompt>)| A skill’s text is expanded for Claude| `{ text }`
-`attribution.text`| Claude Code composes commit or pull request attribution text| `{ text }`
-
-#### Source and frontmatter fields on `skill.prompt`
-
-In a `skill.prompt` hook, you can read these fields along with the skill’s name in `e.skill` and the text Claude reads in `e.text`:
-
-Field| Type| What it holds
----|---|---
-`e.source`| string| Who provides the skill: `policySettings`, `userSettings`, or `projectSettings` for a skill in the enterprise, personal, or project [location](</docs/en/skills#where-skills-live>), respectively. Other sources give a word such as `plugin`, `mcp`, `syncedSkills`, or `built-in`.
-`e.pluginName`| string| The plugin’s name, for a skill whose `e.source` is `plugin`
-`e.path`| string| The absolute path of the skill’s `SKILL.md` file, or of its `.md` file for a skill written as a [command file](</docs/en/skills#where-skills-live>). Absent when the skill has no file on this machine, as with a built-in skill.
-`e.frontmatter`| object| The frontmatter of the skill’s file, as plain data
-`e.frontmatterProblem`| string| The reason `e.frontmatter` is missing the file’s frontmatter or one of its keys, as in `is a list or a single value, not a table`. Absent when `e.frontmatter` holds the whole frontmatter or the skill has none.
-
-A hook can pass a changed `text` or `frontmatter` to `next`: the hooks after it read both, and Claude reads the final `text`. A hook that changes any other field [fails](</docs/en/plugins/mods/events#handle-a-hook-that-fails>). On `skill.prompt`, `e.source`, `e.pluginName`, `e.path`, `e.frontmatter`, and `e.frontmatterProblem` require Claude Code v2.1.299 or later.
-
-#### Send a changed system prompt section or tool description with `breakPromptCache`
+## Telemetry
+
+`telemetry.log` fires when a telemetry record is about to be logged. In your mod, give a telemetry hook the filter `{ to: 'collector' }`, as in `on('telemetry.log', { to: 'collector' }, hook)`. Without the filter, the mod fails `claude plugin validate`.
+
+To run your hook in sessions that load the [built-in guard](</docs/en/plugins/mods/admin#know-what-happens-by-default>), such as on a Team or Enterprise login, ask the organization’s administrator to [install your mod as theirs](</docs/en/plugins/mods/admin#install-your-organizations-mods>). If you or another user installs it instead, the hook [doesn’t run in those sessions](</docs/en/plugins/mods/admin#hooks-the-guard-passes-over>) on Claude Code v2.1.328 or later.
+
+## Send a changed system prompt section or tool description with `breakPromptCache`
To change a section or a tool description in a running conversation, call `$.ui.invalidate('prompt.section')` or `$.ui.invalidate('tool.describe')` so your hook runs again. Return `{ text, breakPromptCache: true }` or `{ description, breakPromptCache: true }` from it. Without the field, Claude keeps reading the text [saved with the conversation](</docs/en/cli-reference#system-prompt-flags-in-resumed-conversations>) for a section or a tool loaded upfront until a new conversation or a [compaction](</docs/en/prompt-caching#compacting-the-conversation>). The changed text reaches Claude on the next turn, and the [prompt cache](</docs/en/prompt-caching>) starts over, so that turn is slower and more expensive. The field requires Claude Code v2.1.321 or later. From v2.1.299 until v2.1.321, a running conversation got the changed text on the next turn.
-#### Send a changed tool list
+## Send a changed tool list
To change the main conversation’s tool list, call `$.ui.invalidate('tool.offer')` and return `{ isOffered, breakPromptCache: true }` from your `tool.offer` hook. The [prompt cache](</docs/en/prompt-caching>) then starts over. Requires Claude Code v2.1.331 or later.
-### Commands and configuration
-
-Event| Fires when| A hook can return
----|---|---
-[`command.run`](</docs/en/plugins/mods/api#add-a-command>)| A command is about to run| `{ text }`, `{}`, or `next(e)`
-`command.describe`| Once for each command, for the command list| `{ description, argumentHint, isHidden }`
-`config.set`| A `/config` row is about to change| `next({ ...e, value })` or `{ deny: reason }`
-`config.describe`| Once for each `/config` row| `{ label, description, isHidden }`
-[`settings.read`](</docs/en/plugins/mods/events#settings-read-hook>)| A mod calls [`$.settings.read`](</docs/en/plugins/mods/api#reach-files-processes-and-the-network>), or Claude Code builds the session’s merged settings. Requires Claude Code v2.1.304 or later on Claude Code’s own read and for `e.layers`| `next(e)`, `{ value }`, or `{ deny: reason }`
-
-#### `e.layers` and `e.source` on `settings.read`
-
- * **`e.layers`** : one `{ source, settings }` object for each source in use that holds settings, lowest [precedence](</docs/en/settings#settings-precedence>) first. See [What a `settings.read` hook receives](</docs/en/plugins/mods/events#settings-read-receives>).
- * **`e.source`** : the one source a mod asked for, as in `$.settings.read({ source: 'policy' })`. Absent on Claude Code’s own read and on a read of the merged settings
-
-### Turns
-
-Turn events follow one answer from start to finish, including each request to the model within it:
-
-Event| Fires when| A hook can return
----|---|---
-[`turn.start`](</docs/en/plugins/mods/events#follow-a-turn>)| A turn begins| `next(e)`
-[`turn.step`](</docs/en/plugins/mods/events#follow-a-turn>)| One request is about to go to the model| `yield* next(e)`, or `next({ ...e, model })`, `next({ ...e, effort })`
-[`turn.complete`](</docs/en/plugins/mods/events#follow-a-turn>)| A turn ended| `next(e)`, or `{ text }` to show a line under the main conversation’s answer
-
-### Session
-
-Session events mark the session starting, ending, compacting, and exchanging messages with other sessions:
-
-Event| Fires when| A hook can return
----|---|---
-[`session.start`](</docs/en/plugins/mods/api#add-a-command-or-a-tool>)| Once for each loaded mod, before the first prompt, and again after a reload of that mod. Not after `/clear`, `/resume`, or `/branch`.| `next(e)`
-`session.end`| The session ends, or `/clear`, `/resume`, or `/branch` runs. `e.reason` is `clear`, `resume`, `logout`, `prompt_input_exit`, or `other`. `/branch` reports `resume`.| `next(e)`
-`session.compact`| The conversation is about to be compacted| `{ skip: reason }`
-[`session.receive`](</docs/en/plugins/mods/api#send-and-receive-messages-between-sessions>), [`session.send`](</docs/en/plugins/mods/api#send-and-receive-messages-between-sessions>)| A message arrives from, or is about to go to, another agent or session. See [Send and receive messages between sessions](</docs/en/plugins/mods/api#send-and-receive-messages-between-sessions>).| `{ consumed: reason }` for `receive`, `{ isDelivered: false, reason }` for `send`
-`session.append`| Once for each row the conversation keeps, such as a prompt, a response block, a tool result, or a notice, before it’s stored| `next({ ...e, message })` with a changed `message.content`, to rewrite the row’s text blocks or the `content` of a `tool_result` block in it. You can’t rewrite a row that holds a [skill from an MCP server](</docs/en/mcp#use-skills-from-mcp-servers>). To change that skill’s text, hook `skill.prompt` instead.
-`session.attach`, `session.detach`| Another app connects to or disconnects from the session| `next(e)`
-`session.measure`| After each turn, and when a plan limit’s percent used changes| `next(e)`
-`session.stop`| The user stops Claude, such as with Esc during a turn. Requires Claude Code v2.1.326 or later.| `next(e)`
-
-### Subagents
-
-Subagent events fire when a subagent type is offered to Claude and when a subagent or an agent-team teammate is about to start:
-
-Event| Fires when| A hook can return
----|---|---
-`agent.offer`| A subagent type is offered to Claude| `{ isOffered: false }` to withhold it
-`agent.spawn`| A subagent or an [agent team](</docs/en/agent-teams>) teammate is about to start, or a subagent that finished or stopped is about to run again. For a teammate, `e.isTeammate` is `true`. For a resumed run, `e.resume` is set.| `next({ ...e, model })` to choose the model of one that is starting, or `{ deny: reason }`
+## Subagent starts
+
+`agent.spawn` fires when a subagent or an [agent team](</docs/en/agent-teams>) teammate is about to start. To choose the model of one that is starting, call `next({ ...e, model })`.
+
+### Resumed subagent runs
Your `agent.spawn` hook also runs when a subagent that finished or stopped is about to run again, such as when Claude sends it a message with the [`SendMessage`](</docs/en/sub-agents#resume-subagents>) tool. On that event, `e.resume` is `{ agentId }`. If your hook counts subagents, skip the events where `e.resume` is set, so a resumed subagent isn’t counted again. Return `{ deny: reason }` to refuse a resumed run. The run doesn’t start, and the subagent stays as it was. When a `SendMessage` call asked for the run, Claude reads `a plugin declined the resume:` followed by your reason as that call’s result. If you pass a changed event to `next` for a resumed run, such as a different `model`, Claude Code ignores the change.
The event for a resumed run requires Claude Code v2.1.299 or later. Before v2.1.299, your `agent.spawn` hook didn’t run when a subagent resumed. On those versions, to refuse the `SendMessage` calls that resume a subagent, match that tool in a [`tool.call`](</docs/en/plugins/mods/events#guard-or-change-a-tool-call>) hook.
-### Interface
-
-Interface events fire when Claude Code draws a render site and when the user uses a control a mod drew. [Draw in the interface](</docs/en/plugins/mods/interface>) shows what a `ui.render` hook returns:
-
-Event| Fires when
----|---
-[`ui.render`](</docs/en/plugins/mods/interface#pick-where-to-draw>)| A render site is about to be drawn
-`ui.resolve`| Mods load, once for each app, render site, and mod. The result is the element table that `$.ui.resolve(e)` reads.
-[`ui.press`](</docs/en/plugins/mods/interface#respond-to-presses-and-typing>), [`ui.input`](</docs/en/plugins/mods/interface#respond-to-presses-and-typing>), [`ui.select`](</docs/en/plugins/mods/interface#respond-to-presses-and-typing>)| A `Button`, `Input`, or `Select` a mod drew is used
-[`ui.pointer`](</docs/en/plugins/mods/interface#animate-a-backdrop-with-a-shader>)| The user clicks a part of your mod’s backdrop that the app doesn’t cover. Requires Claude Code v2.1.326 or later.
-`ui.focus`, `ui.scroll`| The focused control or the scroll position of a pane or the band is about to change
-`ui.close`| A pane is about to close. `e.id` is the pane and `e.origin.kind` is `plugin`, `person`, or `unload`.
-[`ui.message`](</docs/en/plugins/mods/interface#build-a-tree-from-elements>)| A `Client` element posts data to its mod
-[`ui.fault`](</docs/en/plugins/mods/interface#redraw-when-something-changes>)| A `Client` element your mod drew failed to load, draw, or run. `e.phase` is `load`, `render`, or `run`, and `e.reason` is the error message. Requires Claude Code v2.1.289 or later.
-
-### Other mods
-
-These events let a mod act on other mods as they load, to refuse one or change the mods API it receives:
-
-Event| Fires when| A hook can return
----|---|---
-[`plugin.register`](</docs/en/plugins/mods/admin#enforce-a-policy-with-a-mod-of-your-own>)| A hooks module is about to load, or, on v2.1.326 or later, a plugin without one. `e.uses` lists the module’s events, mods API calls, environment variables, and state, as `claude plugin validate` prints them. Each call is written without the `$.` prefix, such as `fs.read`.| `{ refuse: reason }`. On v2.1.326 or later, a refusal keeps out the whole plugin, and `next({ ...e, provides: { ...e.provides, modules: [] } })` keeps out only its hooks module. Earlier versions ignore `provides` and load the module.
-`engine.create`| The mods API is being built for this mod| A changed mods API, to add a namespace. A mod in the `prepend` or `append` tier can also withhold one.
-
-When another mod’s hook calls a method on a namespace you added in `engine.create`, your method’s `$` calls run in that hook’s context until every hook on that event returns. For example, a relative path resolves against that hook’s working directory, and `$.prompt.submit` rejects while the turn is waiting on that hook. Calls your method makes after that run in your mod’s own context.
-
-### Telemetry
-
-Telemetry events fire for the usage records Claude Code logs:
-
-Event| Fires when| A hook can return
----|---|---
-`telemetry.log`, `telemetry.mark`| A telemetry record is about to be logged, or one use of a feature is marked. In a mod you install, give a telemetry hook the filter `{ to: 'collector' }`, as in `on('telemetry.log', { to: 'collector' }, hook)`. Without the filter, the mod fails `claude plugin validate`. `*` doesn’t match these events.| `next(e)`, or `{ deny: reason }`
-
-### Settings hook events
-
-Each [settings hook event](</docs/en/hooks#hook-events>) is an event named `classic.<Event>`, such as `classic.Stop`. For the fields on `e`, see [Handle the settings hook events](</docs/en/plugins/mods/events#hook-the-settings-hook-events>).
-
-### Mods API calls
+## Mods API calls
Every mods API method is also an event, named for its namespace and method, such as `fs.read`, `model.complete`, or `ui.open`. A hook on one can return `next(e)`, `{ deny: reason }`, or `{ value }`. Some of these events also fire for Claude Code’s own actions, so check whether `next.origin.plugin` is `engine` before you refuse one.
-#### Fields on Claude Code’s own `http.fetch` requests
+### Fields on Claude Code’s own `http.fetch` requests
In an `http.fetch` hook, a `next.origin` of `{ plugin: 'engine', tier: 'core' }` marks one of Claude Code’s own requests, such as a model request, not a mod’s `$.http.fetch` call. Where the [built-in guard](</docs/en/plugins/mods/admin#know-what-happens-by-default>) is loaded, your hook doesn’t get these events unless your mod [counts as your organization’s](</docs/en/plugins/mods/admin#install-your-organizations-mods>). On these events, `e.init` and the `value` that `next(e)` resolves to can hold these fields, among others:
@@ -208,66 +65,46 @@
These events and fields require Claude Code v2.1.321 or later.
-## Mods API methods
-
-The mods API is the `$` argument every hook receives. Its methods are grouped in namespaces, such as `$.ui`. This table lists each namespace’s methods by name, so `open` in the `$.ui` row is the call `$.ui.open(...)`. The guides show the common ones in use, and [the types for your build](</docs/en/plugins/mods/create#get-the-types-for-your-build>) document every method with an example.
-
-Namespace| Methods
+## Skip other mods’ hooks with `next.to`
+
+To call `next.to`, your mod has to run in the `prepend` or `append` tier. To see who can put it there, check the scope of [`prependPlugins`](</docs/en/settings-reference#prependplugins>) or [`appendPlugins`](</docs/en/settings-reference#appendplugins>). The `to` entry under `type Next<` lists the tiers each one can skip to.
+
+## Namespaces you add
+
+When another mod’s hook calls a method on a namespace you added in `engine.create`, your method’s `$` calls run in that hook’s context until every hook on that event returns. For example, a relative path resolves against that hook’s working directory, and `$.prompt.submit` rejects while the turn is waiting on that hook. Calls your method makes after that run in your mod’s own context.
+
+## File writes
+
+`$.fs.write` isn’t atomic: it replaces the file’s content in place, so another process can read a partly written file. Keep data that several sessions change in `$.store`.
+
+## Render sites
+
+A render site is an extension point in Claude Code’s interface. Each row is a value of `e.component` in a `ui.render` hook, with the apps that render it. For a site’s `e.props`, search the type declarations. For the VS Code extension’s version requirements and differences, see [Draw in the VS Code extension](</docs/en/plugins/mods/interface#draw-in-the-vs-code-extension>).
+
+Site| Rendered on
---|---
-`$.plugin`| `name`, `root`: this plugin’s name and directory
-[`$.ui`](</docs/en/plugins/mods/interface#pick-where-to-draw>)| `resolve`, `invalidate`, `open`, `close`, `panes`, [`place`](</docs/en/plugins/mods/interface#place-a-row-in-the-transcript>), `focus`, `scroll`, `toast`, `notify`, `status`, `log`, `notice`, `ask`, `copy`, `selection`, `blit`, `view`. `view` requires Claude Code v2.1.300 or later and `place` v2.1.314 or later.
-[`$.theme`](</docs/en/plugins/mods/interface#put-a-backdrop-behind-the-conversation>)| `set`, `clear`: set a backdrop for the Desktop or mobile app to draw, and take the backdrop off. Requires Claude Code v2.1.319 or later. [Message styles](</docs/en/plugins/mods/interface#style-messages-in-the-desktop-app>) and [sound](</docs/en/plugins/mods/interface#add-sound-to-a-theme>) require v2.1.329 or later.
-[`$.command`](</docs/en/plugins/mods/api#add-a-command>)| `register`, `run`, `list`
-[`$.tool`](</docs/en/plugins/mods/api#add-a-tool>)| `register`, `call`, `check`, `list`
-`$.agent`| `register`, `spawn`, `call`, `list`, `limits`. `call` and `limits` require Claude Code v2.1.326 or later. `list()` returns this session’s subagents and teammates, each with a `status` of `pending`, `running`, `waiting`, `idle`, `completed`, `failed`, or `killed`, where `idle` and `waiting` require Claude Code v2.1.289 or later.
-[`$.model`](</docs/en/plugins/mods/api#call-a-model>)| `complete`, `fork`, `classify`
-[`$.prompt`](</docs/en/plugins/mods/api#start-a-turn-from-a-background-job>)| `submit`, `read`, `fill`, `suggest`, `compose`. Claude reads text from `submit({ text })` after a sentence that names your mod as the sender. `submit({ text, asUser: true })` sends the text as the user’s own words, without that sentence.
-`$.turn`| `abort`
-[`$.session`](</docs/en/plugins/mods/api#send-and-receive-messages-between-sessions>)| `messages`, `cwd`, `root`, `model`, `turns`, `id`, `repo`, `surfaces`, `usage`, `version`, `info`, `compact`, `send`, `append`, `authorize`, `redact`. `info` requires Claude Code v2.1.326 or later. `redact`, a best-effort mask for credentials only, requires v2.1.331 or later. `usage()` returns `{ startedAt, context, rateLimits, cost }`: `context` has `tokens`, `window`, and `percent`, and `rateLimits` is a list of `{ kind, percentUsed, resetsAt }`.
-`$.config`| `list`, `set`
-[`$.settings`](</docs/en/plugins/mods/api#reach-files-processes-and-the-network>)| `read`
-[`$.env`](</docs/en/plugins/mods/api#reach-files-processes-and-the-network>)| `get`, `set`. A refused `set` either rejects or resolves to `{ deny }`. The `{ deny }` result requires Claude Code v2.1.301 or later.
-[`$.fs`](</docs/en/plugins/mods/api#reach-files-processes-and-the-network>)| `read`, `write`, `list`, `exists`, `stat`, `ancestors`. `write` isn’t atomic: it replaces the file’s content in place, so another process can read a partly written file. Keep data that several sessions change in `$.store`.
-[`$.store`](</docs/en/plugins/mods/interface#keep-state>)| `get`, `set`, `delete`, `keys`. A key-value store that every session on the machine shares. See [Save from more than one session](</docs/en/plugins/mods/interface#save-from-more-than-one-session>).
-[`$.state`](</docs/en/plugins/mods/interface#keep-a-value-in-$-state>)| Reactive state: `get`, `set`, with the helpers `atom`, `read`, `update`, `derive`, and `memberOf` imported from `claude-code`
-[`$.clock`](</docs/en/plugins/mods/api#run-work-in-the-background>)| `now`, `sleep`, `after`, `every`
-[`$.http`](</docs/en/plugins/mods/api#reach-files-processes-and-the-network>)| `fetch`
-[`$.process`](</docs/en/plugins/mods/api#reach-files-processes-and-the-network>)| `run`, `spawn`, `hookEnv`. `hookEnv` requires Claude Code v2.1.326 or later.
-[`$.mcp`](</docs/en/plugins/mods/api#reach-files-processes-and-the-network>)| `call`, `connect`. `connect(server)` connects an MCP server that your own plugin’s manifest lists.
-[`$.wasm`](</docs/en/plugins/mods/api#reach-files-processes-and-the-network>)| `compile`. Requires Claude Code v2.1.326 or later.
-`$.audio`| `play`, `speak`
-`$.telemetry`| `log`, `mark`. A record is sent only when Claude Code or a built-in mod makes the call.
-
-In the terminal, `$.ui.view({ agentId })` shows an agent’s transcript and `$.ui.view({})` switches back. Call either from a command or button. A timer’s call resolves to `{ deny: 'not person-initiated' }`.
-
-## Render sites
-
-A render site is an extension point in Claude Code’s interface. Each row is a value of `e.component` in a `ui.render` hook, with the fields of `e.props` and the apps that render it. `e.surface` names the app that’s drawing, such as `terminal`, `desktop`, or `vscode`. [Change what Claude Code already draws](</docs/en/plugins/mods/interface#change-what-claude-code-already-draws>) shows what a hook can do at a site, with an example of each choice. Rendering in the VS Code extension requires extension version 2.1.299 or later. A session that [doesn’t fetch feature flags](</docs/en/env-vars#features-that-need-feature-flag-fetching>) needs 2.1.304 or later. [Draw in the VS Code extension](</docs/en/plugins/mods/interface#draw-in-the-vs-code-extension>) lists what the extension draws differently.
-
-Site| `e.props`| `e.requestId`| Rendered on
----|---|---|---
-[`Pane`](</docs/en/plugins/mods/interface#pick-where-to-draw>)| `title`, `isFocused`, `bodyColumns`, `placement`, `scroll`, `view`| The pane’s `id`| Terminal, Desktop, VS Code
-[`AbovePrompt`](</docs/en/plugins/mods/interface#pick-where-to-draw>)| `hasSurvey`, [`isCollapsed`](</docs/en/plugins/mods/interface#when-the-user-collapses-the-band>), `isWorking`, `maxRows`, `bodyColumns`, `scroll`, `view`| One instance| Terminal, Desktop, VS Code
-`AbovePromptList`, the stack of `AbovePrompt` rows| `rows`, a list with one `{ plugin, tree }` for each mod’s row, plus the `AbovePrompt` props| One instance| Terminal, Desktop, VS Code. Requires Claude Code v2.1.323 or later.
-`BesidePrompt`, a cell to the right of the prompt| `maxColumns`, `floatRows`, `floatColumns`, `isWorking`, `view`| One instance| Terminal in [fullscreen rendering](</docs/en/fullscreen>), Desktop. Requires Claude Code v2.1.331 or later.
-`Underlay`, a layer visible only where the interface is blank| `columns`, `rows`, `isWorking`, `view`| `site:underlay`| Terminal in fullscreen rendering. Requires Claude Code v2.1.331 or later.
-`BesidePromptList` and `UnderlayList`, the order of the `BesidePrompt` cells and `Underlay` layers| `plugins`| One instance| The same apps as the site it orders. Requires Claude Code v2.1.331 or later.
-[`Placed`](</docs/en/plugins/mods/interface#place-a-row-in-the-transcript>)| `id`, `plugin`, `onScreen`| The `requestId` that `$.ui.place` returned| Terminal
-[`Backdrop`](</docs/en/plugins/mods/interface#put-a-backdrop-behind-the-conversation>)| `scene`, `plugin`, `glass`, `overrideColorScheme`. Before v2.1.323, `scene` was `id` and `overrideColorScheme` was `colorScheme`.| `backdrop`| `desktop` and `mobile` surfaces. Your hook runs when the Desktop or mobile app asks to draw a backdrop.
-`UserMessage`| `text`, `origin`, `isExpanded`, and `task` or `from` by origin| The drawn row’s id| Terminal, Desktop, VS Code
-`AssistantMessage`| The reply’s text| The drawn row’s id| Terminal, Desktop, VS Code
-`ToolUse`, `ToolResult`, `ToolGroup`| The tool’s name, input, and result| The tool call id| Terminal, Desktop, VS Code
-`CommandOutput`| `command`, `text`| The drawn row’s id| Terminal, Desktop
-[`AskUserQuestion`](</docs/en/plugins/mods/interface#change-what-claude-code-already-draws>)| The question and options| The tool call id| Terminal, Desktop, VS Code
-`ToolProgress`| `kind`| The tool call id| Terminal
-[`Spinner`](</docs/en/plugins/mods/interface#change-what-claude-code-already-draws>)| `word`, `message`, `suffix`, `mode`| The agent id| Terminal, Desktop, VS Code
-`TurnDuration`| `word`, `durationMs`| The drawn row’s id| Terminal
-`InfoNotice`| `text`, `command`| The notice’s `text` prefixed with `notice:`| Terminal
-`SessionMode`| `modes`| One instance| Terminal, Desktop
-`PromptHint`| `isDraft`, `isWorking`, `hint`| One instance| Terminal, Desktop
-`AgentRow`| The agent’s [`$.agent.list()` fields](</docs/en/plugins/mods/create#get-the-types-for-your-build>), plus `rowIds`, `columns`, `body`, and `isHidden`| The agent id| Terminal and VS Code’s [Focus view](</docs/en/vs-code#extension-settings>). Requires v2.1.326 or later of Claude Code or the extension.
-
-`e.viewport` holds `columns`, `rows`, and `isFullscreen`. In the terminal and the Desktop app, it’s absent until the app has measured its window. There, its `rows` is the height of the whole window, not of your pane. In the VS Code extension, it’s always present. To fit a tree to its site, read these props in the hook:
+[`Pane`](</docs/en/plugins/mods/interface#pick-where-to-draw>)| Terminal, Desktop, VS Code
+[`AbovePrompt`](</docs/en/plugins/mods/interface#pick-where-to-draw>)| Terminal, Desktop, VS Code
+`AbovePromptList`, the stack of `AbovePrompt` rows| Terminal, Desktop, VS Code. Requires Claude Code v2.1.323 or later.
+`BesidePrompt`, a cell to the right of the prompt| Terminal in [fullscreen rendering](</docs/en/fullscreen>), Desktop. Requires Claude Code v2.1.331 or later.
+`Underlay`, a layer visible only where the interface is blank| Terminal in fullscreen rendering. Requires Claude Code v2.1.331 or later.
+`BesidePromptList` and `UnderlayList`, the order of the `BesidePrompt` cells and `Underlay` layers| The same apps as the site it orders. Requires Claude Code v2.1.331 or later.
+[`Placed`](</docs/en/plugins/mods/interface#place-a-row-in-the-transcript>)| Terminal
+[`Backdrop`](</docs/en/plugins/mods/interface#put-a-backdrop-behind-the-conversation>)| `desktop` and `mobile` surfaces. Your hook runs when the Desktop or mobile app asks to draw a backdrop.
+`UserMessage`| Terminal, Desktop, VS Code
+`AssistantMessage`| Terminal, Desktop, VS Code
+`ToolUse`, `ToolResult`, `ToolGroup`| Terminal, Desktop, VS Code
+`CommandOutput`| Terminal, Desktop
+[`AskUserQuestion`](</docs/en/plugins/mods/interface#change-what-claude-code-already-draws>)| Terminal, Desktop, VS Code
+`ToolProgress`| Terminal
+[`Spinner`](</docs/en/plugins/mods/interface#change-what-claude-code-already-draws>)| Terminal, Desktop, VS Code
+`TurnDuration`| Terminal
+`InfoNotice`| Terminal
+`SessionMode`| Terminal, Desktop
+`PromptHint`| Terminal, Desktop
+`AgentRow`| Terminal and VS Code’s [Focus view](</docs/en/vs-code#extension-settings>). Requires v2.1.326 or later of Claude Code or the extension.
+
+`e.viewport` holds `columns`, `rows`, and `isFullscreen`. In the terminal and the Desktop app, it’s absent until the app has measured its window. There, its `rows` is the height of the whole window. To fit a tree to its site, read these props in the hook:
* **Width of a`Pane` or the band**: draw to `e.props.bodyColumns`
* **Height of a`Pane` beside the transcript**: where `e.props.placement` is `'dock'`, `e.props.scroll.bodyRows` is the number of rows the pane has for your tree
@@ -277,43 +114,15 @@
## Elements
-Elements are the building blocks of a tree a `ui.render` hook returns, and you get them from `$.ui.resolve(e)`. [Build a tree from elements](</docs/en/plugins/mods/interface#build-a-tree-from-elements>) shows the common ones with how the terminal draws them, and the [interface gallery](</docs/en/plugins/mods/gallery>) has screenshots of most. A check mark means the app can draw the element.
-
-Element| Main props| Terminal| Desktop| VS Code
----|---|---|---|---
-[`Box`](</docs/en/plugins/mods/interface#build-a-tree-from-elements>)| `key`, flex layout, `gap`, `padding`, `margin`, `width`, `height`, `minWidth`, `minHeight`, `borderStyle`, `borderColor`, `borderDimColor`, `backgroundColor`, `position`, `top`, `left`, `right`, `bottom`, `overflow`, `display`, `hover`| ✓| ✓| ✓
-[`Text`](</docs/en/plugins/mods/interface#build-a-tree-from-elements>)| `color`, `backgroundColor`, `bold`, `italic`, `underline`, `strikethrough`, `dimColor`, `inverse`, `wrap`, `size`, `weight`, `mono`, `tabular`, `hover`| ✓| ✓| ✓
-[`Button`](</docs/en/plugins/mods/interface#respond-to-presses-and-typing>)| `key`, `label`, `children`, `onPress`, `hotkey`, `plain`, `dimColor`, `autoFocus`, `action`, `variant`, `role`, `hover`| ✓| ✓| ✓
-[`Link`](</docs/en/plugins/mods/interface#link-in-the-desktop-app>)| `href`, `label`. See Limits.| ✓| ✓| ✓
-[`Code`](</docs/en/plugins/mods/gallery#show-code-and-changes>)| `source`, `language`, `path`, `startLine`, `format`, `wrap`| ✓| ✓| ✓
-`Markdown`| `text`, `key`, `dimColor`, `onLinkPress`, `pressableLinks`| ✓| ✓| ✓
-[`Input`](</docs/en/plugins/mods/interface#take-typed-input-and-draw-a-row-for-each-item>)| `key`, `label`, `placeholder`, `value`, `submitLabel`, [`rows`](</docs/en/plugins/mods/gallery#input>), `onSubmit`, `onInput`, `autoFocus`| ✓| ✓| ✓
-`Select`| `key`, `label`, `options`, `value`, `onSelect`, `autoFocus`| ✓| ✓| ✓
-`Svg`| a `source` of SVG markup up to 131,072 characters, `alt` text, `width`, `height`, and `isInteractive`| | ✓| ✓
-[`Shader`](</docs/en/plugins/mods/interface#animate-a-backdrop-with-a-shader>)| `module`, `values`, and one `Svg` child. Draws in a `Backdrop` only. Requires Claude Code v2.1.326 or later.| | ✓|
-[`Client`](</docs/en/plugins/mods/interface#build-a-tree-from-elements>)| `module`, `key`, `props`, `width`, `height`, `flexGrow`| ✓| ✓|
-[`Raster`](</docs/en/plugins/mods/interface#draw-a-grid-of-colored-cells>)| `key`, `columns` up to 512, `rows` up to 256, `cells`. See [Draw a grid of colored cells](</docs/en/plugins/mods/interface#draw-a-grid-of-colored-cells>).| ✓| |
-`Image`| `key`, a `source` such as PNG or RGBA bytes up to 2 MiB, or a file path, `columns` and `rows` up to 255, and `alt` text. See [which terminals draw it](</docs/en/plugins/mods/gallery#image-and-client>).| ✓| |
-
-More `Button` rules:
-
- * **`action`** : names one of Claude Code’s own [keybinding actions](</docs/en/keybindings>), and the user’s binding for it presses the button when that binding is a chord or a modified key
- * **Digit hotkeys on the band** : a digit `hotkey` on a button in the band also fires when the user types that digit alone into an empty prompt and pauses
- * **A collapsed band** : while the band is [collapsed](</docs/en/plugins/mods/interface#when-the-user-collapses-the-band>), neither an `action` binding nor a hotkey presses a button in it
- * **Two buttons on one hotkey** : when two of your buttons in one drawing name the same `hotkey`, the later one gets it. For another mod’s button on the same key, see [Hotkeys do nothing](</docs/en/plugins/mods/troubleshoot#hotkeys-do-nothing>).
- * **`variant`** : `primary` or `secondary`, and any other value throws. In the terminal, a `primary` button draws in the accent color unless it’s `plain`.
- * **`role`** : `dismiss` marks a close button, and any other value throws. Do the closing in your `onPress`. In a band that holds text and a row of buttons, the Desktop app can draw the row’s first `dismiss` button as its own close control. The terminal draws the button as it would without `role`.
-
-A `Button` can hold `children` in place of a `label`:
-
- * **What children can be** : strings and `Text` elements, such as a name followed by a dim detail or a colored chip. Claude Code refuses any other element inside a `Button`.
- * **Naming the button** : the `label` names the button and defaults to the text of its children. Give a button with children other than one string a `key` or a `label`.
- * **In the terminal** : the children draw where the label would be, and a press anywhere on them counts as one press, so you can make each row of a list a single button
- * **In the Desktop app and the VS Code extension** : the button draws its `label`
-
-A `Button` with children other than a single string requires Claude Code v2.1.295 or later.
-
-`autoFocus` accepts only `true` on any control, so omit the prop to leave it off. The VS Code extension ignores some element props and draws the element as if you had left them out:
+Elements are the building blocks of a tree a `ui.render` hook returns. For the main elements and the apps that draw them, see [Build a tree from elements](</docs/en/plugins/mods/interface#build-a-tree-from-elements>). For an element’s props, search the type declarations.
+
+### Buttons with children in the Desktop app and VS Code
+
+For a `Button` that holds `children`, the Desktop app and the VS Code extension draw its `label` in place of the children. To choose that text, set `label`, which otherwise defaults to the text of the children. A `Button` with children other than a single string requires Claude Code v2.1.295 or later.
+
+### Props the VS Code extension ignores
+
+The VS Code extension ignores some element props and draws the element as if you had left them out:
* **`Box`** : `position` with its `top`, `left`, `right`, and `bottom`, `alignSelf`, `borderDimColor`, and `hover`
* **`Text`** : `size`, `mono`, `tabular`, and `hover`
@@ -321,6 +130,8 @@
* **`Code`** : `language`, `path`, `startLine`, `format`, and `wrap`, so code draws without colors or line numbers, and a `format: 'diff'` block shows the diff’s raw text
* **`Input` and `Select`**: `autoFocus`, and `rows` on an `Input`
* **`Svg`** : `isInteractive`
+
+The terminal also ignores `size`, `mono`, and `tabular` on a `Text`.
### `Box` border styles
@@ -340,37 +151,6 @@
`'quote'`| A bar, `▎`, down the left side and blank cells on the other three sides| Blank
A `Box` whose `borderStyle` names anything else, such as `'rounded'`, draws with no border.
-
-### `Box` spacing steps
-
-The `Box` spacing props are `gap`, `columnGap`, `rowGap`, `padding`, `margin`, and the one-side and one-axis forms of `padding` and `margin`, such as `paddingX` and `marginTop`. Each takes a number of terminal cells such as `gap: 1`, or a step name such as `gap: 'md'`. In the terminal and the VS Code extension, each step is this many cells:
-
-Step| Cells across| Cells down
----|---|---
-`'xs'`| 1| 0
-`'sm'`| 1| 0
-`'md'`| 2| 1
-`'lg'`| 3| 1
-`'xl'`| 4| 2
-
-If you set `gap`, `padding`, or `margin` to a step, the step applies across and down at once. For example, in the terminal and the VS Code extension, `padding: 'md'` is two cells at each side and one row above and below. Step names require Claude Code v2.1.299 or later. On an earlier release, a tree that uses a step name doesn’t draw.
-
-### `Text` typography props
-
-Set `size`, `weight`, `mono`, or `tabular` on a `Text` to ask the app drawing your tree for a text size, a weight, a monospaced typeface, or equal-width digits. Before you rely on a prop, check what the terminal and the VS Code extension do with it. If an app ignores a prop you set, your tree still draws there, with the text as if you’d left that prop out.
-
-Prop| Values| In the terminal| In the VS Code extension
----|---|---|---
-`size`| `'caption'`, `'footnote'`, `'body'`, `'heading'`, or `'title'`| Ignored: the terminal has one text size| Ignored
-`weight`| `'regular'`, `'medium'`, `'semibold'`, or `'bold'`| `semibold` and `bold` draw as bold text| `semibold` and `bold` draw as bold text
-`mono`| `true` to ask for the app’s monospaced typeface| Ignored: the terminal is always monospaced| Ignored, so text keeps the extension’s own typeface
-`tabular`| `true` to ask for digits of equal width, so that a number that updates in place or a column of numbers stays aligned| Ignored: the terminal’s digits are already one cell wide| Ignored
-
-These four props require Claude Code v2.1.299 or later. On an earlier release, a tree that sets `size`, `weight`, `mono`, or `tabular` doesn’t draw.
-
-#### Replace `bold` with `weight`
-
-`bold` on a `Text` is deprecated in favor of `weight` and still works. To replace it on a `Text` with no `weight`, change `bold: true` to `weight: 'semibold'` for the same result on Claude Code v2.1.299 or later. On a release earlier than v2.1.299, a tree that sets `weight` doesn’t draw. If you set both `bold` and `weight` on a `Text`, `bold` has no effect.
## Limits
@@ -400,6 +180,9 @@
Depth and size of a tree counted with its prop values| Claude Code refuses anything `nested more than 100 lists and objects deep` or with `more than 1000000 values once written out`. Requires Claude Code v2.1.326 or later.
Elements and text children in one tree| 20,000
`Raster` cells in one tree, each `Raster`’s `columns` times its `rows`| 262,144
+One `Raster`| 512 columns and 256 rows
+One `Image`| 255 columns and 255 rows
+One `Svg`’s `source`| 131,072 characters
The rows above the prompt, stacked| Elements, `Raster` cells, and `Image` bytes add up across the rows, against the limits for one tree
PNG or RGBA bytes of all the `Image`s in one tree| 2 MiB
`$.store`| 4 MiB of JSON in total
@@ -421,32 +204,10 @@
Command, tool, subagent type, and pane names, the `id` of a placed row, and the `scene` of a backdrop| Letters, digits, `_`, and `-`, up to 64 characters
One `claude plugin test` test| 5 seconds unless the test sets `timeoutMs`
-## Settings and environment variables
-
-These are the settings and environment variables that affect mods. The Where column says which settings file or environment each one is read from:
-
-Name| Where| What it does
----|---|---
-`CLAUDE_CODE_PLUGIN_DIRS`| Environment, or `env` in `~/.claude/settings.json`| Plugin directories to load as `--plugin-dir` does, for apps you can’t pass a flag to. Absolute paths separated by `:`, or `;` on Windows.
-`CLAUDE_CODE_PLUGIN_DIR_WATCH`| Environment| Whether mods reload on save. See the [environment variables reference](</docs/en/env-vars>) for the defaults and values
-`prependPlugins`, `appendPlugins`| Managed settings. User settings only on a machine with no managed settings or [`managed-mcp.json`](</docs/en/managed-mcp#deploy-managed-mcp-json>) file, in a session whose credential isn’t a Team or Enterprise `/login`.| Lists of plugin ids, such as `acme-guard@acme-tools`. Mods in `prependPlugins` run before every mod a user installs, and mods in `appendPlugins` run after, in the listed order. See [The order mods run in](</docs/en/plugins/mods/events#the-order-mods-run-in>).
-`allowManagedModsOnly`| Managed settings, as an [option on the built-in guard](</docs/en/plugins/mods/admin#set-options-on-the-built-in-guard>)| Only mods that [count as your organization’s](</docs/en/plugins/mods/admin#install-your-organizations-mods>), and mods built into Claude Code, run their hooks. Users’ settings hooks keep running.
-`allowModsToOverrideDenyRules`| Managed settings, as an [option on the built-in guard](</docs/en/plugins/mods/admin#set-options-on-the-built-in-guard>)| Lets a mod a user installed approve a tool call past most of [the outcomes that stay in place by default](</docs/en/permissions#precedence-among-rules-hooks-and-mods>), including a `deny` rule
-`allowManagedHooksOnly`| Managed settings| Blocks hooks and installed mods that aren’t your organization’s. See [what keeps running](</docs/en/settings-reference#what-runs-under-allowmanagedhooksonly>).
-`disableAllHooks`| Any settings file| In managed settings, no mod or hook from an installed plugin runs. In your own settings, what your organization manages keeps running. See [`disableAllHooks`](</docs/en/settings-reference#disableallhooks>).
-`disableSideloadFlags`| Managed settings| Rejects `--plugin-dir` and `--plugin-url` at startup
-`pluginConfigs`| User or managed settings| Holds `userConfig` values for a mod, keyed by the plugin’s id, such as `acme-guard@acme-tools`, or its name and `@inline`, such as `first-mod@inline`, for one loaded with `--plugin-dir`
-
-`sec-default@builtin` is a guard built into Claude Code, listed as `cc-plugin-sec-default` in `/plugin` and the debug log. [Where it loads](</docs/en/plugins/mods/admin#know-what-happens-by-default>), it runs ahead of every mod a person installs. If managed `prependPlugins` is set, the guard loads only when that list names it, at the position listed. Its source is in the [`mods/sec-default` directory of the Claude Code repository](<https://github.com/anthropics/claude-code/tree/main/mods/sec-default>).
-
-## Commands
-
-These commands and flags load, inspect, and test a mod. The `claude` commands run in your shell and the `/` commands at the Claude Code prompt. In the table, `<directory>` stands for a path you type, as in `claude plugin validate ./first-mod`. Square brackets mark an optional argument.
-
-Command| What it does
----|---
-[`/plugin`](</docs/en/plugins/mods/overview#see-which-mods-a-session-loaded>)| Shows a line such as `1 mod active · first-mod` under its tabs when a mod that isn’t built in has loaded
-[`claude plugin validate <directory>`](</docs/en/plugins/mods/create#check-what-claude-code-reads-from-your-mod>)| Reads a plugin’s manifest and hooks module and reports errors, the events it handles, and the mods API calls it makes. `--strict` treats warnings as errors and `--json` prints a machine-readable report.
-[`claude plugin test [directory]`](</docs/en/plugins/mods/test#write-a-test>)| Runs every file under the directory, or the current directory when you give none, whose name ends in `.test.ts` or `.test.tsx`. Exits with status 1 when a test fails.
-[`claude --plugin-dir <directory>`](</docs/en/plugins/mods/create#write-a-mod-yourself>)| Loads a plugin directory for one session. In an interactive terminal session, reloads the hooks module when you save. Repeat the flag to load several.
-`/reload-plugins`| Reloads plugins when you run it
+## Related resources
+
+ * [React to events](</docs/en/plugins/mods/events>) and [Draw in the interface](</docs/en/plugins/mods/interface>): examples of the common events and elements
+ * [Manage mods for your organization](</docs/en/plugins/mods/admin>): the managed settings that control mods
+ * [Plugin and skill settings](</docs/en/settings-reference#plugins-and-skills>): scope and type for keys such as `prependPlugins` and `pluginConfigs`
+ * [Environment variables](</docs/en/env-vars>): variables such as `CLAUDE_CODE_PLUGIN_DIRS` and `CLAUDE_CODE_PLUGIN_DIR_WATCH`
+ * [Plugin CLI reference](</docs/en/plugins/cli-reference>): commands such as `claude plugin validate` and `claude plugin test`
--- a/reference.md
+++ b/reference.md
@@ -408,6 +408,9 @@
`$.ui.invalidate('ui.render')` redraws| Throttled to 10 a second, or 30 in the terminal for the visible pane, the expanded band, and the hint line under the prompt. Calls that come sooner are coalesced.
[`ui.pointer`](</docs/en/plugins/mods/interface#animate-a-backdrop-with-a-shader>) clicks| Two a second. The app drops the rest.
A [`Shader`](</docs/en/plugins/mods/interface#animate-a-backdrop-with-a-shader>)’s `values`| Eight numbers
+Nested tags in a [backdrop](</docs/en/plugins/mods/interface#put-a-backdrop-behind-the-conversation>) `Svg`’s `source` in the Desktop app| 128 levels, counting the root `<svg>`. Quote every attribute value, or tags that aren’t nested can count as levels. Past the limit, the `Svg` isn’t drawn.
+Elements in a backdrop `Svg`’s `source` in the Desktop app| 512 filter elements whose names start with `fe`, such as `<feOffset>` or `<feMergeNode>`, and 256 `<pattern>`, `<mask>`, `<clipPath>`, and `<marker>` elements combined. Past either limit, the `Svg` isn’t drawn.
+Deepest level of nested tags times a link count in a backdrop `Svg`’s `source` in the Desktop app| 4,096, counting the root `<svg>` as a level. The link count is the total of `<use>`, `<pattern>`, `<mask>`, `<clipPath>`, and `<marker>` elements, capped at the number of `id` attributes. Past the limit, the `Svg` isn’t drawn.
`$.ui.toast`| Shown for 4 seconds unless you pass `{ timeoutMs }`. In the [classic renderer](</docs/en/fullscreen#enable-fullscreen-rendering>), a mod’s newer toast can [take the place of its older one](</docs/en/plugins/mods/troubleshoot#a-toast-doesn%E2%80%99t-appear>) that’s showing or waiting to show.
A pane opened without the user asking| Placed from 144 terminal columns, 110 after they’ve opened it once
Rows from `$.ui.place` that one mod has in a conversation at one time| 500\. At the limit, a call with a new `id` resolves to `{ isPlaced: false, reason: 'a plugin holds at most 500 placed rows' }`.
Show diff (131 lines)
--- a/reference.md
+++ b/reference.md
@@ -23,7 +23,7 @@
Argument| What it is
---|---
[`$`](</docs/en/plugins/mods/events#how-a-hook-handles-an-event>)| The mods API: every method in mods API methods. Write each call in full, namespace then method, as in `$.fs.read('notes.md')`.
-[`e`](</docs/en/plugins/mods/events#how-a-hook-handles-an-event>)| The event’s input, as deeply frozen plain data. To change it, pass a copy to `next`.
+[`e`](</docs/en/plugins/mods/events#how-a-hook-handles-an-event>)| The event’s input. To change it, pass a copy to `next`.
[`next(e)`](</docs/en/plugins/mods/events#how-a-hook-handles-an-event>)| The next handler, as in middleware. Runs the hooks after this one, then Claude Code’s behavior. Resolves to the event’s result.
[`next.signal`](</docs/en/plugins/mods/api#stop-background-work>)| An `AbortSignal` that aborts when the event is abandoned
`next.origin`| `{ plugin, tier }` of whoever fired the event. Claude Code itself is `{ plugin: 'engine', tier: 'core' }`. A mod’s `tier` is its priority group in the [order mods run in](</docs/en/plugins/mods/events#the-order-mods-run-in>): `prepend`, `user`, `append`, or `builtin`.
@@ -47,6 +47,7 @@
`tool.judge`| [Auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>) is about to ask its classifier about a call. Requires Claude Code v2.1.326 or later.| `next(e)` or `{ decision }`
`tool.run`| An allowed call is about to run. Requires Claude Code v2.1.326 or later.| `next(e)`, `{ deny: reason }`, or `{ result }`
`tool.describe`| Once for each tool, when its description is first sent to Claude. A second time for an MCP tool when Claude loads it through [tool search](</docs/en/mcp#scale-with-mcp-tool-search>), with `e.description` set to the text Claude reads for the loaded tool.| `{ description }`, optionally with `isDeferred` set to `true` to put the tool behind tool search or `false` to load it upfront. Add `breakPromptCache: true` to send a changed description on the next turn.
+`tool.offer`| Claude Code builds Claude’s tool list, and again when Claude calls a tool. Requires Claude Code v2.1.328 or later.| `next(e)`, or `{ isOffered: false }` to withhold the tool from Claude. See Send a changed tool list.
#### Agent and organization fields on `tool.check`
@@ -97,6 +98,10 @@
To change a section or a tool description in a running conversation, call `$.ui.invalidate('prompt.section')` or `$.ui.invalidate('tool.describe')` so your hook runs again. Return `{ text, breakPromptCache: true }` or `{ description, breakPromptCache: true }` from it. Without the field, Claude keeps reading the text [saved with the conversation](</docs/en/cli-reference#system-prompt-flags-in-resumed-conversations>) for a section or a tool loaded upfront until a new conversation or a [compaction](</docs/en/prompt-caching#compacting-the-conversation>). The changed text reaches Claude on the next turn, and the [prompt cache](</docs/en/prompt-caching>) starts over, so that turn is slower and more expensive. The field requires Claude Code v2.1.321 or later. From v2.1.299 until v2.1.321, a running conversation got the changed text on the next turn.
+#### Send a changed tool list
+
+To change the main conversation’s tool list, call `$.ui.invalidate('tool.offer')` and return `{ isOffered, breakPromptCache: true }` from your `tool.offer` hook. The [prompt cache](</docs/en/prompt-caching>) then starts over. Requires Claude Code v2.1.331 or later.
+
### Commands and configuration
Event| Fires when| A hook can return
@@ -120,7 +125,7 @@
---|---|---
[`turn.start`](</docs/en/plugins/mods/events#follow-a-turn>)| A turn begins| `next(e)`
[`turn.step`](</docs/en/plugins/mods/events#follow-a-turn>)| One request is about to go to the model| `yield* next(e)`, or `next({ ...e, model })`, `next({ ...e, effort })`
-[`turn.complete`](</docs/en/plugins/mods/events#follow-a-turn>)| A turn ended| `next(e)`, or `{ text }` to show a line under the answer
+[`turn.complete`](</docs/en/plugins/mods/events#follow-a-turn>)| A turn ended| `next(e)`, or `{ text }` to show a line under the main conversation’s answer
### Session
@@ -159,6 +164,7 @@
[`ui.render`](</docs/en/plugins/mods/interface#pick-where-to-draw>)| A render site is about to be drawn
`ui.resolve`| Mods load, once for each app, render site, and mod. The result is the element table that `$.ui.resolve(e)` reads.
[`ui.press`](</docs/en/plugins/mods/interface#respond-to-presses-and-typing>), [`ui.input`](</docs/en/plugins/mods/interface#respond-to-presses-and-typing>), [`ui.select`](</docs/en/plugins/mods/interface#respond-to-presses-and-typing>)| A `Button`, `Input`, or `Select` a mod drew is used
+[`ui.pointer`](</docs/en/plugins/mods/interface#animate-a-backdrop-with-a-shader>)| The user clicks a part of your mod’s backdrop that the app doesn’t cover. Requires Claude Code v2.1.326 or later.
`ui.focus`, `ui.scroll`| The focused control or the scroll position of a pane or the band is about to change
`ui.close`| A pane is about to close. `e.id` is the pane and `e.origin.kind` is `plugin`, `person`, or `unload`.
[`ui.message`](</docs/en/plugins/mods/interface#build-a-tree-from-elements>)| A `Client` element posts data to its mod
@@ -210,17 +216,17 @@
---|---
`$.plugin`| `name`, `root`: this plugin’s name and directory
[`$.ui`](</docs/en/plugins/mods/interface#pick-where-to-draw>)| `resolve`, `invalidate`, `open`, `close`, `panes`, [`place`](</docs/en/plugins/mods/interface#place-a-row-in-the-transcript>), `focus`, `scroll`, `toast`, `notify`, `status`, `log`, `notice`, `ask`, `copy`, `selection`, `blit`, `view`. `view` requires Claude Code v2.1.300 or later and `place` v2.1.314 or later.
-[`$.theme`](</docs/en/plugins/mods/interface#put-a-backdrop-behind-the-conversation>)| `set`, `clear`: set a backdrop for the Desktop or mobile app to draw, and take the backdrop off. Requires Claude Code v2.1.319 or later.
+[`$.theme`](</docs/en/plugins/mods/interface#put-a-backdrop-behind-the-conversation>)| `set`, `clear`: set a backdrop for the Desktop or mobile app to draw, and take the backdrop off. Requires Claude Code v2.1.319 or later. [Message styles](</docs/en/plugins/mods/interface#style-messages-in-the-desktop-app>) and [sound](</docs/en/plugins/mods/interface#add-sound-to-a-theme>) require v2.1.329 or later.
[`$.command`](</docs/en/plugins/mods/api#add-a-command>)| `register`, `run`, `list`
[`$.tool`](</docs/en/plugins/mods/api#add-a-tool>)| `register`, `call`, `check`, `list`
`$.agent`| `register`, `spawn`, `call`, `list`, `limits`. `call` and `limits` require Claude Code v2.1.326 or later. `list()` returns this session’s subagents and teammates, each with a `status` of `pending`, `running`, `waiting`, `idle`, `completed`, `failed`, or `killed`, where `idle` and `waiting` require Claude Code v2.1.289 or later.
[`$.model`](</docs/en/plugins/mods/api#call-a-model>)| `complete`, `fork`, `classify`
[`$.prompt`](</docs/en/plugins/mods/api#start-a-turn-from-a-background-job>)| `submit`, `read`, `fill`, `suggest`, `compose`. Claude reads text from `submit({ text })` after a sentence that names your mod as the sender. `submit({ text, asUser: true })` sends the text as the user’s own words, without that sentence.
`$.turn`| `abort`
-[`$.session`](</docs/en/plugins/mods/api#send-and-receive-messages-between-sessions>)| `messages`, `cwd`, `root`, `model`, `turns`, `id`, `repo`, `surfaces`, `usage`, `version`, `info`, `compact`, `send`, `append`, `authorize`. `info` requires Claude Code v2.1.326 or later. `usage()` returns `{ startedAt, context, rateLimits, cost }`: `context` has `tokens`, `window`, and `percent`, and `rateLimits` is a list of `{ kind, percentUsed, resetsAt }`.
+[`$.session`](</docs/en/plugins/mods/api#send-and-receive-messages-between-sessions>)| `messages`, `cwd`, `root`, `model`, `turns`, `id`, `repo`, `surfaces`, `usage`, `version`, `info`, `compact`, `send`, `append`, `authorize`, `redact`. `info` requires Claude Code v2.1.326 or later. `redact`, a best-effort mask for credentials only, requires v2.1.331 or later. `usage()` returns `{ startedAt, context, rateLimits, cost }`: `context` has `tokens`, `window`, and `percent`, and `rateLimits` is a list of `{ kind, percentUsed, resetsAt }`.
`$.config`| `list`, `set`
[`$.settings`](</docs/en/plugins/mods/api#reach-files-processes-and-the-network>)| `read`
-[`$.env`](</docs/en/plugins/mods/api#reach-files-processes-and-the-network>)| `get`, `set`
+[`$.env`](</docs/en/plugins/mods/api#reach-files-processes-and-the-network>)| `get`, `set`. A refused `set` either rejects or resolves to `{ deny }`. The `{ deny }` result requires Claude Code v2.1.301 or later.
[`$.fs`](</docs/en/plugins/mods/api#reach-files-processes-and-the-network>)| `read`, `write`, `list`, `exists`, `stat`, `ancestors`. `write` isn’t atomic: it replaces the file’s content in place, so another process can read a partly written file. Keep data that several sessions change in `$.store`.
[`$.store`](</docs/en/plugins/mods/interface#keep-state>)| `get`, `set`, `delete`, `keys`. A key-value store that every session on the machine shares. See [Save from more than one session](</docs/en/plugins/mods/interface#save-from-more-than-one-session>).
[`$.state`](</docs/en/plugins/mods/interface#keep-a-value-in-$-state>)| Reactive state: `get`, `set`, with the helpers `atom`, `read`, `update`, `derive`, and `memberOf` imported from `claude-code`
@@ -232,6 +238,8 @@
`$.audio`| `play`, `speak`
`$.telemetry`| `log`, `mark`. A record is sent only when Claude Code or a built-in mod makes the call.
+In the terminal, `$.ui.view({ agentId })` shows an agent’s transcript and `$.ui.view({})` switches back. Call either from a command or button. A timer’s call resolves to `{ deny: 'not person-initiated' }`.
+
## Render sites
A render site is an extension point in Claude Code’s interface. Each row is a value of `e.component` in a `ui.render` hook, with the fields of `e.props` and the apps that render it. `e.surface` names the app that’s drawing, such as `terminal`, `desktop`, or `vscode`. [Change what Claude Code already draws](</docs/en/plugins/mods/interface#change-what-claude-code-already-draws>) shows what a hook can do at a site, with an example of each choice. Rendering in the VS Code extension requires extension version 2.1.299 or later. A session that [doesn’t fetch feature flags](</docs/en/env-vars#features-that-need-feature-flag-fetching>) needs 2.1.304 or later. [Draw in the VS Code extension](</docs/en/plugins/mods/interface#draw-in-the-vs-code-extension>) lists what the extension draws differently.
@@ -239,8 +247,11 @@
Site| `e.props`| `e.requestId`| Rendered on
---|---|---|---
[`Pane`](</docs/en/plugins/mods/interface#pick-where-to-draw>)| `title`, `isFocused`, `bodyColumns`, `placement`, `scroll`, `view`| The pane’s `id`| Terminal, Desktop, VS Code
-[`AbovePrompt`](</docs/en/plugins/mods/interface#pick-where-to-draw>)| `hasSurvey`, [`isCollapsed`](</docs/en/plugins/mods/interface#when-the-user-collapses-the-band>), `isWorking`, `maxRows`, `bodyColumns`, `scroll`, `view`| One instance| Terminal, Desktop
-`AbovePromptList`, the stack of `AbovePrompt` rows| `rows`, a list with one `{ plugin, tree }` for each mod’s row, plus the `AbovePrompt` props| One instance| Terminal, Desktop. Requires Claude Code v2.1.323 or later.
+[`AbovePrompt`](</docs/en/plugins/mods/interface#pick-where-to-draw>)| `hasSurvey`, [`isCollapsed`](</docs/en/plugins/mods/interface#when-the-user-collapses-the-band>), `isWorking`, `maxRows`, `bodyColumns`, `scroll`, `view`| One instance| Terminal, Desktop, VS Code
+`AbovePromptList`, the stack of `AbovePrompt` rows| `rows`, a list with one `{ plugin, tree }` for each mod’s row, plus the `AbovePrompt` props| One instance| Terminal, Desktop, VS Code. Requires Claude Code v2.1.323 or later.
+`BesidePrompt`, a cell to the right of the prompt| `maxColumns`, `floatRows`, `floatColumns`, `isWorking`, `view`| One instance| Terminal in [fullscreen rendering](</docs/en/fullscreen>), Desktop. Requires Claude Code v2.1.331 or later.
+`Underlay`, a layer visible only where the interface is blank| `columns`, `rows`, `isWorking`, `view`| `site:underlay`| Terminal in fullscreen rendering. Requires Claude Code v2.1.331 or later.
+`BesidePromptList` and `UnderlayList`, the order of the `BesidePrompt` cells and `Underlay` layers| `plugins`| One instance| The same apps as the site it orders. Requires Claude Code v2.1.331 or later.
[`Placed`](</docs/en/plugins/mods/interface#place-a-row-in-the-transcript>)| `id`, `plugin`, `onScreen`| The `requestId` that `$.ui.place` returned| Terminal
[`Backdrop`](</docs/en/plugins/mods/interface#put-a-backdrop-behind-the-conversation>)| `scene`, `plugin`, `glass`, `overrideColorScheme`. Before v2.1.323, `scene` was `id` and `overrideColorScheme` was `colorScheme`.| `backdrop`| `desktop` and `mobile` surfaces. Your hook runs when the Desktop or mobile app asks to draw a backdrop.
`UserMessage`| `text`, `origin`, `isExpanded`, and `task` or `from` by origin| The drawn row’s id| Terminal, Desktop, VS Code
@@ -279,6 +290,7 @@
[`Input`](</docs/en/plugins/mods/interface#take-typed-input-and-draw-a-row-for-each-item>)| `key`, `label`, `placeholder`, `value`, `submitLabel`, [`rows`](</docs/en/plugins/mods/gallery#input>), `onSubmit`, `onInput`, `autoFocus`| ✓| ✓| ✓
`Select`| `key`, `label`, `options`, `value`, `onSelect`, `autoFocus`| ✓| ✓| ✓
`Svg`| a `source` of SVG markup up to 131,072 characters, `alt` text, `width`, `height`, and `isInteractive`| | ✓| ✓
+[`Shader`](</docs/en/plugins/mods/interface#animate-a-backdrop-with-a-shader>)| `module`, `values`, and one `Svg` child. Draws in a `Backdrop` only. Requires Claude Code v2.1.326 or later.| | ✓|
[`Client`](</docs/en/plugins/mods/interface#build-a-tree-from-elements>)| `module`, `key`, `props`, `width`, `height`, `flexGrow`| ✓| ✓|
[`Raster`](</docs/en/plugins/mods/interface#draw-a-grid-of-colored-cells>)| `key`, `columns` up to 512, `rows` up to 256, `cells`. See [Draw a grid of colored cells](</docs/en/plugins/mods/interface#draw-a-grid-of-colored-cells>).| ✓| |
`Image`| `key`, a `source` such as PNG or RGBA bytes up to 2 MiB, or a file path, `columns` and `rows` up to 255, and `alt` text. See [which terminals draw it](</docs/en/plugins/mods/gallery#image-and-client>).| ✓| |
@@ -375,10 +387,12 @@
`$.model.complete` `maxTokens`| 1024 by default, up to 64,000 or the model’s output limit
`$.fs.read` and `$.fs.write`| 4 MiB for one file. On v2.1.326 or later, read a larger file in parts with `$.fs.read(path, { offset, length })`, both in bytes.
A `$.http.fetch` request body| 4 MiB, counted in characters. A call with a larger body rejects.
-A `$.http.fetch` response body| 4 MiB. `text` holds the first 4 MiB and the rest isn’t read. When the `Content-Length` header declares more, the call rejects instead, with a reason that ends `is over the 4194304-byte limit`, except when the last request after any redirects uses the `HEAD` method. The `HEAD` exemption requires Claude Code v2.1.296 or later.
+A `$.http.fetch` response body| 4 MiB. `text` holds the first 4 MiB and the rest isn’t read. When the `Content-Length` header declares more, the call rejects instead, with a reason that ends `is over the 4194304-byte limit`. The call ignores that header on a 204, 205, or 304 response, and when its last request after any redirects uses `HEAD`. The `HEAD` case requires Claude Code v2.1.296 or later, and the others v2.1.299 or later.
One `$.http.fetch` call, redirects and body included| 30 seconds
Redirects one `$.http.fetch` call follows| 5
A hook’s `drop` reason or `config.set` `deny` reason| 4,096 characters. The end of a longer reason is cut, and the drop or deny still applies. The cut requires Claude Code v2.1.292 or later, and on earlier versions the hook [fails](</docs/en/plugins/mods/events#handle-a-hook-that-fails>) instead.
+All mods’ elements [above the question dialog](</docs/en/plugins/mods/interface#change-what-claude-code-already-draws>)| 12 rows in the terminal and 48 in the Desktop app or the VS Code extension, counted at a 40-column width. Over the limit, the dialog appears without your elements.
+A call to a method another mod added in `engine.create`| 10 seconds. After that, the call rejects with a reason that ends `did not answer within 10000ms`.
Text in one tree| The first 100,000 characters are drawn
A `Code`’s `language` or `path`, a `Select` option’s `value`, or a `Client`’s `module`| 10,000 characters. If one is longer, the `ui.render` hook that returned it [fails](</docs/en/plugins/mods/events#handle-a-hook-that-fails>).
A `Link`’s `href`| 2,048 characters. If it’s longer, the `ui.render` hook that returned it [fails](</docs/en/plugins/mods/events#handle-a-hook-that-fails>).
@@ -390,7 +404,10 @@
PNG or RGBA bytes of all the `Image`s in one tree| 2 MiB
`$.store`| 4 MiB of JSON in total
`$.session.messages()`| The newest 4,096 entries
+Text passed to `$.session.redact`| 100,000 characters. A call with longer text rejects.
`$.ui.invalidate('ui.render')` redraws| Throttled to 10 a second, or 30 in the terminal for the visible pane, the expanded band, and the hint line under the prompt. Calls that come sooner are coalesced.
+[`ui.pointer`](</docs/en/plugins/mods/interface#animate-a-backdrop-with-a-shader>) clicks| Two a second. The app drops the rest.
+A [`Shader`](</docs/en/plugins/mods/interface#animate-a-backdrop-with-a-shader>)’s `values`| Eight numbers
`$.ui.toast`| Shown for 4 seconds unless you pass `{ timeoutMs }`. In the [classic renderer](</docs/en/fullscreen#enable-fullscreen-rendering>), a mod’s newer toast can [take the place of its older one](</docs/en/plugins/mods/troubleshoot#a-toast-doesn%E2%80%99t-appear>) that’s showing or waiting to show.
A pane opened without the user asking| Placed from 144 terminal columns, 110 after they’ve opened it once
Rows from `$.ui.place` that one mod has in a conversation at one time| 500\. At the limit, a call with a new `id` resolves to `{ isPlaced: false, reason: 'a plugin holds at most 500 placed rows' }`.
@@ -428,5 +445,5 @@
[`/plugin`](</docs/en/plugins/mods/overview#see-which-mods-a-session-loaded>)| Shows a line such as `1 mod active · first-mod` under its tabs when a mod that isn’t built in has loaded
[`claude plugin validate <directory>`](</docs/en/plugins/mods/create#check-what-claude-code-reads-from-your-mod>)| Reads a plugin’s manifest and hooks module and reports errors, the events it handles, and the mods API calls it makes. `--strict` treats warnings as errors and `--json` prints a machine-readable report.
[`claude plugin test [directory]`](</docs/en/plugins/mods/test#write-a-test>)| Runs every file under the directory, or the current directory when you give none, whose name ends in `.test.ts` or `.test.tsx`. Exits with status 1 when a test fails.
-[`claude --plugin-dir <directory>`](</docs/en/plugins/mods/create#write-a-mod-yourself>)| Loads a plugin directory for one session and reloads its hooks module when you save. Repeat the flag to load several.
+[`claude --plugin-dir <directory>`](</docs/en/plugins/mods/create#write-a-mod-yourself>)| Loads a plugin directory for one session. In an interactive terminal session, reloads the hooks module when you save. Repeat the flag to load several.
`/reload-plugins`| Reloads plugins when you run it
--- a/reference.md
+++ b/reference.md
@@ -132,7 +132,7 @@
`session.end`| The session ends, or `/clear`, `/resume`, or `/branch` runs. `e.reason` is `clear`, `resume`, `logout`, `prompt_input_exit`, or `other`. `/branch` reports `resume`.| `next(e)`
`session.compact`| The conversation is about to be compacted| `{ skip: reason }`
[`session.receive`](</docs/en/plugins/mods/api#send-and-receive-messages-between-sessions>), [`session.send`](</docs/en/plugins/mods/api#send-and-receive-messages-between-sessions>)| A message arrives from, or is about to go to, another agent or session. See [Send and receive messages between sessions](</docs/en/plugins/mods/api#send-and-receive-messages-between-sessions>).| `{ consumed: reason }` for `receive`, `{ isDelivered: false, reason }` for `send`
-`session.append`| Once for each row the conversation keeps, such as a prompt, a response block, a tool result, or a notice, before it’s stored| `next({ ...e, message })` with a changed `message.content`, to rewrite the row’s text blocks or the `content` of a `tool_result` block in it
+`session.append`| Once for each row the conversation keeps, such as a prompt, a response block, a tool result, or a notice, before it’s stored| `next({ ...e, message })` with a changed `message.content`, to rewrite the row’s text blocks or the `content` of a `tool_result` block in it. You can’t rewrite a row that holds a [skill from an MCP server](</docs/en/mcp#use-skills-from-mcp-servers>). To change that skill’s text, hook `skill.prompt` instead.
`session.attach`, `session.detach`| Another app connects to or disconnects from the session| `next(e)`
`session.measure`| After each turn, and when a plan limit’s percent used changes| `next(e)`
`session.stop`| The user stops Claude, such as with Esc during a turn. Requires Claude Code v2.1.326 or later.| `next(e)`
@@ -185,7 +185,7 @@
### Settings hook events
-Each [settings hook event](</docs/en/hooks#hook-events>) is an event named `classic.<Event>`, such as `classic.Stop` or `classic.PostToolUse`. `e` is the hook’s stdin JSON.
+Each [settings hook event](</docs/en/hooks#hook-events>) is an event named `classic.<Event>`, such as `classic.Stop`. For the fields on `e`, see [Handle the settings hook events](</docs/en/plugins/mods/events#hook-the-settings-hook-events>).
### Mods API calls
--- a/reference.md
+++ b/reference.md
@@ -44,6 +44,8 @@
---|---|---
[`tool.call`](</docs/en/plugins/mods/events#guard-or-change-a-tool-call>)| A tool is about to run| `next(e)`, `{ deny: reason }`, or `{ result }`
[`tool.check`](</docs/en/plugins/mods/events#where-settings-hooks-run-in-the-order>)| Claude Code decides whether a tool call may run, after the `tool.call` and `PreToolUse` hooks. `next(e)` resolves to the decision the rules, the permission mode, and those hooks reached.| `next(e)` or `{ decision }`, with `decision` set to `allow`, `ask`, or `deny` and an optional `reason`
+`tool.judge`| [Auto mode](</docs/en/permission-modes#eliminate-prompts-with-auto-mode>) is about to ask its classifier about a call. Requires Claude Code v2.1.326 or later.| `next(e)` or `{ decision }`
+`tool.run`| An allowed call is about to run. Requires Claude Code v2.1.326 or later.| `next(e)`, `{ deny: reason }`, or `{ result }`
`tool.describe`| Once for each tool, when its description is first sent to Claude. A second time for an MCP tool when Claude loads it through [tool search](</docs/en/mcp#scale-with-mcp-tool-search>), with `e.description` set to the text Claude reads for the loaded tool.| `{ description }`, optionally with `isDeferred` set to `true` to put the tool behind tool search or `false` to load it upfront. Add `breakPromptCache: true` to send a changed description on the next turn.
#### Agent and organization fields on `tool.check`
@@ -133,6 +135,7 @@
`session.append`| Once for each row the conversation keeps, such as a prompt, a response block, a tool result, or a notice, before it’s stored| `next({ ...e, message })` with a changed `message.content`, to rewrite the row’s text blocks or the `content` of a `tool_result` block in it
`session.attach`, `session.detach`| Another app connects to or disconnects from the session| `next(e)`
`session.measure`| After each turn, and when a plan limit’s percent used changes| `next(e)`
+`session.stop`| The user stops Claude, such as with Esc during a turn. Requires Claude Code v2.1.326 or later.| `next(e)`
### Subagents
@@ -167,8 +170,8 @@
Event| Fires when| A hook can return
---|---|---
-[`plugin.register`](</docs/en/plugins/mods/admin#enforce-a-policy-with-a-mod-of-your-own>)| A hooks module is about to load. `e.uses` lists its events, mods API calls, environment variables, and state, as `claude plugin validate` prints them. Each call is written without the `$.` prefix, such as `fs.read`.| `{ refuse: reason }`
-`engine.create`| The mods API is being built for this mod| A changed mods API, to add a namespace. A mod outside the `user` tier can also withhold one.
+[`plugin.register`](</docs/en/plugins/mods/admin#enforce-a-policy-with-a-mod-of-your-own>)| A hooks module is about to load, or, on v2.1.326 or later, a plugin without one. `e.uses` lists the module’s events, mods API calls, environment variables, and state, as `claude plugin validate` prints them. Each call is written without the `$.` prefix, such as `fs.read`.| `{ refuse: reason }`. On v2.1.326 or later, a refusal keeps out the whole plugin, and `next({ ...e, provides: { ...e.provides, modules: [] } })` keeps out only its hooks module. Earlier versions ignore `provides` and load the module.
+`engine.create`| The mods API is being built for this mod| A changed mods API, to add a namespace. A mod in the `prepend` or `append` tier can also withhold one.
When another mod’s hook calls a method on a namespace you added in `engine.create`, your method’s `$` calls run in that hook’s context until every hook on that event returns. For example, a relative path resolves against that hook’s working directory, and `$.prompt.submit` rejects while the turn is waiting on that hook. Calls your method makes after that run in your mod’s own context.
@@ -214,7 +217,7 @@
[`$.model`](</docs/en/plugins/mods/api#call-a-model>)| `complete`, `fork`, `classify`
[`$.prompt`](</docs/en/plugins/mods/api#start-a-turn-from-a-background-job>)| `submit`, `read`, `fill`, `suggest`, `compose`. Claude reads text from `submit({ text })` after a sentence that names your mod as the sender. `submit({ text, asUser: true })` sends the text as the user’s own words, without that sentence.
`$.turn`| `abort`
-[`$.session`](</docs/en/plugins/mods/api#send-and-receive-messages-between-sessions>)| `messages`, `cwd`, `root`, `model`, `turns`, `id`, `repo`, `surfaces`, `usage`, `version`, `compact`, `send`, `append`, `authorize`. `usage()` returns `{ startedAt, context, rateLimits, cost }`: `context` has `tokens`, `window`, and `percent`, and `rateLimits` is a list of `{ kind, percentUsed, resetsAt }`.
+[`$.session`](</docs/en/plugins/mods/api#send-and-receive-messages-between-sessions>)| `messages`, `cwd`, `root`, `model`, `turns`, `id`, `repo`, `surfaces`, `usage`, `version`, `info`, `compact`, `send`, `append`, `authorize`. `info` requires Claude Code v2.1.326 or later. `usage()` returns `{ startedAt, context, rateLimits, cost }`: `context` has `tokens`, `window`, and `percent`, and `rateLimits` is a list of `{ kind, percentUsed, resetsAt }`.
`$.config`| `list`, `set`
[`$.settings`](</docs/en/plugins/mods/api#reach-files-processes-and-the-network>)| `read`
[`$.env`](</docs/en/plugins/mods/api#reach-files-processes-and-the-network>)| `get`, `set`
@@ -223,8 +226,9 @@
[`$.state`](</docs/en/plugins/mods/interface#keep-a-value-in-$-state>)| Reactive state: `get`, `set`, with the helpers `atom`, `read`, `update`, `derive`, and `memberOf` imported from `claude-code`
[`$.clock`](</docs/en/plugins/mods/api#run-work-in-the-background>)| `now`, `sleep`, `after`, `every`
[`$.http`](</docs/en/plugins/mods/api#reach-files-processes-and-the-network>)| `fetch`
-[`$.process`](</docs/en/plugins/mods/api#reach-files-processes-and-the-network>)| `run`, `spawn`
+[`$.process`](</docs/en/plugins/mods/api#reach-files-processes-and-the-network>)| `run`, `spawn`, `hookEnv`. `hookEnv` requires Claude Code v2.1.326 or later.
[`$.mcp`](</docs/en/plugins/mods/api#reach-files-processes-and-the-network>)| `call`, `connect`. `connect(server)` connects an MCP server that your own plugin’s manifest lists.
+[`$.wasm`](</docs/en/plugins/mods/api#reach-files-processes-and-the-network>)| `compile`. Requires Claude Code v2.1.326 or later.
`$.audio`| `play`, `speak`
`$.telemetry`| `log`, `mark`. A record is sent only when Claude Code or a built-in mod makes the call.
@@ -250,6 +254,7 @@
`InfoNotice`| `text`, `command`| The notice’s `text` prefixed with `notice:`| Terminal
`SessionMode`| `modes`| One instance| Terminal, Desktop
`PromptHint`| `isDraft`, `isWorking`, `hint`| One instance| Terminal, Desktop
+`AgentRow`| The agent’s [`$.agent.list()` fields](</docs/en/plugins/mods/create#get-the-types-for-your-build>), plus `rowIds`, `columns`, `body`, and `isHidden`| The agent id| Terminal and VS Code’s [Focus view](</docs/en/vs-code#extension-settings>). Requires v2.1.326 or later of Claude Code or the extension.
`e.viewport` holds `columns`, `rows`, and `isFullscreen`. In the terminal and the Desktop app, it’s absent until the app has measured its window. There, its `rows` is the height of the whole window, not of your pane. In the VS Code extension, it’s always present. To fit a tree to its site, read these props in the hook:
@@ -363,11 +368,12 @@
---|---
A hook’s own execution time for one event, not counting time inside `next` or a mods API call other than `$.clock.sleep`| 10 seconds, or 50 milliseconds for a `prompt.edit` hook
A `.catch` handler’s execution time| 1 second
+Time a `ui.render` or `plugin.register` hook waits on mods API calls for one event| 30 seconds for `ui.render`. 10 seconds for `plugin.register`, not counting `$.ui.ask`. The `ui.render` limit and the `$.ui.ask` exemption require Claude Code v2.1.326 or later.
All `session.end` hooks together| As long as the [SessionEnd hook budget](</docs/en/hooks#sessionend-input>), 1.5 seconds unless you change it, counted from when your settings `SessionEnd` hooks finish
`$.process.run` timeout| 30 seconds by default, 10 minutes at most
`$.process.run` `stdout` and `stderr`| 4 MiB each. `isStdoutTruncated` or `isStderrTruncated` is `true` when one was cut.
`$.model.complete` `maxTokens`| 1024 by default, up to 64,000 or the model’s output limit
-`$.fs.read` and `$.fs.write`| 4 MiB for one file
+`$.fs.read` and `$.fs.write`| 4 MiB for one file. On v2.1.326 or later, read a larger file in parts with `$.fs.read(path, { offset, length })`, both in bytes.
A `$.http.fetch` request body| 4 MiB, counted in characters. A call with a larger body rejects.
A `$.http.fetch` response body| 4 MiB. `text` holds the first 4 MiB and the rest isn’t read. When the `Content-Length` header declares more, the call rejects instead, with a reason that ends `is over the 4194304-byte limit`, except when the last request after any redirects uses the `HEAD` method. The `HEAD` exemption requires Claude Code v2.1.296 or later.
One `$.http.fetch` call, redirects and body included| 30 seconds
@@ -377,6 +383,7 @@
A `Code`’s `language` or `path`, a `Select` option’s `value`, or a `Client`’s `module`| 10,000 characters. If one is longer, the `ui.render` hook that returned it [fails](</docs/en/plugins/mods/events#handle-a-hook-that-fails>).
A `Link`’s `href`| 2,048 characters. If it’s longer, the `ui.render` hook that returned it [fails](</docs/en/plugins/mods/events#handle-a-hook-that-fails>).
Nesting depth of one tree| 32 levels below the root element
+Depth and size of a tree counted with its prop values| Claude Code refuses anything `nested more than 100 lists and objects deep` or with `more than 1000000 values once written out`. Requires Claude Code v2.1.326 or later.
Elements and text children in one tree| 20,000
`Raster` cells in one tree, each `Raster`’s `columns` times its `rows`| 262,144
The rows above the prompt, stacked| Elements, `Raster` cells, and `Image` bytes add up across the rows, against the limits for one tree
@@ -388,7 +395,7 @@
A pane opened without the user asking| Placed from 144 terminal columns, 110 after they’ve opened it once
Rows from `$.ui.place` that one mod has in a conversation at one time| 500\. At the limit, a call with a new `id` resolves to `{ isPlaced: false, reason: 'a plugin holds at most 500 placed rows' }`.
Nesting depth of a mods API call’s arguments| 28,000 levels. Past that, the call rejects with a message ending `nesting deeper than 28000 levels is not supported`. Requires Claude Code v2.1.299 or later.
-Nesting depth of a changed event passed to `next`, outside async generator hooks such as one on `turn.step`| 28,000 levels. Past that, `next` rejects with a message ending `nesting deeper than 28000 levels is not supported`. Requires Claude Code v2.1.299 or later.
+Nesting depth of a changed event passed to `next`, outside `ui.render` and async generator hooks such as one on `turn.step`| 28,000 levels. Past that, `next` rejects with a message ending `nesting deeper than 28000 levels is not supported`. Requires Claude Code v2.1.299 or later.
Nesting depth of a hook’s return value, outside `ui.render`, `ui.resolve`, and async generator hooks| 28,000 levels. Past that, the hook’s result is refused, and [the notice that reports it](</docs/en/plugins/mods/troubleshoot#find-out-why-a-mod-does-nothing>) includes `nesting deeper than 28000 levels is not supported`. Requires Claude Code v2.1.299 or later.
Scopes, such as functions, blocks, and loops, nested inside one another in one file of a hooks module| 2,000
Command, tool, subagent type, and pane names, the `id` of a placed row, and the `scene` of a backdrop| Letters, digits, `_`, and `-`, up to 64 characters
--- a/reference.md
+++ b/reference.md
@@ -209,8 +209,8 @@
[`$.ui`](</docs/en/plugins/mods/interface#pick-where-to-draw>)| `resolve`, `invalidate`, `open`, `close`, `panes`, [`place`](</docs/en/plugins/mods/interface#place-a-row-in-the-transcript>), `focus`, `scroll`, `toast`, `notify`, `status`, `log`, `notice`, `ask`, `copy`, `selection`, `blit`, `view`. `view` requires Claude Code v2.1.300 or later and `place` v2.1.314 or later.
[`$.theme`](</docs/en/plugins/mods/interface#put-a-backdrop-behind-the-conversation>)| `set`, `clear`: set a backdrop for the Desktop or mobile app to draw, and take the backdrop off. Requires Claude Code v2.1.319 or later.
[`$.command`](</docs/en/plugins/mods/api#add-a-command>)| `register`, `run`, `list`
-[`$.tool`](</docs/en/plugins/mods/api#add-a-tool>)| `register`, `call`, `check`, `list`. When a `call` needs a person’s approval, such as one a hook or your organization answers with `ask`, it resolves with `{ deny: "<tool> wasn't run: this call needs a person's approval, and a mod's own call can't ask for it." }`, where `<tool>` is the tool’s name.
-`$.agent`| `register`, `spawn`, `list`. `list()` returns this session’s subagents and teammates, each with a `status` of `pending`, `running`, `waiting`, `idle`, `completed`, `failed`, or `killed`, where `idle` and `waiting` require Claude Code v2.1.289 or later.
+[`$.tool`](</docs/en/plugins/mods/api#add-a-tool>)| `register`, `call`, `check`, `list`
+`$.agent`| `register`, `spawn`, `call`, `list`, `limits`. `call` and `limits` require Claude Code v2.1.326 or later. `list()` returns this session’s subagents and teammates, each with a `status` of `pending`, `running`, `waiting`, `idle`, `completed`, `failed`, or `killed`, where `idle` and `waiting` require Claude Code v2.1.289 or later.
[`$.model`](</docs/en/plugins/mods/api#call-a-model>)| `complete`, `fork`, `classify`
[`$.prompt`](</docs/en/plugins/mods/api#start-a-turn-from-a-background-job>)| `submit`, `read`, `fill`, `suggest`, `compose`. Claude reads text from `submit({ text })` after a sentence that names your mod as the sender. `submit({ text, asUser: true })` sends the text as the user’s own words, without that sentence.
`$.turn`| `abort`
--- a/reference.md
+++ b/reference.md
@@ -186,7 +186,18 @@
### Mods API calls
-Every mods API method is also an event, named for its namespace and method, such as `fs.read`, `model.complete`, or `ui.open`. A hook on one intercepts calls from the mods that run after it, and can return `next(e)`, `{ deny: reason }`, or `{ value }`.
+Every mods API method is also an event, named for its namespace and method, such as `fs.read`, `model.complete`, or `ui.open`. A hook on one can return `next(e)`, `{ deny: reason }`, or `{ value }`. Some of these events also fire for Claude Code’s own actions, so check whether `next.origin.plugin` is `engine` before you refuse one.
+
+#### Fields on Claude Code’s own `http.fetch` requests
+
+In an `http.fetch` hook, a `next.origin` of `{ plugin: 'engine', tier: 'core' }` marks one of Claude Code’s own requests, such as a model request, not a mod’s `$.http.fetch` call. Where the [built-in guard](</docs/en/plugins/mods/admin#know-what-happens-by-default>) is loaded, your hook doesn’t get these events unless your mod [counts as your organization’s](</docs/en/plugins/mods/admin#install-your-organizations-mods>). On these events, `e.init` and the `value` that `next(e)` resolves to can hold these fields, among others:
+
+Field| What it means
+---|---
+`e.init.compress`| Set when Claude Code compresses the body after your hook. `e.init.body` holds the uncompressed body. To send the body uncompressed, call `next({ ...e, init: { ...e.init, compress: undefined } })`.
+`value.isStreaming`| Set to `true` because Claude Code reads the response body itself, so `value.text` is empty. Read `value.status` and `value.headers` instead. To answer with your own `text`, return a `value` without `isStreaming`.
+
+These events and fields require Claude Code v2.1.321 or later.
## Mods API methods
@@ -198,7 +209,7 @@
[`$.ui`](</docs/en/plugins/mods/interface#pick-where-to-draw>)| `resolve`, `invalidate`, `open`, `close`, `panes`, [`place`](</docs/en/plugins/mods/interface#place-a-row-in-the-transcript>), `focus`, `scroll`, `toast`, `notify`, `status`, `log`, `notice`, `ask`, `copy`, `selection`, `blit`, `view`. `view` requires Claude Code v2.1.300 or later and `place` v2.1.314 or later.
[`$.theme`](</docs/en/plugins/mods/interface#put-a-backdrop-behind-the-conversation>)| `set`, `clear`: set a backdrop for the Desktop or mobile app to draw, and take the backdrop off. Requires Claude Code v2.1.319 or later.
[`$.command`](</docs/en/plugins/mods/api#add-a-command>)| `register`, `run`, `list`
-[`$.tool`](</docs/en/plugins/mods/api#add-a-tool>)| `register`, `call`, `check`, `list`
+[`$.tool`](</docs/en/plugins/mods/api#add-a-tool>)| `register`, `call`, `check`, `list`. When a `call` needs a person’s approval, such as one a hook or your organization answers with `ask`, it resolves with `{ deny: "<tool> wasn't run: this call needs a person's approval, and a mod's own call can't ask for it." }`, where `<tool>` is the tool’s name.
`$.agent`| `register`, `spawn`, `list`. `list()` returns this session’s subagents and teammates, each with a `status` of `pending`, `running`, `waiting`, `idle`, `completed`, `failed`, or `killed`, where `idle` and `waiting` require Claude Code v2.1.289 or later.
[`$.model`](</docs/en/plugins/mods/api#call-a-model>)| `complete`, `fork`, `classify`
[`$.prompt`](</docs/en/plugins/mods/api#start-a-turn-from-a-background-job>)| `submit`, `read`, `fill`, `suggest`, `compose`. Claude reads text from `submit({ text })` after a sentence that names your mod as the sender. `submit({ text, asUser: true })` sends the text as the user’s own words, without that sentence.
@@ -224,9 +235,10 @@
Site| `e.props`| `e.requestId`| Rendered on
---|---|---|---
[`Pane`](</docs/en/plugins/mods/interface#pick-where-to-draw>)| `title`, `isFocused`, `bodyColumns`, `placement`, `scroll`, `view`| The pane’s `id`| Terminal, Desktop, VS Code
-[`AbovePrompt`](</docs/en/plugins/mods/interface#pick-where-to-draw>)| `hasSurvey`, `isWorking`, `maxRows`, `bodyColumns`, `scroll`, `view`| One instance| Terminal, Desktop
+[`AbovePrompt`](</docs/en/plugins/mods/interface#pick-where-to-draw>)| `hasSurvey`, [`isCollapsed`](</docs/en/plugins/mods/interface#when-the-user-collapses-the-band>), `isWorking`, `maxRows`, `bodyColumns`, `scroll`, `view`| One instance| Terminal, Desktop
+`AbovePromptList`, the stack of `AbovePrompt` rows| `rows`, a list with one `{ plugin, tree }` for each mod’s row, plus the `AbovePrompt` props| One instance| Terminal, Desktop. Requires Claude Code v2.1.323 or later.
[`Placed`](</docs/en/plugins/mods/interface#place-a-row-in-the-transcript>)| `id`, `plugin`, `onScreen`| The `requestId` that `$.ui.place` returned| Terminal
-[`Backdrop`](</docs/en/plugins/mods/interface#put-a-backdrop-behind-the-conversation>)| `id`, `plugin`, `glass`, `colorScheme`| `backdrop`| `desktop` and `mobile` surfaces. Your hook runs when the Desktop or mobile app asks to draw a backdrop.
+[`Backdrop`](</docs/en/plugins/mods/interface#put-a-backdrop-behind-the-conversation>)| `scene`, `plugin`, `glass`, `overrideColorScheme`. Before v2.1.323, `scene` was `id` and `overrideColorScheme` was `colorScheme`.| `backdrop`| `desktop` and `mobile` surfaces. Your hook runs when the Desktop or mobile app asks to draw a backdrop.
`UserMessage`| `text`, `origin`, `isExpanded`, and `task` or `from` by origin| The drawn row’s id| Terminal, Desktop, VS Code
`AssistantMessage`| The reply’s text| The drawn row’s id| Terminal, Desktop, VS Code
`ToolUse`, `ToolResult`, `ToolGroup`| The tool’s name, input, and result| The tool call id| Terminal, Desktop, VS Code
@@ -271,7 +283,7 @@
* **`action`** : names one of Claude Code’s own [keybinding actions](</docs/en/keybindings>), and the user’s binding for it presses the button when that binding is a chord or a modified key
* **Digit hotkeys on the band** : a digit `hotkey` on a button in the band also fires when the user types that digit alone into an empty prompt and pauses
* **A collapsed band** : while the band is [collapsed](</docs/en/plugins/mods/interface#when-the-user-collapses-the-band>), neither an `action` binding nor a hotkey presses a button in it
- * **Two buttons on one hotkey** : when two buttons in one drawing name the same `hotkey`, the later one gets it
+ * **Two buttons on one hotkey** : when two of your buttons in one drawing name the same `hotkey`, the later one gets it. For another mod’s button on the same key, see [Hotkeys do nothing](</docs/en/plugins/mods/troubleshoot#hotkeys-do-nothing>).
* **`variant`** : `primary` or `secondary`, and any other value throws. In the terminal, a `primary` button draws in the accent color unless it’s `plain`.
* **`role`** : `dismiss` marks a close button, and any other value throws. Do the closing in your `onPress`. In a band that holds text and a row of buttons, the Desktop app can draw the row’s first `dismiss` button as its own close control. The terminal draws the button as it would without `role`.
@@ -367,6 +379,7 @@
Nesting depth of one tree| 32 levels below the root element
Elements and text children in one tree| 20,000
`Raster` cells in one tree, each `Raster`’s `columns` times its `rows`| 262,144
+The rows above the prompt, stacked| Elements, `Raster` cells, and `Image` bytes add up across the rows, against the limits for one tree
PNG or RGBA bytes of all the `Image`s in one tree| 2 MiB
`$.store`| 4 MiB of JSON in total
`$.session.messages()`| The newest 4,096 entries
@@ -378,7 +391,7 @@
Nesting depth of a changed event passed to `next`, outside async generator hooks such as one on `turn.step`| 28,000 levels. Past that, `next` rejects with a message ending `nesting deeper than 28000 levels is not supported`. Requires Claude Code v2.1.299 or later.
Nesting depth of a hook’s return value, outside `ui.render`, `ui.resolve`, and async generator hooks| 28,000 levels. Past that, the hook’s result is refused, and [the notice that reports it](</docs/en/plugins/mods/troubleshoot#find-out-why-a-mod-does-nothing>) includes `nesting deeper than 28000 levels is not supported`. Requires Claude Code v2.1.299 or later.
Scopes, such as functions, blocks, and loops, nested inside one another in one file of a hooks module| 2,000
-Command, tool, subagent type, and pane names, and the `id` of a placed row or a backdrop| Letters, digits, `_`, and `-`, up to 64 characters
+Command, tool, subagent type, and pane names, the `id` of a placed row, and the `scene` of a backdrop| Letters, digits, `_`, and `-`, up to 64 characters
One `claude plugin test` test| 5 seconds unless the test sets `timeoutMs`
## Settings and environment variables
@@ -388,7 +401,7 @@
Name| Where| What it does
---|---|---
`CLAUDE_CODE_PLUGIN_DIRS`| Environment, or `env` in `~/.claude/settings.json`| Plugin directories to load as `--plugin-dir` does, for apps you can’t pass a flag to. Absolute paths separated by `:`, or `;` on Windows.
-`CLAUDE_CODE_PLUGIN_DIR_WATCH`| Environment| `1` makes a long-running non-interactive session reload `--plugin-dir` mods on save
+`CLAUDE_CODE_PLUGIN_DIR_WATCH`| Environment| Whether mods reload on save. See the [environment variables reference](</docs/en/env-vars>) for the defaults and values
`prependPlugins`, `appendPlugins`| Managed settings. User settings only on a machine with no managed settings or [`managed-mcp.json`](</docs/en/managed-mcp#deploy-managed-mcp-json>) file, in a session whose credential isn’t a Team or Enterprise `/login`.| Lists of plugin ids, such as `acme-guard@acme-tools`. Mods in `prependPlugins` run before every mod a user installs, and mods in `appendPlugins` run after, in the listed order. See [The order mods run in](</docs/en/plugins/mods/events#the-order-mods-run-in>).
`allowManagedModsOnly`| Managed settings, as an [option on the built-in guard](</docs/en/plugins/mods/admin#set-options-on-the-built-in-guard>)| Only mods that [count as your organization’s](</docs/en/plugins/mods/admin#install-your-organizations-mods>), and mods built into Claude Code, run their hooks. Users’ settings hooks keep running.
`allowModsToOverrideDenyRules`| Managed settings, as an [option on the built-in guard](</docs/en/plugins/mods/admin#set-options-on-the-built-in-guard>)| Lets a mod a user installed approve a tool call past most of [the outcomes that stay in place by default](</docs/en/permissions#precedence-among-rules-hooks-and-mods>), including a `deny` rule
Show diff (352 lines)
--- a/reference.md
+++ b/reference.md
@@ -2,11 +2,7 @@
The complete reference is Claude Code’s [TypeScript declarations for mods](<https://github.com/anthropics/claude-code/blob/main/mods/types/claude-code.d.ts>), which describe every event, method, and element, with examples. The copy on GitHub can be older than the Claude Code version you have installed. When the two disagree, trust [the copy Claude Code writes for your version](</docs/en/plugins/mods/create#get-the-types-for-your-build>).
-##
-
-
-
-Files
+## Files
A mod is a plugin directory with these files:
@@ -20,11 +16,7 @@
`register` receives `on` and `options`. `options` holds the values of the [`userConfig`](</docs/en/plugins/components#user-configuration>) fields the manifest declares, with defaults filled in.
-##
-
-
-
-The hook function
+## The hook function
A mod registers each of its hooks, which are event handlers, by calling `on` inside `register`. `on` takes the event’s name, an optional [matcher](</docs/en/plugins/mods/events#filter-which-events-a-hook-handles>), which is a filter on the event’s fields, and the hook, as in `on('tool.call', { tool: 'Bash' }, async ($, e, next) => next(e))`. `on` returns a registration with one method, `.catch(handler)`, which sets the hook’s [error handler](</docs/en/plugins/mods/events#handle-a-hook-that-fails>).
@@ -40,19 +32,11 @@
`next.error`| In a `.catch` handler only. `kind` is `throw` or `timeout`, and `message` is the error’s text.
`next.called`| In a `.catch` handler only. `true` when the hook had called `next`.
-##
-
-
-
-Events
+## Events
Events are grouped by what they concern, each with when it fires and what a hook on it can return. Hooks on `turn.step` and `process.spawn` are async generators, and other hooks are async functions. The last column of each table uses shorthand. `next(e)` passes the event on unchanged. `next({ ...e, text })` passes on a copy with the named field changed, as in `next({ ...e, text: e.text.trim() })`. An object answers the event without calling `next`, and a word such as `reason` stands for a string you write, as in `{ deny: 'Use the file tools.' }`.
-###
-
-
-
-Tools
+### Tools
Tool events fire around each tool call Claude makes, from the description Claude reads to the decision on whether the call runs:
@@ -62,11 +46,7 @@
[`tool.check`](</docs/en/plugins/mods/events#where-settings-hooks-run-in-the-order>)| Claude Code decides whether a tool call may run, after the `tool.call` and `PreToolUse` hooks. `next(e)` resolves to the decision the rules, the permission mode, and those hooks reached.| `next(e)` or `{ decision }`, with `decision` set to `allow`, `ask`, or `deny` and an optional `reason`
`tool.describe`| Once for each tool, when its description is first sent to Claude. A second time for an MCP tool when Claude loads it through [tool search](</docs/en/mcp#scale-with-mcp-tool-search>), with `e.description` set to the text Claude reads for the loaded tool.| `{ description }`, optionally with `isDeferred` set to `true` to put the tool behind tool search or `false` to load it upfront. Add `breakPromptCache: true` to send a changed description on the next turn.
-####
-
-
-
-Agent and organization fields on `tool.check`
+#### Agent and organization fields on `tool.check`
In a `tool.check` hook, read these fields to tell a subagent’s call from the main conversation’s, and to see whether your organization requires approval for a connector tool:
@@ -75,19 +55,11 @@
On `tool.check`, `e.agentId` and `e.ceiling` require Claude Code v2.1.290 or later.
-####
-
-
-
-The `e.isReadOnly` field on `tool.check`
+#### The `e.isReadOnly` field on `tool.check`
In a `tool.check` hook, `e.isReadOnly` is `true` when the tool reports this call as read-only. Otherwise the field is absent, not `false`. The value is the tool’s own report, so read [Check whether a tool call is read-only](</docs/en/plugins/mods/events#check-whether-a-tool-call-is-read-only>) before you approve a call on this field alone. On `tool.check`, `e.isReadOnly` requires Claude Code v2.1.304 or later.
-###
-
-
-
-Prompts and what Claude reads
+### Prompts and what Claude reads
Prompt events cover the text the user types and the text Claude Code sends to Claude on its own, such as the system prompt and reminders:
@@ -105,11 +77,7 @@
[`skill.prompt`](</docs/en/plugins/mods/events#rewrite-or-add-to-a-prompt>)| A skill’s text is expanded for Claude| `{ text }`
`attribution.text`| Claude Code composes commit or pull request attribution text| `{ text }`
-####
-
-
-
-Source and frontmatter fields on `skill.prompt`
+#### Source and frontmatter fields on `skill.prompt`
In a `skill.prompt` hook, you can read these fields along with the skill’s name in `e.skill` and the text Claude reads in `e.text`:
@@ -123,19 +91,11 @@
A hook can pass a changed `text` or `frontmatter` to `next`: the hooks after it read both, and Claude reads the final `text`. A hook that changes any other field [fails](</docs/en/plugins/mods/events#handle-a-hook-that-fails>). On `skill.prompt`, `e.source`, `e.pluginName`, `e.path`, `e.frontmatter`, and `e.frontmatterProblem` require Claude Code v2.1.299 or later.
-####
-
-
-
-Send a changed system prompt section or tool description with `breakPromptCache`
+#### Send a changed system prompt section or tool description with `breakPromptCache`
To change a section or a tool description in a running conversation, call `$.ui.invalidate('prompt.section')` or `$.ui.invalidate('tool.describe')` so your hook runs again. Return `{ text, breakPromptCache: true }` or `{ description, breakPromptCache: true }` from it. Without the field, Claude keeps reading the text [saved with the conversation](</docs/en/cli-reference#system-prompt-flags-in-resumed-conversations>) for a section or a tool loaded upfront until a new conversation or a [compaction](</docs/en/prompt-caching#compacting-the-conversation>). The changed text reaches Claude on the next turn, and the [prompt cache](</docs/en/prompt-caching>) starts over, so that turn is slower and more expensive. The field requires Claude Code v2.1.321 or later. From v2.1.299 until v2.1.321, a running conversation got the changed text on the next turn.
-###
-
-
-
-Commands and configuration
+### Commands and configuration
Event| Fires when| A hook can return
---|---|---
@@ -145,20 +105,12 @@
`config.describe`| Once for each `/config` row| `{ label, description, isHidden }`
[`settings.read`](</docs/en/plugins/mods/events#settings-read-hook>)| A mod calls [`$.settings.read`](</docs/en/plugins/mods/api#reach-files-processes-and-the-network>), or Claude Code builds the session’s merged settings. Requires Claude Code v2.1.304 or later on Claude Code’s own read and for `e.layers`| `next(e)`, `{ value }`, or `{ deny: reason }`
-####
-
-
-
-`e.layers` and `e.source` on `settings.read`
+#### `e.layers` and `e.source` on `settings.read`
* **`e.layers`** : one `{ source, settings }` object for each source in use that holds settings, lowest [precedence](</docs/en/settings#settings-precedence>) first. See [What a `settings.read` hook receives](</docs/en/plugins/mods/events#settings-read-receives>).
* **`e.source`** : the one source a mod asked for, as in `$.settings.read({ source: 'policy' })`. Absent on Claude Code’s own read and on a read of the merged settings
-###
-
-
-
-Turns
+### Turns
Turn events follow one answer from start to finish, including each request to the model within it:
@@ -168,11 +120,7 @@
[`turn.step`](</docs/en/plugins/mods/events#follow-a-turn>)| One request is about to go to the model| `yield* next(e)`, or `next({ ...e, model })`, `next({ ...e, effort })`
[`turn.complete`](</docs/en/plugins/mods/events#follow-a-turn>)| A turn ended| `next(e)`, or `{ text }` to show a line under the answer
-###
-
-
-
-Session
+### Session
Session events mark the session starting, ending, compacting, and exchanging messages with other sessions:
@@ -186,11 +134,7 @@
`session.attach`, `session.detach`| Another app connects to or disconnects from the session| `next(e)`
`session.measure`| After each turn, and when a plan limit’s percent used changes| `next(e)`
-###
-
-
-
-Subagents
+### Subagents
Subagent events fire when a subagent type is offered to Claude and when a subagent or an agent-team teammate is about to start:
@@ -203,11 +147,7 @@
The event for a resumed run requires Claude Code v2.1.299 or later. Before v2.1.299, your `agent.spawn` hook didn’t run when a subagent resumed. On those versions, to refuse the `SendMessage` calls that resume a subagent, match that tool in a [`tool.call`](</docs/en/plugins/mods/events#guard-or-change-a-tool-call>) hook.
-###
-
-
-
-Interface
+### Interface
Interface events fire when Claude Code draws a render site and when the user uses a control a mod drew. [Draw in the interface](</docs/en/plugins/mods/interface>) shows what a `ui.render` hook returns:
@@ -221,11 +161,7 @@
[`ui.message`](</docs/en/plugins/mods/interface#build-a-tree-from-elements>)| A `Client` element posts data to its mod
[`ui.fault`](</docs/en/plugins/mods/interface#redraw-when-something-changes>)| A `Client` element your mod drew failed to load, draw, or run. `e.phase` is `load`, `render`, or `run`, and `e.reason` is the error message. Requires Claude Code v2.1.289 or later.
-###
-
-
-
-Other mods
+### Other mods
These events let a mod act on other mods as they load, to refuse one or change the mods API it receives:
@@ -236,11 +172,7 @@
When another mod’s hook calls a method on a namespace you added in `engine.create`, your method’s `$` calls run in that hook’s context until every hook on that event returns. For example, a relative path resolves against that hook’s working directory, and `$.prompt.submit` rejects while the turn is waiting on that hook. Calls your method makes after that run in your mod’s own context.
-###
-
-
-
-Telemetry
+### Telemetry
Telemetry events fire for the usage records Claude Code logs:
@@ -248,27 +180,15 @@
---|---|---
`telemetry.log`, `telemetry.mark`| A telemetry record is about to be logged, or one use of a feature is marked. In a mod you install, give a telemetry hook the filter `{ to: 'collector' }`, as in `on('telemetry.log', { to: 'collector' }, hook)`. Without the filter, the mod fails `claude plugin validate`. `*` doesn’t match these events.| `next(e)`, or `{ deny: reason }`
-###
-
-
-
-Settings hook events
+### Settings hook events
Each [settings hook event](</docs/en/hooks#hook-events>) is an event named `classic.<Event>`, such as `classic.Stop` or `classic.PostToolUse`. `e` is the hook’s stdin JSON.
-###
-
-
-
-Mods API calls
+### Mods API calls
Every mods API method is also an event, named for its namespace and method, such as `fs.read`, `model.complete`, or `ui.open`. A hook on one intercepts calls from the mods that run after it, and can return `next(e)`, `{ deny: reason }`, or `{ value }`.
-##
-
-
-
-Mods API methods
+## Mods API methods
The mods API is the `$` argument every hook receives. Its methods are grouped in namespaces, such as `$.ui`. This table lists each namespace’s methods by name, so `open` in the `$.ui` row is the call `$.ui.open(...)`. The guides show the common ones in use, and [the types for your build](</docs/en/plugins/mods/create#get-the-types-for-your-build>) document every method with an example.
@@ -297,11 +217,7 @@
`$.audio`| `play`, `speak`
`$.telemetry`| `log`, `mark`. A record is sent only when Claude Code or a built-in mod makes the call.
-##
-
-
-
-Render sites
+## Render sites
A render site is an extension point in Claude Code’s interface. Each row is a value of `e.component` in a `ui.render` hook, with the fields of `e.props` and the apps that render it. `e.surface` names the app that’s drawing, such as `terminal`, `desktop`, or `vscode`. [Change what Claude Code already draws](</docs/en/plugins/mods/interface#change-what-claude-code-already-draws>) shows what a hook can do at a site, with an example of each choice. Rendering in the VS Code extension requires extension version 2.1.299 or later. A session that [doesn’t fetch feature flags](</docs/en/env-vars#features-that-need-feature-flag-fetching>) needs 2.1.304 or later. [Draw in the VS Code extension](</docs/en/plugins/mods/interface#draw-in-the-vs-code-extension>) lists what the extension draws differently.
@@ -331,11 +247,7 @@
A tree taller than the pane scrolls as a whole.
-##
-
-
-
-Elements
+## Elements
Elements are the building blocks of a tree a `ui.render` hook returns, and you get them from `$.ui.resolve(e)`. [Build a tree from elements](</docs/en/plugins/mods/interface#build-a-tree-from-elements>) shows the common ones with how the terminal draws them, and the [interface gallery](</docs/en/plugins/mods/gallery>) has screenshots of most. A check mark means the app can draw the element.
@@ -381,11 +293,7 @@
* **`Input` and `Select`**: `autoFocus`, and `rows` on an `Input`
* **`Svg`** : `isInteractive`
-###
-
-
-
-`Box` border styles
+### `Box` border styles
To draw a border around a `Box`, set its `borderStyle` to one of these names, as in `borderStyle: 'round'`. Each row says what the terminal draws for that name and shows the top edge of the border.
@@ -404,11 +312,7 @@
A `Box` whose `borderStyle` names anything else, such as `'rounded'`, draws with no border.
-###
-
-
-
-`Box` spacing steps
+### `Box` spacing steps
The `Box` spacing props are `gap`, `columnGap`, `rowGap`, `padding`, `margin`, and the one-side and one-axis forms of `padding` and `margin`, such as `paddingX` and `marginTop`. Each takes a number of terminal cells such as `gap: 1`, or a step name such as `gap: 'md'`. In the terminal and the VS Code extension, each step is this many cells:
@@ -422,11 +326,7 @@
If you set `gap`, `padding`, or `margin` to a step, the step applies across and down at once. For example, in the terminal and the VS Code extension, `padding: 'md'` is two cells at each side and one row above and below. Step names require Claude Code v2.1.299 or later. On an earlier release, a tree that uses a step name doesn’t draw.
-###
-
-
-
-`Text` typography props
+### `Text` typography props
Set `size`, `weight`, `mono`, or `tabular` on a `Text` to ask the app drawing your tree for a text size, a weight, a monospaced typeface, or equal-width digits. Before you rely on a prop, check what the terminal and the VS Code extension do with it. If an app ignores a prop you set, your tree still draws there, with the text as if you’d left that prop out.
@@ -439,19 +339,11 @@
These four props require Claude Code v2.1.299 or later. On an earlier release, a tree that sets `size`, `weight`, `mono`, or `tabular` doesn’t draw.
-####
-
-
-
-Replace `bold` with `weight`
+#### Replace `bold` with `weight`
`bold` on a `Text` is deprecated in favor of `weight` and still works. To replace it on a `Text` with no `weight`, change `bold: true` to `weight: 'semibold'` for the same result on Claude Code v2.1.299 or later. On a release earlier than v2.1.299, a tree that sets `weight` doesn’t draw. If you set both `bold` and `weight` on a `Text`, `bold` has no effect.
-##
-
-
-
-Limits
+## Limits
Hooks and mods API calls run under time and size limits. Claude Code skips a hook that exceeds a time limit. A tree over the nesting, element, `Raster` cell, or `Image` byte limit [isn’t drawn](</docs/en/plugins/mods/troubleshoot#a-pane-or-band-is-empty>).
@@ -489,11 +381,7 @@
Command, tool, subagent type, and pane names, and the `id` of a placed row or a backdrop| Letters, digits, `_`, and `-`, up to 64 characters
One `claude plugin test` test| 5 seconds unless the test sets `timeoutMs`
-##
-
-
-
-Settings and environment variables
+## Settings and environment variables
These are the settings and environment variables that affect mods. The Where column says which settings file or environment each one is read from:
@@ -511,11 +399,7 @@
`sec-default@builtin` is a guard built into Claude Code, listed as `cc-plugin-sec-default` in `/plugin` and the debug log. [Where it loads](</docs/en/plugins/mods/admin#know-what-happens-by-default>), it runs ahead of every mod a person installs. If managed `prependPlugins` is set, the guard loads only when that list names it, at the position listed. Its source is in the [`mods/sec-default` directory of the Claude Code repository](<https://github.com/anthropics/claude-code/tree/main/mods/sec-default>).
-##
-
-
-
-Commands
+## Commands
These commands and flags load, inspect, and test a mod. The `claude` commands run in your shell and the `/` commands at the Claude Code prompt. In the table, `<directory>` stands for a path you type, as in `claude plugin validate ./first-mod`. Square brackets mark an optional argument.
--- a/reference.md
+++ b/reference.md
@@ -37,8 +37,7 @@
`next.origin`| `{ plugin, tier }` of whoever fired the event. Claude Code itself is `{ plugin: 'engine', tier: 'core' }`. A mod’s `tier` is its priority group in the [order mods run in](</docs/en/plugins/mods/events#the-order-mods-run-in>): `prepend`, `user`, `append`, or `builtin`.
`next.budget`| The hook’s time limit in milliseconds: `next.budget.ms` is the whole limit, and `next.budget.remainingMs` is what’s left now
`next.to(e, tier)`| Skips to a later tier, which is `append`, `builtin`, or `core`. `next.to(e, 'append')` skips the mods a user installed. Only a mod in `prependPlugins` or `appendPlugins` can call it.
-`next.error`| In a `.catch` handler only. `kind` is `throw` or `timeout` when the hook failed, and `message` is the error’s text. `kind` is `re-entry` when the hook was skipped because the event came from inside a mods API call by that hook or by your mod’s code outside its hooks. `re-entry` requires Claude Code v2.1.292 or later.
-`next.error.cause`| Set only when `kind` is `re-entry`. `rewritten` if a `tool.call` or [`PreToolUse`](</docs/en/hooks#pretooluse>) hook changed the mods API call the event came from, or an `agent.spawn` hook changed an agent started by that call. `lent` when a method another mod adds to the mods API fired that event, unless `rewritten` also applies. `lent` requires Claude Code v2.1.292 or later and `rewritten` v2.1.300 or later.
+`next.error`| In a `.catch` handler only. `kind` is `throw` or `timeout`, and `message` is the error’s text.
`next.called`| In a `.catch` handler only. `true` when the hook had called `next`.
##
Show diff (101 lines)
--- a/reference.md
+++ b/reference.md
@@ -61,7 +61,7 @@
---|---|---
[`tool.call`](</docs/en/plugins/mods/events#guard-or-change-a-tool-call>)| A tool is about to run| `next(e)`, `{ deny: reason }`, or `{ result }`
[`tool.check`](</docs/en/plugins/mods/events#where-settings-hooks-run-in-the-order>)| Claude Code decides whether a tool call may run, after the `tool.call` and `PreToolUse` hooks. `next(e)` resolves to the decision the rules, the permission mode, and those hooks reached.| `next(e)` or `{ decision }`, with `decision` set to `allow`, `ask`, or `deny` and an optional `reason`
-`tool.describe`| Once for each tool, when its description is first sent to Claude. A second time for an MCP tool when Claude loads it through [tool search](</docs/en/mcp#scale-with-mcp-tool-search>), with `e.description` set to the text Claude reads for the loaded tool.| `{ description }`, optionally with `isDeferred` set to `true` to put the tool behind tool search or `false` to load it upfront
+`tool.describe`| Once for each tool, when its description is first sent to Claude. A second time for an MCP tool when Claude loads it through [tool search](</docs/en/mcp#scale-with-mcp-tool-search>), with `e.description` set to the text Claude reads for the loaded tool.| `{ description }`, optionally with `isDeferred` set to `true` to put the tool behind tool search or `false` to load it upfront. Add `breakPromptCache: true` to send a changed description on the next turn.
####
@@ -99,7 +99,7 @@
`prompt.edit`| The user edits the prompt box| `next(e)`
`prompt.autocomplete`| The user types in the prompt box and a word ends at the cursor. `e.token` is that word. Claude Code doesn’t wait for the hook: its own autocomplete rows show first.| `{ suggestions }`, a list of `{ text, label, description }` rows shown below Claude Code’s own. Choosing a row writes its `text` over the word.
`prompt.compose`| Claude Code renders a system prompt| `{ sections }`, a list of `{ id, text, scope }` in the order they’re sent
-[`prompt.section`](</docs/en/plugins/mods/events#rewrite-or-add-to-a-prompt>)| Once for each named section of the system prompt. `e.name` is the section’s `id` in `prompt.compose`.| `{ text }`, or `{ text: null }` to omit the section
+[`prompt.section`](</docs/en/plugins/mods/events#rewrite-or-add-to-a-prompt>)| Once for each named section of the system prompt. `e.name` is the section’s `id` in `prompt.compose`.| `{ text }`, or `{ text: null }` to omit the section. Add `breakPromptCache: true` to send a changed section on the next turn.
[`prompt.context`](</docs/en/plugins/mods/events#rewrite-or-add-to-a-prompt>)| Once for each conversation, for the context sent with the first message| `{ blocks }`
`prompt.attachment`| Claude Code adds a message of its own for Claude, such as a reminder. `e.type` names the kind, and for the kinds the types declare, `e.detail` holds the facts the text was written from.| `{ text }`, or `{ text: null }` to omit it
`prompt.mention`| Claude Code is about to read a file that a prompt @-mentions. Requires Claude Code v2.1.290 or later.| `next({ ...e, path })` to read a different file, or `{ deny: reason }`
@@ -123,6 +123,14 @@
`e.frontmatterProblem`| string| The reason `e.frontmatter` is missing the file’s frontmatter or one of its keys, as in `is a list or a single value, not a table`. Absent when `e.frontmatter` holds the whole frontmatter or the skill has none.
A hook can pass a changed `text` or `frontmatter` to `next`: the hooks after it read both, and Claude reads the final `text`. A hook that changes any other field [fails](</docs/en/plugins/mods/events#handle-a-hook-that-fails>). On `skill.prompt`, `e.source`, `e.pluginName`, `e.path`, `e.frontmatter`, and `e.frontmatterProblem` require Claude Code v2.1.299 or later.
+
+####
+
+
+
+Send a changed system prompt section or tool description with `breakPromptCache`
+
+To change a section or a tool description in a running conversation, call `$.ui.invalidate('prompt.section')` or `$.ui.invalidate('tool.describe')` so your hook runs again. Return `{ text, breakPromptCache: true }` or `{ description, breakPromptCache: true }` from it. Without the field, Claude keeps reading the text [saved with the conversation](</docs/en/cli-reference#system-prompt-flags-in-resumed-conversations>) for a section or a tool loaded upfront until a new conversation or a [compaction](</docs/en/prompt-caching#compacting-the-conversation>). The changed text reaches Claude on the next turn, and the [prompt cache](</docs/en/prompt-caching>) starts over, so that turn is slower and more expensive. The field requires Claude Code v2.1.321 or later. From v2.1.299 until v2.1.321, a running conversation got the changed text on the next turn.
###
@@ -268,7 +276,8 @@
Namespace| Methods
---|---
`$.plugin`| `name`, `root`: this plugin’s name and directory
-[`$.ui`](</docs/en/plugins/mods/interface#pick-where-to-draw>)| `resolve`, `invalidate`, `open`, `close`, `panes`, `focus`, `scroll`, `toast`, `notify`, `status`, `log`, `notice`, `ask`, `copy`, `selection`, `blit`
+[`$.ui`](</docs/en/plugins/mods/interface#pick-where-to-draw>)| `resolve`, `invalidate`, `open`, `close`, `panes`, [`place`](</docs/en/plugins/mods/interface#place-a-row-in-the-transcript>), `focus`, `scroll`, `toast`, `notify`, `status`, `log`, `notice`, `ask`, `copy`, `selection`, `blit`, `view`. `view` requires Claude Code v2.1.300 or later and `place` v2.1.314 or later.
+[`$.theme`](</docs/en/plugins/mods/interface#put-a-backdrop-behind-the-conversation>)| `set`, `clear`: set a backdrop for the Desktop or mobile app to draw, and take the backdrop off. Requires Claude Code v2.1.319 or later.
[`$.command`](</docs/en/plugins/mods/api#add-a-command>)| `register`, `run`, `list`
[`$.tool`](</docs/en/plugins/mods/api#add-a-tool>)| `register`, `call`, `check`, `list`
`$.agent`| `register`, `spawn`, `list`. `list()` returns this session’s subagents and teammates, each with a `status` of `pending`, `running`, `waiting`, `idle`, `completed`, `failed`, or `killed`, where `idle` and `waiting` require Claude Code v2.1.289 or later.
@@ -301,15 +310,17 @@
---|---|---|---
[`Pane`](</docs/en/plugins/mods/interface#pick-where-to-draw>)| `title`, `isFocused`, `bodyColumns`, `placement`, `scroll`, `view`| The pane’s `id`| Terminal, Desktop, VS Code
[`AbovePrompt`](</docs/en/plugins/mods/interface#pick-where-to-draw>)| `hasSurvey`, `isWorking`, `maxRows`, `bodyColumns`, `scroll`, `view`| One instance| Terminal, Desktop
-`UserMessage`| `text`, `origin`, `isExpanded`, and `task` or `from` by origin| The message id| Terminal, Desktop, VS Code
-`AssistantMessage`| The reply’s text| The message id| Terminal, Desktop, VS Code
+[`Placed`](</docs/en/plugins/mods/interface#place-a-row-in-the-transcript>)| `id`, `plugin`, `onScreen`| The `requestId` that `$.ui.place` returned| Terminal
+[`Backdrop`](</docs/en/plugins/mods/interface#put-a-backdrop-behind-the-conversation>)| `id`, `plugin`, `glass`, `colorScheme`| `backdrop`| `desktop` and `mobile` surfaces. Your hook runs when the Desktop or mobile app asks to draw a backdrop.
+`UserMessage`| `text`, `origin`, `isExpanded`, and `task` or `from` by origin| The drawn row’s id| Terminal, Desktop, VS Code
+`AssistantMessage`| The reply’s text| The drawn row’s id| Terminal, Desktop, VS Code
`ToolUse`, `ToolResult`, `ToolGroup`| The tool’s name, input, and result| The tool call id| Terminal, Desktop, VS Code
-`CommandOutput`| `command`, `text`| The message id| Terminal, Desktop
+`CommandOutput`| `command`, `text`| The drawn row’s id| Terminal, Desktop
[`AskUserQuestion`](</docs/en/plugins/mods/interface#change-what-claude-code-already-draws>)| The question and options| The tool call id| Terminal, Desktop, VS Code
`ToolProgress`| `kind`| The tool call id| Terminal
[`Spinner`](</docs/en/plugins/mods/interface#change-what-claude-code-already-draws>)| `word`, `message`, `suffix`, `mode`| The agent id| Terminal, Desktop, VS Code
-`TurnDuration`| `word`, `durationMs`| The message id| Terminal
-`InfoNotice`| `text`, `command`| The message id| Terminal
+`TurnDuration`| `word`, `durationMs`| The drawn row’s id| Terminal
+`InfoNotice`| `text`, `command`| The notice’s `text` prefixed with `notice:`| Terminal
`SessionMode`| `modes`| One instance| Terminal, Desktop
`PromptHint`| `isDraft`, `isWorking`, `hint`| One instance| Terminal, Desktop
@@ -471,11 +482,12 @@
`$.ui.invalidate('ui.render')` redraws| Throttled to 10 a second, or 30 in the terminal for the visible pane, the expanded band, and the hint line under the prompt. Calls that come sooner are coalesced.
`$.ui.toast`| Shown for 4 seconds unless you pass `{ timeoutMs }`. In the [classic renderer](</docs/en/fullscreen#enable-fullscreen-rendering>), a mod’s newer toast can [take the place of its older one](</docs/en/plugins/mods/troubleshoot#a-toast-doesn%E2%80%99t-appear>) that’s showing or waiting to show.
A pane opened without the user asking| Placed from 144 terminal columns, 110 after they’ve opened it once
+Rows from `$.ui.place` that one mod has in a conversation at one time| 500\. At the limit, a call with a new `id` resolves to `{ isPlaced: false, reason: 'a plugin holds at most 500 placed rows' }`.
Nesting depth of a mods API call’s arguments| 28,000 levels. Past that, the call rejects with a message ending `nesting deeper than 28000 levels is not supported`. Requires Claude Code v2.1.299 or later.
Nesting depth of a changed event passed to `next`, outside async generator hooks such as one on `turn.step`| 28,000 levels. Past that, `next` rejects with a message ending `nesting deeper than 28000 levels is not supported`. Requires Claude Code v2.1.299 or later.
Nesting depth of a hook’s return value, outside `ui.render`, `ui.resolve`, and async generator hooks| 28,000 levels. Past that, the hook’s result is refused, and [the notice that reports it](</docs/en/plugins/mods/troubleshoot#find-out-why-a-mod-does-nothing>) includes `nesting deeper than 28000 levels is not supported`. Requires Claude Code v2.1.299 or later.
Scopes, such as functions, blocks, and loops, nested inside one another in one file of a hooks module| 2,000
-Command, tool, subagent type, and pane names| Letters, digits, `_`, and `-`, up to 64 characters
+Command, tool, subagent type, and pane names, and the `id` of a placed row or a backdrop| Letters, digits, `_`, and `-`, up to 64 characters
One `claude plugin test` test| 5 seconds unless the test sets `timeoutMs`
##
@@ -490,15 +502,15 @@
---|---|---
`CLAUDE_CODE_PLUGIN_DIRS`| Environment, or `env` in `~/.claude/settings.json`| Plugin directories to load as `--plugin-dir` does, for apps you can’t pass a flag to. Absolute paths separated by `:`, or `;` on Windows.
`CLAUDE_CODE_PLUGIN_DIR_WATCH`| Environment| `1` makes a long-running non-interactive session reload `--plugin-dir` mods on save
-`prependPlugins`, `appendPlugins`| Managed settings. User settings only on a machine with no managed settings, in a session whose credential isn’t a Team or Enterprise `/login`.| Lists of plugin ids, such as `acme-guard@acme-tools`. Mods in `prependPlugins` run before every mod a user installs, and mods in `appendPlugins` run after, in the listed order. See [The order mods run in](</docs/en/plugins/mods/events#the-order-mods-run-in>).
+`prependPlugins`, `appendPlugins`| Managed settings. User settings only on a machine with no managed settings or [`managed-mcp.json`](</docs/en/managed-mcp#deploy-managed-mcp-json>) file, in a session whose credential isn’t a Team or Enterprise `/login`.| Lists of plugin ids, such as `acme-guard@acme-tools`. Mods in `prependPlugins` run before every mod a user installs, and mods in `appendPlugins` run after, in the listed order. See [The order mods run in](</docs/en/plugins/mods/events#the-order-mods-run-in>).
`allowManagedModsOnly`| Managed settings, as an [option on the built-in guard](</docs/en/plugins/mods/admin#set-options-on-the-built-in-guard>)| Only mods that [count as your organization’s](</docs/en/plugins/mods/admin#install-your-organizations-mods>), and mods built into Claude Code, run their hooks. Users’ settings hooks keep running.
-`allowModsToOverrideDenyRules`| Managed settings, as an [option on the built-in guard](</docs/en/plugins/mods/admin#set-options-on-the-built-in-guard>)| Lets a mod a user installed approve a tool call that a `deny` rule refuses
+`allowModsToOverrideDenyRules`| Managed settings, as an [option on the built-in guard](</docs/en/plugins/mods/admin#set-options-on-the-built-in-guard>)| Lets a mod a user installed approve a tool call past most of [the outcomes that stay in place by default](</docs/en/permissions#precedence-among-rules-hooks-and-mods>), including a `deny` rule
`allowManagedHooksOnly`| Managed settings| Blocks hooks and installed mods that aren’t your organization’s. See [what keeps running](</docs/en/settings-reference#what-runs-under-allowmanagedhooksonly>).
`disableAllHooks`| Any settings file| In managed settings, no mod or hook from an installed plugin runs. In your own settings, what your organization manages keeps running. See [`disableAllHooks`](</docs/en/settings-reference#disableallhooks>).
`disableSideloadFlags`| Managed settings| Rejects `--plugin-dir` and `--plugin-url` at startup
`pluginConfigs`| User or managed settings| Holds `userConfig` values for a mod, keyed by the plugin’s id, such as `acme-guard@acme-tools`, or its name and `@inline`, such as `first-mod@inline`, for one loaded with `--plugin-dir`
-`sec-default@builtin` is a guard built into Claude Code, listed as `cc-plugin-sec-default` in `/plugin` and the debug log. It loads ahead of every mod a person installs on a machine with managed settings, or in a session whose credential is a Team or Enterprise [`/login`](</docs/en/authentication#authentication-precedence>). If managed `prependPlugins` is set, the guard loads only when that list names it, at the position listed. Its source is in the [`mods/sec-default` directory of the Claude Code repository](<https://github.com/anthropics/claude-code/tree/main/mods/sec-default>).
+`sec-default@builtin` is a guard built into Claude Code, listed as `cc-plugin-sec-default` in `/plugin` and the debug log. [Where it loads](</docs/en/plugins/mods/admin#know-what-happens-by-default>), it runs ahead of every mod a person installs. If managed `prependPlugins` is set, the guard loads only when that list names it, at the position listed. Its source is in the [`mods/sec-default` directory of the Claude Code repository](<https://github.com/anthropics/claude-code/tree/main/mods/sec-default>).
##
--- a/reference.md
+++ b/reference.md
@@ -190,9 +190,11 @@
Event| Fires when| A hook can return
---|---|---
`agent.offer`| A subagent type is offered to Claude| `{ isOffered: false }` to withhold it
-`agent.spawn`| A subagent or an [agent team](</docs/en/agent-teams>) teammate is about to start. For a teammate, `e.isTeammate` is `true`.| `next({ ...e, model })` to choose its model, or `{ deny: reason }`
-
-When Claude resumes a subagent with the [`SendMessage`](</docs/en/sub-agents#resume-subagents>) tool, your `agent.spawn` hook doesn’t run again. To refuse the `SendMessage` calls that resume a subagent, match that tool in a [`tool.call`](</docs/en/plugins/mods/events#guard-or-change-a-tool-call>) hook.
+`agent.spawn`| A subagent or an [agent team](</docs/en/agent-teams>) teammate is about to start, or a subagent that finished or stopped is about to run again. For a teammate, `e.isTeammate` is `true`. For a resumed run, `e.resume` is set.| `next({ ...e, model })` to choose the model of one that is starting, or `{ deny: reason }`
+
+Your `agent.spawn` hook also runs when a subagent that finished or stopped is about to run again, such as when Claude sends it a message with the [`SendMessage`](</docs/en/sub-agents#resume-subagents>) tool. On that event, `e.resume` is `{ agentId }`. If your hook counts subagents, skip the events where `e.resume` is set, so a resumed subagent isn’t counted again. Return `{ deny: reason }` to refuse a resumed run. The run doesn’t start, and the subagent stays as it was. When a `SendMessage` call asked for the run, Claude reads `a plugin declined the resume:` followed by your reason as that call’s result. If you pass a changed event to `next` for a resumed run, such as a different `model`, Claude Code ignores the change.
+
+The event for a resumed run requires Claude Code v2.1.299 or later. Before v2.1.299, your `agent.spawn` hook didn’t run when a subagent resumed. On those versions, to refuse the `SendMessage` calls that resume a subagent, match that tool in a [`tool.call`](</docs/en/plugins/mods/events#guard-or-change-a-tool-call>) hook.
###
--- a/reference.md
+++ b/reference.md
@@ -130,15 +130,13 @@
Commands and configuration
-Command and configuration events fire when a command runs or is listed, when a `/config` row is shown or changed, and on a settings read:
-
Event| Fires when| A hook can return
---|---|---
[`command.run`](</docs/en/plugins/mods/api#add-a-command>)| A command is about to run| `{ text }`, `{}`, or `next(e)`
`command.describe`| Once for each command, for the command list| `{ description, argumentHint, isHidden }`
`config.set`| A `/config` row is about to change| `next({ ...e, value })` or `{ deny: reason }`
`config.describe`| Once for each `/config` row| `{ label, description, isHidden }`
-[`settings.read`](</docs/en/plugins/mods/events#settings-read-hook>)| A mod calls [`$.settings.read`](</docs/en/plugins/mods/api#reach-files-processes-and-the-network>), or Claude Code builds the session’s merged settings| `next(e)`, `{ value }`, or `{ deny: reason }`
+[`settings.read`](</docs/en/plugins/mods/events#settings-read-hook>)| A mod calls [`$.settings.read`](</docs/en/plugins/mods/api#reach-files-processes-and-the-network>), or Claude Code builds the session’s merged settings. Requires Claude Code v2.1.304 or later on Claude Code’s own read and for `e.layers`| `next(e)`, `{ value }`, or `{ deny: reason }`
####
@@ -147,9 +145,7 @@
`e.layers` and `e.source` on `settings.read`
* **`e.layers`** : one `{ source, settings }` object for each source in use that holds settings, lowest [precedence](</docs/en/settings#settings-precedence>) first. See [What a `settings.read` hook receives](</docs/en/plugins/mods/events#settings-read-receives>).
- * **`e.source`** : the one source a mod asked for, as in `$.settings.read({ source: 'policy' })`. Absent on Claude Code’s own read and on any other read of the merged settings
-
-On `settings.read`, the event firing on Claude Code’s own read and the `e.layers` field require Claude Code v2.1.304 or later. For when the hook runs and what the hook can return, with an example, see [Change or refuse a settings read](</docs/en/plugins/mods/events#settings-read-hook>).
+ * **`e.source`** : the one source a mod asked for, as in `$.settings.read({ source: 'policy' })`. Absent on Claude Code’s own read and on a read of the merged settings
###
@@ -335,7 +331,7 @@
---|---|---|---|---
[`Box`](</docs/en/plugins/mods/interface#build-a-tree-from-elements>)| `key`, flex layout, `gap`, `padding`, `margin`, `width`, `height`, `minWidth`, `minHeight`, `borderStyle`, `borderColor`, `borderDimColor`, `backgroundColor`, `position`, `top`, `left`, `right`, `bottom`, `overflow`, `display`, `hover`| ✓| ✓| ✓
[`Text`](</docs/en/plugins/mods/interface#build-a-tree-from-elements>)| `color`, `backgroundColor`, `bold`, `italic`, `underline`, `strikethrough`, `dimColor`, `inverse`, `wrap`, `size`, `weight`, `mono`, `tabular`, `hover`| ✓| ✓| ✓
-[`Button`](</docs/en/plugins/mods/interface#respond-to-presses-and-typing>)| `key`, `label`, `onPress`, `hotkey`, `plain`, `dimColor`, `autoFocus`, `action`, `hover`| ✓| ✓| ✓
+[`Button`](</docs/en/plugins/mods/interface#respond-to-presses-and-typing>)| `key`, `label`, `children`, `onPress`, `hotkey`, `plain`, `dimColor`, `autoFocus`, `action`, `variant`, `role`, `hover`| ✓| ✓| ✓
[`Link`](</docs/en/plugins/mods/interface#link-in-the-desktop-app>)| `href`, `label`. See Limits.| ✓| ✓| ✓
[`Code`](</docs/en/plugins/mods/gallery#show-code-and-changes>)| `source`, `language`, `path`, `startLine`, `format`, `wrap`| ✓| ✓| ✓
`Markdown`| `text`, `key`, `dimColor`, `onLinkPress`, `pressableLinks`| ✓| ✓| ✓
@@ -352,14 +348,25 @@
* **Digit hotkeys on the band** : a digit `hotkey` on a button in the band also fires when the user types that digit alone into an empty prompt and pauses
* **A collapsed band** : while the band is [collapsed](</docs/en/plugins/mods/interface#when-the-user-collapses-the-band>), neither an `action` binding nor a hotkey presses a button in it
* **Two buttons on one hotkey** : when two buttons in one drawing name the same `hotkey`, the later one gets it
+ * **`variant`** : `primary` or `secondary`, and any other value throws. In the terminal, a `primary` button draws in the accent color unless it’s `plain`.
+ * **`role`** : `dismiss` marks a close button, and any other value throws. Do the closing in your `onPress`. In a band that holds text and a row of buttons, the Desktop app can draw the row’s first `dismiss` button as its own close control. The terminal draws the button as it would without `role`.
+
+A `Button` can hold `children` in place of a `label`:
+
+ * **What children can be** : strings and `Text` elements, such as a name followed by a dim detail or a colored chip. Claude Code refuses any other element inside a `Button`.
+ * **Naming the button** : the `label` names the button and defaults to the text of its children. Give a button with children other than one string a `key` or a `label`.
+ * **In the terminal** : the children draw where the label would be, and a press anywhere on them counts as one press, so you can make each row of a list a single button
+ * **In the Desktop app and the VS Code extension** : the button draws its `label`
+
+A `Button` with children other than a single string requires Claude Code v2.1.295 or later.
`autoFocus` accepts only `true` on any control, so omit the prop to leave it off. The VS Code extension ignores some element props and draws the element as if you had left them out:
* **`Box`** : `position` with its `top`, `left`, `right`, and `bottom`, `alignSelf`, `borderDimColor`, and `hover`
* **`Text`** : `size`, `mono`, `tabular`, and `hover`
- * **`Button`** : `hotkey`, `plain`, `autoFocus`, `action`, and `hover`, so the user presses a button there with a click, or with Enter once it has focus
+ * **`Button`** : `hotkey`, `plain`, `autoFocus`, `action`, and `hover`, so the user presses a button there with a click, or with Enter once it has focus. The extension also ignores `variant` and `role`.
* **`Code`** : `language`, `path`, `startLine`, `format`, and `wrap`, so code draws without colors or line numbers, and a `format: 'diff'` block shows the diff’s raw text
- * **`Input` and `Select`**: `autoFocus`
+ * **`Input` and `Select`**: `autoFocus`, and `rows` on an `Input`
* **`Svg`** : `isInteractive`
###
@@ -442,6 +449,7 @@
A `.catch` handler’s execution time| 1 second
All `session.end` hooks together| As long as the [SessionEnd hook budget](</docs/en/hooks#sessionend-input>), 1.5 seconds unless you change it, counted from when your settings `SessionEnd` hooks finish
`$.process.run` timeout| 30 seconds by default, 10 minutes at most
+`$.process.run` `stdout` and `stderr`| 4 MiB each. `isStdoutTruncated` or `isStderrTruncated` is `true` when one was cut.
`$.model.complete` `maxTokens`| 1024 by default, up to 64,000 or the model’s output limit
`$.fs.read` and `$.fs.write`| 4 MiB for one file
A `$.http.fetch` request body| 4 MiB, counted in characters. A call with a larger body rejects.
@@ -459,8 +467,11 @@
`$.store`| 4 MiB of JSON in total
`$.session.messages()`| The newest 4,096 entries
`$.ui.invalidate('ui.render')` redraws| Throttled to 10 a second, or 30 in the terminal for the visible pane, the expanded band, and the hint line under the prompt. Calls that come sooner are coalesced.
-`$.ui.toast`| Shown for 4 seconds unless you pass `{ timeoutMs }`
+`$.ui.toast`| Shown for 4 seconds unless you pass `{ timeoutMs }`. In the [classic renderer](</docs/en/fullscreen#enable-fullscreen-rendering>), a mod’s newer toast can [take the place of its older one](</docs/en/plugins/mods/troubleshoot#a-toast-doesn%E2%80%99t-appear>) that’s showing or waiting to show.
A pane opened without the user asking| Placed from 144 terminal columns, 110 after they’ve opened it once
+Nesting depth of a mods API call’s arguments| 28,000 levels. Past that, the call rejects with a message ending `nesting deeper than 28000 levels is not supported`. Requires Claude Code v2.1.299 or later.
+Nesting depth of a changed event passed to `next`, outside async generator hooks such as one on `turn.step`| 28,000 levels. Past that, `next` rejects with a message ending `nesting deeper than 28000 levels is not supported`. Requires Claude Code v2.1.299 or later.
+Nesting depth of a hook’s return value, outside `ui.render`, `ui.resolve`, and async generator hooks| 28,000 levels. Past that, the hook’s result is refused, and [the notice that reports it](</docs/en/plugins/mods/troubleshoot#find-out-why-a-mod-does-nothing>) includes `nesting deeper than 28000 levels is not supported`. Requires Claude Code v2.1.299 or later.
Scopes, such as functions, blocks, and loops, nested inside one another in one file of a hooks module| 2,000
Command, tool, subagent type, and pane names| Letters, digits, `_`, and `-`, up to 64 characters
One `claude plugin test` test| 5 seconds unless the test sets `timeoutMs`
--- a/reference.md
+++ b/reference.md
@@ -339,7 +339,7 @@
[`Link`](</docs/en/plugins/mods/interface#link-in-the-desktop-app>)| `href`, `label`. See Limits.| ✓| ✓| ✓
[`Code`](</docs/en/plugins/mods/gallery#show-code-and-changes>)| `source`, `language`, `path`, `startLine`, `format`, `wrap`| ✓| ✓| ✓
`Markdown`| `text`, `key`, `dimColor`, `onLinkPress`, `pressableLinks`| ✓| ✓| ✓
-[`Input`](</docs/en/plugins/mods/interface#take-typed-input-and-draw-a-row-for-each-item>)| `key`, `label`, `placeholder`, `value`, `submitLabel`, `onSubmit`, `onInput`, `autoFocus`| ✓| ✓| ✓
+[`Input`](</docs/en/plugins/mods/interface#take-typed-input-and-draw-a-row-for-each-item>)| `key`, `label`, `placeholder`, `value`, `submitLabel`, [`rows`](</docs/en/plugins/mods/gallery#input>), `onSubmit`, `onInput`, `autoFocus`| ✓| ✓| ✓
`Select`| `key`, `label`, `options`, `value`, `onSelect`, `autoFocus`| ✓| ✓| ✓
`Svg`| a `source` of SVG markup up to 131,072 characters, `alt` text, `width`, `height`, and `isInteractive`| | ✓| ✓
[`Client`](</docs/en/plugins/mods/interface#build-a-tree-from-elements>)| `module`, `key`, `props`, `width`, `height`, `flexGrow`| ✓| ✓|
@@ -401,7 +401,7 @@
`'lg'`| 3| 1
`'xl'`| 4| 2
-If you set `gap`, `padding`, or `margin` to a step, the step applies across and down at once. For example, in the terminal and the VS Code extension, `padding: 'md'` is two cells at each side and one row above and below. Step names require Claude Code v2.1.299 or later. On an earlier release, Claude Code [draws its own version of the site](</docs/en/plugins/mods/interface#build-a-tree-from-elements>) in place of a tree that uses a step name.
+If you set `gap`, `padding`, or `margin` to a step, the step applies across and down at once. For example, in the terminal and the VS Code extension, `padding: 'md'` is two cells at each side and one row above and below. Step names require Claude Code v2.1.299 or later. On an earlier release, a tree that uses a step name doesn’t draw.
###
@@ -418,7 +418,7 @@
`mono`| `true` to ask for the app’s monospaced typeface| Ignored: the terminal is always monospaced| Ignored, so text keeps the extension’s own typeface
`tabular`| `true` to ask for digits of equal width, so that a number that updates in place or a column of numbers stays aligned| Ignored: the terminal’s digits are already one cell wide| Ignored
-These four props require Claude Code v2.1.299 or later. On an earlier release, Claude Code [draws its own version of the site](</docs/en/plugins/mods/interface#build-a-tree-from-elements>) in place of a tree that sets `size`, `weight`, `mono`, or `tabular`.
+These four props require Claude Code v2.1.299 or later. On an earlier release, a tree that sets `size`, `weight`, `mono`, or `tabular` doesn’t draw.
####
@@ -426,7 +426,7 @@
Replace `bold` with `weight`
-`bold` on a `Text` is deprecated in favor of `weight` and still works. To replace it on a `Text` with no `weight`, change `bold: true` to `weight: 'semibold'` for the same result on Claude Code v2.1.299 or later. On a release earlier than v2.1.299, a tree that sets `weight` doesn’t draw, and Claude Code [draws its own version of the site](</docs/en/plugins/mods/interface#build-a-tree-from-elements>) instead. If you set both `bold` and `weight` on a `Text`, `bold` has no effect.
+`bold` on a `Text` is deprecated in favor of `weight` and still works. To replace it on a `Text` with no `weight`, change `bold: true` to `weight: 'semibold'` for the same result on Claude Code v2.1.299 or later. On a release earlier than v2.1.299, a tree that sets `weight` doesn’t draw. If you set both `bold` and `weight` on a `Text`, `bold` has no effect.
##
@@ -434,7 +434,7 @@
Limits
-Hooks and mods API calls run under time and size limits. Claude Code skips a hook that exceeds a time limit.
+Hooks and mods API calls run under time and size limits. Claude Code skips a hook that exceeds a time limit. A tree over the nesting, element, `Raster` cell, or `Image` byte limit [isn’t drawn](</docs/en/plugins/mods/troubleshoot#a-pane-or-band-is-empty>).
Limit| Value
---|---
@@ -450,8 +450,12 @@
Redirects one `$.http.fetch` call follows| 5
A hook’s `drop` reason or `config.set` `deny` reason| 4,096 characters. The end of a longer reason is cut, and the drop or deny still applies. The cut requires Claude Code v2.1.292 or later, and on earlier versions the hook [fails](</docs/en/plugins/mods/events#handle-a-hook-that-fails>) instead.
Text in one tree| The first 100,000 characters are drawn
-A `Code`’s `language` or `path`, a `Select` option’s `value`, or a `Client`’s `module`| 10,000 characters. If one is longer, Claude Code [draws its own version of the site](</docs/en/plugins/mods/interface#build-a-tree-from-elements>).
-A `Link`’s `href`| 2,048 characters. A longer `href` keeps the whole tree from drawing.
+A `Code`’s `language` or `path`, a `Select` option’s `value`, or a `Client`’s `module`| 10,000 characters. If one is longer, the `ui.render` hook that returned it [fails](</docs/en/plugins/mods/events#handle-a-hook-that-fails>).
+A `Link`’s `href`| 2,048 characters. If it’s longer, the `ui.render` hook that returned it [fails](</docs/en/plugins/mods/events#handle-a-hook-that-fails>).
+Nesting depth of one tree| 32 levels below the root element
+Elements and text children in one tree| 20,000
+`Raster` cells in one tree, each `Raster`’s `columns` times its `rows`| 262,144
+PNG or RGBA bytes of all the `Image`s in one tree| 2 MiB
`$.store`| 4 MiB of JSON in total
`$.session.messages()`| The newest 4,096 entries
`$.ui.invalidate('ui.render')` redraws| Throttled to 10 a second, or 30 in the terminal for the visible pane, the expanded band, and the hint line under the prompt. Calls that come sooner are coalesced.
--- a/reference.md
+++ b/reference.md
@@ -15,7 +15,7 @@
`.claude-plugin/plugin.json`| Yes| The plugin [manifest](</docs/en/plugins/manifest-reference>). Mods add no required fields.
`hooks/hooks.json`| Yes| `modules`: an array with one path, relative to this file, to the hooks module, as in `"modules": ["./register.js"]`. Can also hold [settings hooks](</docs/en/hooks>) under `hooks`.
The hooks module, such as [`hooks/register.js`](</docs/en/plugins/mods/create#write-a-mod-yourself>)| Yes| The mod’s entry point. Exports `register(on, options)`. Named `.js`, `.mjs`, `.cjs`, `.jsx`, `.ts`, `.mts`, `.cts`, or `.tsx`. An ES module.
-[`types/index.d.ts`](</docs/en/plugins/mods/interface#declare-the-values>), named by `types` in the manifest| When the mod uses `$.state` or adds a namespace to the mods API| Declares `PluginState` values and any namespace the mod adds
+[`types/index.d.ts`](</docs/en/plugins/mods/interface#declare-the-values>), unless `types` in the manifest names another path| When the mod uses `$.state` or adds a namespace to the mods API| Declares `PluginState` values and any namespace the mod adds. To leave `types` out of the manifest, you need v2.1.299 or later.
Files whose names end in `.test.ts` or `.test.tsx`| No| Tests that [`claude plugin test`](</docs/en/plugins/mods/test#write-a-test>) runs
`register` receives `on` and `options`. `options` holds the values of the [`userConfig`](</docs/en/plugins/components#user-configuration>) fields the manifest declares, with defaults filled in.
@@ -130,7 +130,7 @@
Commands and configuration
-Command and configuration events fire when a command runs or is listed, and when a `/config` row is shown or changed:
+Command and configuration events fire when a command runs or is listed, when a `/config` row is shown or changed, and on a settings read:
Event| Fires when| A hook can return
---|---|---
@@ -138,6 +138,18 @@
`command.describe`| Once for each command, for the command list| `{ description, argumentHint, isHidden }`
`config.set`| A `/config` row is about to change| `next({ ...e, value })` or `{ deny: reason }`
`config.describe`| Once for each `/config` row| `{ label, description, isHidden }`
+[`settings.read`](</docs/en/plugins/mods/events#settings-read-hook>)| A mod calls [`$.settings.read`](</docs/en/plugins/mods/api#reach-files-processes-and-the-network>), or Claude Code builds the session’s merged settings| `next(e)`, `{ value }`, or `{ deny: reason }`
+
+####
+
+
+
+`e.layers` and `e.source` on `settings.read`
+
+ * **`e.layers`** : one `{ source, settings }` object for each source in use that holds settings, lowest [precedence](</docs/en/settings#settings-precedence>) first. See [What a `settings.read` hook receives](</docs/en/plugins/mods/events#settings-read-receives>).
+ * **`e.source`** : the one source a mod asked for, as in `$.settings.read({ source: 'policy' })`. Absent on Claude Code’s own read and on any other read of the merged settings
+
+On `settings.read`, the event firing on Claude Code’s own read and the `e.layers` field require Claude Code v2.1.304 or later. For when the hook runs and what the hook can return, with an example, see [Change or refuse a settings read](</docs/en/plugins/mods/events#settings-read-hook>).
###
--- a/reference.md
+++ b/reference.md
@@ -321,26 +321,34 @@
Element| Main props| Terminal| Desktop| VS Code
---|---|---|---|---
-[`Box`](</docs/en/plugins/mods/interface#build-a-tree-from-elements>)| `key`, flex layout, `gap`, `padding`, `margin`, `width`, `height`, `borderStyle`, `backgroundColor`, `position`, `hover`| ✓| ✓| ✓
-[`Text`](</docs/en/plugins/mods/interface#build-a-tree-from-elements>)| `color`, `backgroundColor`, `bold`, `italic`, `underline`, `dimColor`, `inverse`, `wrap`, `size`, `weight`, `mono`, `tabular`| ✓| ✓| ✓
-[`Button`](</docs/en/plugins/mods/interface#respond-to-presses-and-typing>)| `key`, `label`, `onPress`, `hotkey`, `plain`, `dimColor`, `autoFocus`, `action`| ✓| ✓| ✓
+[`Box`](</docs/en/plugins/mods/interface#build-a-tree-from-elements>)| `key`, flex layout, `gap`, `padding`, `margin`, `width`, `height`, `minWidth`, `minHeight`, `borderStyle`, `borderColor`, `borderDimColor`, `backgroundColor`, `position`, `top`, `left`, `right`, `bottom`, `overflow`, `display`, `hover`| ✓| ✓| ✓
+[`Text`](</docs/en/plugins/mods/interface#build-a-tree-from-elements>)| `color`, `backgroundColor`, `bold`, `italic`, `underline`, `strikethrough`, `dimColor`, `inverse`, `wrap`, `size`, `weight`, `mono`, `tabular`, `hover`| ✓| ✓| ✓
+[`Button`](</docs/en/plugins/mods/interface#respond-to-presses-and-typing>)| `key`, `label`, `onPress`, `hotkey`, `plain`, `dimColor`, `autoFocus`, `action`, `hover`| ✓| ✓| ✓
[`Link`](</docs/en/plugins/mods/interface#link-in-the-desktop-app>)| `href`, `label`. See Limits.| ✓| ✓| ✓
[`Code`](</docs/en/plugins/mods/gallery#show-code-and-changes>)| `source`, `language`, `path`, `startLine`, `format`, `wrap`| ✓| ✓| ✓
`Markdown`| `text`, `key`, `dimColor`, `onLinkPress`, `pressableLinks`| ✓| ✓| ✓
[`Input`](</docs/en/plugins/mods/interface#take-typed-input-and-draw-a-row-for-each-item>)| `key`, `label`, `placeholder`, `value`, `submitLabel`, `onSubmit`, `onInput`, `autoFocus`| ✓| ✓| ✓
`Select`| `key`, `label`, `options`, `value`, `onSelect`, `autoFocus`| ✓| ✓| ✓
-`Svg`| An SVG document, up to 131,072 characters| | ✓| ✓
-[`Client`](</docs/en/plugins/mods/interface#build-a-tree-from-elements>)| `module`, `key`| ✓| ✓|
+`Svg`| a `source` of SVG markup up to 131,072 characters, `alt` text, `width`, `height`, and `isInteractive`| | ✓| ✓
+[`Client`](</docs/en/plugins/mods/interface#build-a-tree-from-elements>)| `module`, `key`, `props`, `width`, `height`, `flexGrow`| ✓| ✓|
[`Raster`](</docs/en/plugins/mods/interface#draw-a-grid-of-colored-cells>)| `key`, `columns` up to 512, `rows` up to 256, `cells`. See [Draw a grid of colored cells](</docs/en/plugins/mods/interface#draw-a-grid-of-colored-cells>).| ✓| |
-`Image`| PNG or RGBA bytes up to 2 MiB, or a file path, `columns` and `rows` up to 255, and `alt` text. See [which terminals draw it](</docs/en/plugins/mods/gallery#image-and-client>).| ✓| |
-
-More `Button` rules: `action` names one of Claude Code’s own [keybinding actions](</docs/en/keybindings>), and the user’s binding for it presses the button when that binding is a chord or a modified key. A digit `hotkey` on a button in the band also fires when the user types that digit alone into an empty prompt and pauses. When two buttons in one drawing name the same `hotkey`, the later one gets it. `autoFocus` accepts only `true` on any control, so omit the prop to leave it off. The VS Code extension ignores some element props and draws the element as if you had left them out:
-
- * **`Box`** : `position` and `hover`
- * **`Text`** : `size`, `mono`, and `tabular`
- * **`Button`** : `hotkey`, `plain`, `autoFocus`, and `action`, so the user presses a button there with a click, or with Enter once it has focus
+`Image`| `key`, a `source` such as PNG or RGBA bytes up to 2 MiB, or a file path, `columns` and `rows` up to 255, and `alt` text. See [which terminals draw it](</docs/en/plugins/mods/gallery#image-and-client>).| ✓| |
+
+More `Button` rules:
+
+ * **`action`** : names one of Claude Code’s own [keybinding actions](</docs/en/keybindings>), and the user’s binding for it presses the button when that binding is a chord or a modified key
+ * **Digit hotkeys on the band** : a digit `hotkey` on a button in the band also fires when the user types that digit alone into an empty prompt and pauses
+ * **A collapsed band** : while the band is [collapsed](</docs/en/plugins/mods/interface#when-the-user-collapses-the-band>), neither an `action` binding nor a hotkey presses a button in it
+ * **Two buttons on one hotkey** : when two buttons in one drawing name the same `hotkey`, the later one gets it
+
+`autoFocus` accepts only `true` on any control, so omit the prop to leave it off. The VS Code extension ignores some element props and draws the element as if you had left them out:
+
+ * **`Box`** : `position` with its `top`, `left`, `right`, and `bottom`, `alignSelf`, `borderDimColor`, and `hover`
+ * **`Text`** : `size`, `mono`, `tabular`, and `hover`
+ * **`Button`** : `hotkey`, `plain`, `autoFocus`, `action`, and `hover`, so the user presses a button there with a click, or with Enter once it has focus
* **`Code`** : `language`, `path`, `startLine`, `format`, and `wrap`, so code draws without colors or line numbers, and a `format: 'diff'` block shows the diff’s raw text
* **`Input` and `Select`**: `autoFocus`
+ * **`Svg`** : `isInteractive`
###
--- a/reference.md
+++ b/reference.md
@@ -60,7 +60,7 @@
Event| Fires when| A hook can return
---|---|---
[`tool.call`](</docs/en/plugins/mods/events#guard-or-change-a-tool-call>)| A tool is about to run| `next(e)`, `{ deny: reason }`, or `{ result }`
-[`tool.check`](</docs/en/plugins/mods/events#where-settings-hooks-run-in-the-order>)| Claude Code decides whether a tool call may run, after the `tool.call` and `PreToolUse` hooks. `next(e)` resolves to the decision the rules, the permission mode, and those hooks reached.| `{ decision }`, which is `allow`, `ask`, or `deny`
+[`tool.check`](</docs/en/plugins/mods/events#where-settings-hooks-run-in-the-order>)| Claude Code decides whether a tool call may run, after the `tool.call` and `PreToolUse` hooks. `next(e)` resolves to the decision the rules, the permission mode, and those hooks reached.| `next(e)` or `{ decision }`, with `decision` set to `allow`, `ask`, or `deny` and an optional `reason`
`tool.describe`| Once for each tool, when its description is first sent to Claude. A second time for an MCP tool when Claude loads it through [tool search](</docs/en/mcp#scale-with-mcp-tool-search>), with `e.description` set to the text Claude reads for the loaded tool.| `{ description }`, optionally with `isDeferred` set to `true` to put the tool behind tool search or `false` to load it upfront
####
@@ -75,6 +75,14 @@
* **`e.ceiling`** : `ask` for a connector tool your organization set to `ask`, in [sessions where that setting reaches Claude Code](</docs/en/mcp#organization-controls-on-connector-tools>)
On `tool.check`, `e.agentId` and `e.ceiling` require Claude Code v2.1.290 or later.
+
+####
+
+
+
+The `e.isReadOnly` field on `tool.check`
+
+In a `tool.check` hook, `e.isReadOnly` is `true` when the tool reports this call as read-only. Otherwise the field is absent, not `false`. The value is the tool’s own report, so read [Check whether a tool call is read-only](</docs/en/plugins/mods/events#check-whether-a-tool-call-is-read-only>) before you approve a call on this field alone. On `tool.check`, `e.isReadOnly` requires Claude Code v2.1.304 or later.
###
@@ -250,7 +258,7 @@
Namespace| Methods
---|---
`$.plugin`| `name`, `root`: this plugin’s name and directory
-[`$.ui`](</docs/en/plugins/mods/interface#pick-where-to-draw>)| `resolve`, `invalidate`, `open`, `close`, `panes`, `focus`, `scroll`, `toast`, `status`, `log`, `notice`, `ask`, `copy`, `selection`, `blit`
+[`$.ui`](</docs/en/plugins/mods/interface#pick-where-to-draw>)| `resolve`, `invalidate`, `open`, `close`, `panes`, `focus`, `scroll`, `toast`, `notify`, `status`, `log`, `notice`, `ask`, `copy`, `selection`, `blit`
[`$.command`](</docs/en/plugins/mods/api#add-a-command>)| `register`, `run`, `list`
[`$.tool`](</docs/en/plugins/mods/api#add-a-tool>)| `register`, `call`, `check`, `list`
`$.agent`| `register`, `spawn`, `list`. `list()` returns this session’s subagents and teammates, each with a `status` of `pending`, `running`, `waiting`, `idle`, `completed`, `failed`, or `killed`, where `idle` and `waiting` require Claude Code v2.1.289 or later.
@@ -324,7 +332,7 @@
`Svg`| An SVG document, up to 131,072 characters| | ✓| ✓
[`Client`](</docs/en/plugins/mods/interface#build-a-tree-from-elements>)| `module`, `key`| ✓| ✓|
[`Raster`](</docs/en/plugins/mods/interface#draw-a-grid-of-colored-cells>)| `key`, `columns` up to 512, `rows` up to 256, `cells`. See [Draw a grid of colored cells](</docs/en/plugins/mods/interface#draw-a-grid-of-colored-cells>).| ✓| |
-`Image`| PNG or RGBA bytes up to 2 MiB, or a file path, `columns` and `rows` up to 255, and `alt` text.| ✓| |
+`Image`| PNG or RGBA bytes up to 2 MiB, or a file path, `columns` and `rows` up to 255, and `alt` text. See [which terminals draw it](</docs/en/plugins/mods/gallery#image-and-client>).| ✓| |
More `Button` rules: `action` names one of Claude Code’s own [keybinding actions](</docs/en/keybindings>), and the user’s binding for it presses the button when that binding is a chord or a modified key. A digit `hotkey` on a button in the band also fires when the user types that digit alone into an empty prompt and pauses. When two buttons in one drawing name the same `hotkey`, the later one gets it. `autoFocus` accepts only `true` on any control, so omit the prop to leave it off. The VS Code extension ignores some element props and draws the element as if you had left them out:
--- a/reference.md
+++ b/reference.md
@@ -277,7 +277,7 @@
Render sites
-A render site is an extension point in Claude Code’s interface. Each row is a value of `e.component` in a `ui.render` hook, with the fields of `e.props` and the apps that render it. `e.surface` names the app that’s drawing, such as `terminal`, `desktop`, or `vscode`. [Change what Claude Code already draws](</docs/en/plugins/mods/interface#change-what-claude-code-already-draws>) shows what a hook can do at a site, with an example of each choice. Rendering in the VS Code extension requires extension version 2.1.299 or later and a session that [fetches feature flags](</docs/en/env-vars#features-that-need-feature-flag-fetching>). [Draw in the VS Code extension](</docs/en/plugins/mods/interface#draw-in-the-vs-code-extension>) lists what the extension draws differently.
+A render site is an extension point in Claude Code’s interface. Each row is a value of `e.component` in a `ui.render` hook, with the fields of `e.props` and the apps that render it. `e.surface` names the app that’s drawing, such as `terminal`, `desktop`, or `vscode`. [Change what Claude Code already draws](</docs/en/plugins/mods/interface#change-what-claude-code-already-draws>) shows what a hook can do at a site, with an example of each choice. Rendering in the VS Code extension requires extension version 2.1.299 or later. A session that [doesn’t fetch feature flags](</docs/en/env-vars#features-that-need-feature-flag-fetching>) needs 2.1.304 or later. [Draw in the VS Code extension](</docs/en/plugins/mods/interface#draw-in-the-vs-code-extension>) lists what the extension draws differently.
Site| `e.props`| `e.requestId`| Rendered on
---|---|---|---
@@ -445,7 +445,7 @@
---|---|---
`CLAUDE_CODE_PLUGIN_DIRS`| Environment, or `env` in `~/.claude/settings.json`| Plugin directories to load as `--plugin-dir` does, for apps you can’t pass a flag to. Absolute paths separated by `:`, or `;` on Windows.
`CLAUDE_CODE_PLUGIN_DIR_WATCH`| Environment| `1` makes a long-running non-interactive session reload `--plugin-dir` mods on save
-`prependPlugins`, `appendPlugins`| Managed settings. User settings only on a machine with no managed settings, for a user who isn’t signed in with a Team or Enterprise plan.| Lists of plugin ids, such as `acme-guard@acme-tools`. Mods in `prependPlugins` run before every mod a user installs, and mods in `appendPlugins` run after, in the listed order. See [The order mods run in](</docs/en/plugins/mods/events#the-order-mods-run-in>).
+`prependPlugins`, `appendPlugins`| Managed settings. User settings only on a machine with no managed settings, in a session whose credential isn’t a Team or Enterprise `/login`.| Lists of plugin ids, such as `acme-guard@acme-tools`. Mods in `prependPlugins` run before every mod a user installs, and mods in `appendPlugins` run after, in the listed order. See [The order mods run in](</docs/en/plugins/mods/events#the-order-mods-run-in>).
`allowManagedModsOnly`| Managed settings, as an [option on the built-in guard](</docs/en/plugins/mods/admin#set-options-on-the-built-in-guard>)| Only mods that [count as your organization’s](</docs/en/plugins/mods/admin#install-your-organizations-mods>), and mods built into Claude Code, run their hooks. Users’ settings hooks keep running.
`allowModsToOverrideDenyRules`| Managed settings, as an [option on the built-in guard](</docs/en/plugins/mods/admin#set-options-on-the-built-in-guard>)| Lets a mod a user installed approve a tool call that a `deny` rule refuses
`allowManagedHooksOnly`| Managed settings| Blocks hooks and installed mods that aren’t your organization’s. See [what keeps running](</docs/en/settings-reference#what-runs-under-allowmanagedhooksonly>).
@@ -453,7 +453,7 @@
`disableSideloadFlags`| Managed settings| Rejects `--plugin-dir` and `--plugin-url` at startup
`pluginConfigs`| User or managed settings| Holds `userConfig` values for a mod, keyed by the plugin’s id, such as `acme-guard@acme-tools`, or its name and `@inline`, such as `first-mod@inline`, for one loaded with `--plugin-dir`
-`sec-default@builtin` is a guard built into Claude Code, listed as `cc-plugin-sec-default` in `/plugin` and the debug log. It loads ahead of every mod a person installs on a machine with managed settings, or for a user signed in with a Team or Enterprise plan. If managed `prependPlugins` is set, the guard loads only when that list names it, at the position listed. Its source is in the [`mods/sec-default` directory of the Claude Code repository](<https://github.com/anthropics/claude-code/tree/main/mods/sec-default>).
+`sec-default@builtin` is a guard built into Claude Code, listed as `cc-plugin-sec-default` in `/plugin` and the debug log. It loads ahead of every mod a person installs on a machine with managed settings, or in a session whose credential is a Team or Enterprise [`/login`](</docs/en/authentication#authentication-precedence>). If managed `prependPlugins` is set, the guard loads only when that list names it, at the position listed. Its source is in the [`mods/sec-default` directory of the Claude Code repository](<https://github.com/anthropics/claude-code/tree/main/mods/sec-default>).
##
--- a/reference.md
+++ b/reference.md
@@ -314,7 +314,7 @@
Element| Main props| Terminal| Desktop| VS Code
---|---|---|---|---
[`Box`](</docs/en/plugins/mods/interface#build-a-tree-from-elements>)| `key`, flex layout, `gap`, `padding`, `margin`, `width`, `height`, `borderStyle`, `backgroundColor`, `position`, `hover`| ✓| ✓| ✓
-[`Text`](</docs/en/plugins/mods/interface#build-a-tree-from-elements>)| `color`, `backgroundColor`, `bold`, `italic`, `underline`, `dimColor`, `inverse`, `wrap`| ✓| ✓| ✓
+[`Text`](</docs/en/plugins/mods/interface#build-a-tree-from-elements>)| `color`, `backgroundColor`, `bold`, `italic`, `underline`, `dimColor`, `inverse`, `wrap`, `size`, `weight`, `mono`, `tabular`| ✓| ✓| ✓
[`Button`](</docs/en/plugins/mods/interface#respond-to-presses-and-typing>)| `key`, `label`, `onPress`, `hotkey`, `plain`, `dimColor`, `autoFocus`, `action`| ✓| ✓| ✓
[`Link`](</docs/en/plugins/mods/interface#link-in-the-desktop-app>)| `href`, `label`. See Limits.| ✓| ✓| ✓
[`Code`](</docs/en/plugins/mods/gallery#show-code-and-changes>)| `source`, `language`, `path`, `startLine`, `format`, `wrap`| ✓| ✓| ✓
@@ -329,6 +329,7 @@
More `Button` rules: `action` names one of Claude Code’s own [keybinding actions](</docs/en/keybindings>), and the user’s binding for it presses the button when that binding is a chord or a modified key. A digit `hotkey` on a button in the band also fires when the user types that digit alone into an empty prompt and pauses. When two buttons in one drawing name the same `hotkey`, the later one gets it. `autoFocus` accepts only `true` on any control, so omit the prop to leave it off. The VS Code extension ignores some element props and draws the element as if you had left them out:
* **`Box`** : `position` and `hover`
+ * **`Text`** : `size`, `mono`, and `tabular`
* **`Button`** : `hotkey`, `plain`, `autoFocus`, and `action`, so the user presses a button there with a click, or with Enter once it has focus
* **`Code`** : `language`, `path`, `startLine`, `format`, and `wrap`, so code draws without colors or line numbers, and a `format: 'diff'` block shows the diff’s raw text
* **`Input` and `Select`**: `autoFocus`
@@ -355,6 +356,49 @@
`'quote'`| A bar, `▎`, down the left side and blank cells on the other three sides| Blank
A `Box` whose `borderStyle` names anything else, such as `'rounded'`, draws with no border.
+
+###
+
+
+
+`Box` spacing steps
+
+The `Box` spacing props are `gap`, `columnGap`, `rowGap`, `padding`, `margin`, and the one-side and one-axis forms of `padding` and `margin`, such as `paddingX` and `marginTop`. Each takes a number of terminal cells such as `gap: 1`, or a step name such as `gap: 'md'`. In the terminal and the VS Code extension, each step is this many cells:
+
+Step| Cells across| Cells down
+---|---|---
+`'xs'`| 1| 0
+`'sm'`| 1| 0
+`'md'`| 2| 1
+`'lg'`| 3| 1
+`'xl'`| 4| 2
+
+If you set `gap`, `padding`, or `margin` to a step, the step applies across and down at once. For example, in the terminal and the VS Code extension, `padding: 'md'` is two cells at each side and one row above and below. Step names require Claude Code v2.1.299 or later. On an earlier release, Claude Code [draws its own version of the site](</docs/en/plugins/mods/interface#build-a-tree-from-elements>) in place of a tree that uses a step name.
+
+###
+
+
+
+`Text` typography props
+
+Set `size`, `weight`, `mono`, or `tabular` on a `Text` to ask the app drawing your tree for a text size, a weight, a monospaced typeface, or equal-width digits. Before you rely on a prop, check what the terminal and the VS Code extension do with it. If an app ignores a prop you set, your tree still draws there, with the text as if you’d left that prop out.
+
+Prop| Values| In the terminal| In the VS Code extension
+---|---|---|---
+`size`| `'caption'`, `'footnote'`, `'body'`, `'heading'`, or `'title'`| Ignored: the terminal has one text size| Ignored
+`weight`| `'regular'`, `'medium'`, `'semibold'`, or `'bold'`| `semibold` and `bold` draw as bold text| `semibold` and `bold` draw as bold text
+`mono`| `true` to ask for the app’s monospaced typeface| Ignored: the terminal is always monospaced| Ignored, so text keeps the extension’s own typeface
+`tabular`| `true` to ask for digits of equal width, so that a number that updates in place or a column of numbers stays aligned| Ignored: the terminal’s digits are already one cell wide| Ignored
+
+These four props require Claude Code v2.1.299 or later. On an earlier release, Claude Code [draws its own version of the site](</docs/en/plugins/mods/interface#build-a-tree-from-elements>) in place of a tree that sets `size`, `weight`, `mono`, or `tabular`.
+
+####
+
+
+
+Replace `bold` with `weight`
+
+`bold` on a `Text` is deprecated in favor of `weight` and still works. To replace it on a `Text` with no `weight`, change `bold: true` to `weight: 'semibold'` for the same result on Claude Code v2.1.299 or later. On a release earlier than v2.1.299, a tree that sets `weight` doesn’t draw, and Claude Code [draws its own version of the site](</docs/en/plugins/mods/interface#build-a-tree-from-elements>) instead. If you set both `bold` and `weight` on a `Text`, `bold` has no effect.
##
--- a/reference.md
+++ b/reference.md
@@ -1,4 +1,4 @@
-Look up any event a [mod](</docs/en/plugins/mods/overview>) can handle, mods API method it can call, or render site it can draw in, for the Claude Code CLI and the Desktop app as of v2.1.290. Each entry gives the name and a one-line description, and links to the guide section that explains it where there is one.
+Look up any event a [mod](</docs/en/plugins/mods/overview>) can handle, mods API method it can call, or render site it can draw in. Entries cover the Claude Code CLI and the Desktop app as of v2.1.290, and the VS Code extension as of v2.1.299. Each entry gives the name and a one-line description, and links to the guide section that explains it where there is one.
The complete reference is Claude Code’s [TypeScript declarations for mods](<https://github.com/anthropics/claude-code/blob/main/mods/types/claude-code.d.ts>), which describe every event, method, and element, with examples. The copy on GitHub can be older than the Claude Code version you have installed. When the two disagree, trust [the copy Claude Code writes for your version](</docs/en/plugins/mods/create#get-the-types-for-your-build>).
@@ -277,29 +277,29 @@
Render sites
-A render site is an extension point in Claude Code’s interface. Each row is a value of `e.component` in a `ui.render` hook, with the fields of `e.props` and the apps that render it. `e.surface` is `terminal` or `desktop`. [Change what Claude Code already draws](</docs/en/plugins/mods/interface#change-what-claude-code-already-draws>) shows what a hook can do at a site, with an example of each choice.
+A render site is an extension point in Claude Code’s interface. Each row is a value of `e.component` in a `ui.render` hook, with the fields of `e.props` and the apps that render it. `e.surface` names the app that’s drawing, such as `terminal`, `desktop`, or `vscode`. [Change what Claude Code already draws](</docs/en/plugins/mods/interface#change-what-claude-code-already-draws>) shows what a hook can do at a site, with an example of each choice. Rendering in the VS Code extension requires extension version 2.1.299 or later and a session that [fetches feature flags](</docs/en/env-vars#features-that-need-feature-flag-fetching>). [Draw in the VS Code extension](</docs/en/plugins/mods/interface#draw-in-the-vs-code-extension>) lists what the extension draws differently.
Site| `e.props`| `e.requestId`| Rendered on
---|---|---|---
-[`Pane`](</docs/en/plugins/mods/interface#pick-where-to-draw>)| `title`, `isFocused`, `bodyColumns`, `placement`, `scroll`, `view`| The pane’s `id`| Terminal, Desktop
+[`Pane`](</docs/en/plugins/mods/interface#pick-where-to-draw>)| `title`, `isFocused`, `bodyColumns`, `placement`, `scroll`, `view`| The pane’s `id`| Terminal, Desktop, VS Code
[`AbovePrompt`](</docs/en/plugins/mods/interface#pick-where-to-draw>)| `hasSurvey`, `isWorking`, `maxRows`, `bodyColumns`, `scroll`, `view`| One instance| Terminal, Desktop
-`UserMessage`| `text`, `origin`, `isExpanded`, and `task` or `from` by origin| The message id| Terminal, Desktop
-`AssistantMessage`| The reply’s text| The message id| Terminal, Desktop
-`ToolUse`, `ToolResult`, `ToolGroup`| The tool’s name, input, and result| The tool call id| Terminal, Desktop
+`UserMessage`| `text`, `origin`, `isExpanded`, and `task` or `from` by origin| The message id| Terminal, Desktop, VS Code
+`AssistantMessage`| The reply’s text| The message id| Terminal, Desktop, VS Code
+`ToolUse`, `ToolResult`, `ToolGroup`| The tool’s name, input, and result| The tool call id| Terminal, Desktop, VS Code
`CommandOutput`| `command`, `text`| The message id| Terminal, Desktop
-[`AskUserQuestion`](</docs/en/plugins/mods/interface#change-what-claude-code-already-draws>)| The question and options| The tool call id| Terminal, Desktop
+[`AskUserQuestion`](</docs/en/plugins/mods/interface#change-what-claude-code-already-draws>)| The question and options| The tool call id| Terminal, Desktop, VS Code
`ToolProgress`| `kind`| The tool call id| Terminal
-[`Spinner`](</docs/en/plugins/mods/interface#change-what-claude-code-already-draws>)| `word`, `message`, `suffix`, `mode`| The agent id| Terminal, Desktop
+[`Spinner`](</docs/en/plugins/mods/interface#change-what-claude-code-already-draws>)| `word`, `message`, `suffix`, `mode`| The agent id| Terminal, Desktop, VS Code
`TurnDuration`| `word`, `durationMs`| The message id| Terminal
`InfoNotice`| `text`, `command`| The message id| Terminal
`SessionMode`| `modes`| One instance| Terminal, Desktop
`PromptHint`| `isDraft`, `isWorking`, `hint`| One instance| Terminal, Desktop
-`e.viewport` holds `columns`, `rows`, and `isFullscreen`. It’s absent until the app has measured its window. Its `rows` is the height of the whole window, not of your pane. To fit a tree to its site, read these props in the hook:
+`e.viewport` holds `columns`, `rows`, and `isFullscreen`. In the terminal and the Desktop app, it’s absent until the app has measured its window. There, its `rows` is the height of the whole window, not of your pane. In the VS Code extension, it’s always present. To fit a tree to its site, read these props in the hook:
* **Width of a`Pane` or the band**: draw to `e.props.bodyColumns`
* **Height of a`Pane` beside the transcript**: where `e.props.placement` is `'dock'`, `e.props.scroll.bodyRows` is the number of rows the pane has for your tree
- * **Height of a`Pane` above the prompt**: where `e.props.placement` is `'inline'`, the pane grows with your tree up to a limit, and `bodyRows` is that limit. The [`rows` field of `$.ui.open`](</docs/en/plugins/mods/interface#open-a-pane-at-the-right-time>) asks for a different one.
+ * **Height of a`Pane` above the prompt**: where `e.props.placement` is `'inline'`, the pane grows with your tree up to a limit, and `bodyRows` is that limit. To ask for a different limit, see the [`rows` field of `$.ui.open`](</docs/en/plugins/mods/interface#open-a-pane-at-the-right-time>).
A tree taller than the pane scrolls as a whole.
@@ -311,22 +311,27 @@
Elements are the building blocks of a tree a `ui.render` hook returns, and you get them from `$.ui.resolve(e)`. [Build a tree from elements](</docs/en/plugins/mods/interface#build-a-tree-from-elements>) shows the common ones with how the terminal draws them, and the [interface gallery](</docs/en/plugins/mods/gallery>) has screenshots of most. A check mark means the app can draw the element.
-Element| Main props| Terminal| Desktop
----|---|---|---
-[`Box`](</docs/en/plugins/mods/interface#build-a-tree-from-elements>)| `key`, flex layout, `gap`, `padding`, `margin`, `width`, `height`, `borderStyle`, `backgroundColor`, `position`, `hover`| ✓| ✓
-[`Text`](</docs/en/plugins/mods/interface#build-a-tree-from-elements>)| `color`, `backgroundColor`, `bold`, `italic`, `underline`, `dimColor`, `inverse`, `wrap`| ✓| ✓
-[`Button`](</docs/en/plugins/mods/interface#respond-to-presses-and-typing>)| `key`, `label`, `onPress`, `hotkey`, `plain`, `dimColor`, `autoFocus`, `action`| ✓| ✓
-[`Link`](</docs/en/plugins/mods/interface#link-in-the-desktop-app>)| `href`, `label`. See Limits.| ✓| ✓
-[`Code`](</docs/en/plugins/mods/gallery#show-code-and-changes>)| `source`, `language`, `path`, `startLine`, `format`, `wrap`| ✓| ✓
-`Markdown`| `text`, `key`, `dimColor`, `onLinkPress`, `pressableLinks`| ✓| ✓
-[`Input`](</docs/en/plugins/mods/interface#take-typed-input-and-draw-a-row-for-each-item>)| `key`, `label`, `placeholder`, `value`, `submitLabel`, `onSubmit`, `onInput`, `autoFocus`| ✓| ✓
-`Select`| `key`, `label`, `options`, `value`, `onSelect`, `autoFocus`| ✓| ✓
-`Svg`| An SVG document, up to 131,072 characters| | ✓
-[`Client`](</docs/en/plugins/mods/interface#build-a-tree-from-elements>)| `module`, `key`| ✓| ✓
-[`Raster`](</docs/en/plugins/mods/interface#draw-a-grid-of-colored-cells>)| `key`, `columns` up to 512, `rows` up to 256, `cells`. See [Draw a grid of colored cells](</docs/en/plugins/mods/interface#draw-a-grid-of-colored-cells>).| ✓|
-`Image`| PNG or RGBA bytes up to 2 MiB, or a file path, `columns` and `rows` up to 255, and `alt` text.| ✓|
-
-More `Button` rules: `action` names one of Claude Code’s own [keybinding actions](</docs/en/keybindings>), and the user’s binding for it presses the button when that binding is a chord or a modified key. A digit `hotkey` on a button in the band also fires when the user types that digit alone into an empty prompt and pauses. When two buttons in one drawing name the same `hotkey`, the later one gets it. `autoFocus` accepts only `true` on any control, so omit the prop to leave it off.
+Element| Main props| Terminal| Desktop| VS Code
+---|---|---|---|---
+[`Box`](</docs/en/plugins/mods/interface#build-a-tree-from-elements>)| `key`, flex layout, `gap`, `padding`, `margin`, `width`, `height`, `borderStyle`, `backgroundColor`, `position`, `hover`| ✓| ✓| ✓
+[`Text`](</docs/en/plugins/mods/interface#build-a-tree-from-elements>)| `color`, `backgroundColor`, `bold`, `italic`, `underline`, `dimColor`, `inverse`, `wrap`| ✓| ✓| ✓
+[`Button`](</docs/en/plugins/mods/interface#respond-to-presses-and-typing>)| `key`, `label`, `onPress`, `hotkey`, `plain`, `dimColor`, `autoFocus`, `action`| ✓| ✓| ✓
+[`Link`](</docs/en/plugins/mods/interface#link-in-the-desktop-app>)| `href`, `label`. See Limits.| ✓| ✓| ✓
+[`Code`](</docs/en/plugins/mods/gallery#show-code-and-changes>)| `source`, `language`, `path`, `startLine`, `format`, `wrap`| ✓| ✓| ✓
+`Markdown`| `text`, `key`, `dimColor`, `onLinkPress`, `pressableLinks`| ✓| ✓| ✓
+[`Input`](</docs/en/plugins/mods/interface#take-typed-input-and-draw-a-row-for-each-item>)| `key`, `label`, `placeholder`, `value`, `submitLabel`, `onSubmit`, `onInput`, `autoFocus`| ✓| ✓| ✓
+`Select`| `key`, `label`, `options`, `value`, `onSelect`, `autoFocus`| ✓| ✓| ✓
+`Svg`| An SVG document, up to 131,072 characters| | ✓| ✓
+[`Client`](</docs/en/plugins/mods/interface#build-a-tree-from-elements>)| `module`, `key`| ✓| ✓|
+[`Raster`](</docs/en/plugins/mods/interface#draw-a-grid-of-colored-cells>)| `key`, `columns` up to 512, `rows` up to 256, `cells`. See [Draw a grid of colored cells](</docs/en/plugins/mods/interface#draw-a-grid-of-colored-cells>).| ✓| |
+`Image`| PNG or RGBA bytes up to 2 MiB, or a file path, `columns` and `rows` up to 255, and `alt` text.| ✓| |
+
+More `Button` rules: `action` names one of Claude Code’s own [keybinding actions](</docs/en/keybindings>), and the user’s binding for it presses the button when that binding is a chord or a modified key. A digit `hotkey` on a button in the band also fires when the user types that digit alone into an empty prompt and pauses. When two buttons in one drawing name the same `hotkey`, the later one gets it. `autoFocus` accepts only `true` on any control, so omit the prop to leave it off. The VS Code extension ignores some element props and draws the element as if you had left them out:
+
+ * **`Box`** : `position` and `hover`
+ * **`Button`** : `hotkey`, `plain`, `autoFocus`, and `action`, so the user presses a button there with a click, or with Enter once it has focus
+ * **`Code`** : `language`, `path`, `startLine`, `format`, and `wrap`, so code draws without colors or line numbers, and a `format: 'diff'` block shows the diff’s raw text
+ * **`Input` and `Select`**: `autoFocus`
###
--- a/reference.md
+++ b/reference.md
@@ -37,7 +37,8 @@
`next.origin`| `{ plugin, tier }` of whoever fired the event. Claude Code itself is `{ plugin: 'engine', tier: 'core' }`. A mod’s `tier` is its priority group in the [order mods run in](</docs/en/plugins/mods/events#the-order-mods-run-in>): `prepend`, `user`, `append`, or `builtin`.
`next.budget`| The hook’s time limit in milliseconds: `next.budget.ms` is the whole limit, and `next.budget.remainingMs` is what’s left now
`next.to(e, tier)`| Skips to a later tier, which is `append`, `builtin`, or `core`. `next.to(e, 'append')` skips the mods a user installed. Only a mod in `prependPlugins` or `appendPlugins` can call it.
-`next.error`| In a `.catch` handler only. `kind` is `throw` or `timeout` when the hook failed, and `message` is the error’s text. `kind` is `re-entry` when the hook was skipped because the event came from inside one of its own mods API calls, and `cause` is `lent` if a method another mod adds to the mods API fired that event. `re-entry` and `cause` require Claude Code v2.1.292 or later.
+`next.error`| In a `.catch` handler only. `kind` is `throw` or `timeout` when the hook failed, and `message` is the error’s text. `kind` is `re-entry` when the hook was skipped because the event came from inside a mods API call by that hook or by your mod’s code outside its hooks. `re-entry` requires Claude Code v2.1.292 or later.
+`next.error.cause`| Set only when `kind` is `re-entry`. `rewritten` if a `tool.call` or [`PreToolUse`](</docs/en/hooks#pretooluse>) hook changed the mods API call the event came from, or an `agent.spawn` hook changed an agent started by that call. `lent` when a method another mod adds to the mods API fired that event, unless `rewritten` also applies. `lent` requires Claude Code v2.1.292 or later and `rewritten` v2.1.300 or later.
`next.called`| In a `.catch` handler only. `true` when the hook had called `next`.
##
@@ -96,6 +97,24 @@
`prompt.mention`| Claude Code is about to read a file that a prompt @-mentions. Requires Claude Code v2.1.290 or later.| `next({ ...e, path })` to read a different file, or `{ deny: reason }`
[`skill.prompt`](</docs/en/plugins/mods/events#rewrite-or-add-to-a-prompt>)| A skill’s text is expanded for Claude| `{ text }`
`attribution.text`| Claude Code composes commit or pull request attribution text| `{ text }`
+
+####
+
+
+
+Source and frontmatter fields on `skill.prompt`
+
+In a `skill.prompt` hook, you can read these fields along with the skill’s name in `e.skill` and the text Claude reads in `e.text`:
+
+Field| Type| What it holds
+---|---|---
+`e.source`| string| Who provides the skill: `policySettings`, `userSettings`, or `projectSettings` for a skill in the enterprise, personal, or project [location](</docs/en/skills#where-skills-live>), respectively. Other sources give a word such as `plugin`, `mcp`, `syncedSkills`, or `built-in`.
+`e.pluginName`| string| The plugin’s name, for a skill whose `e.source` is `plugin`
+`e.path`| string| The absolute path of the skill’s `SKILL.md` file, or of its `.md` file for a skill written as a [command file](</docs/en/skills#where-skills-live>). Absent when the skill has no file on this machine, as with a built-in skill.
+`e.frontmatter`| object| The frontmatter of the skill’s file, as plain data
+`e.frontmatterProblem`| string| The reason `e.frontmatter` is missing the file’s frontmatter or one of its keys, as in `is a list or a single value, not a table`. Absent when `e.frontmatter` holds the whole frontmatter or the skill has none.
+
+A hook can pass a changed `text` or `frontmatter` to `next`: the hooks after it read both, and Claude reads the final `text`. A hook that changes any other field [fails](</docs/en/plugins/mods/events#handle-a-hook-that-fails>). On `skill.prompt`, `e.source`, `e.pluginName`, `e.path`, `e.frontmatter`, and `e.frontmatterProblem` require Claude Code v2.1.299 or later.
###
--- a/reference.md
+++ b/reference.md
@@ -88,6 +88,7 @@
[`prompt.submit`](</docs/en/plugins/mods/events#rewrite-or-add-to-a-prompt>)| A prompt is submitted| `next({ ...e, text })`, `next({ ...e, context })`, or `{ drop: reason }`
`prompt.fill`, `prompt.suggest`| Text is about to go into the prompt box as a draft, or as a dim suggestion| `next(e)` with changed text
`prompt.edit`| The user edits the prompt box| `next(e)`
+`prompt.autocomplete`| The user types in the prompt box and a word ends at the cursor. `e.token` is that word. Claude Code doesn’t wait for the hook: its own autocomplete rows show first.| `{ suggestions }`, a list of `{ text, label, description }` rows shown below Claude Code’s own. Choosing a row writes its `text` over the word.
`prompt.compose`| Claude Code renders a system prompt| `{ sections }`, a list of `{ id, text, scope }` in the order they’re sent
[`prompt.section`](</docs/en/plugins/mods/events#rewrite-or-add-to-a-prompt>)| Once for each named section of the system prompt. `e.name` is the section’s `id` in `prompt.compose`.| `{ text }`, or `{ text: null }` to omit the section
[`prompt.context`](</docs/en/plugins/mods/events#rewrite-or-add-to-a-prompt>)| Once for each conversation, for the context sent with the first message| `{ blocks }`
--- a/reference.md
+++ b/reference.md
@@ -156,6 +156,8 @@
`agent.offer`| A subagent type is offered to Claude| `{ isOffered: false }` to withhold it
`agent.spawn`| A subagent or an [agent team](</docs/en/agent-teams>) teammate is about to start. For a teammate, `e.isTeammate` is `true`.| `next({ ...e, model })` to choose its model, or `{ deny: reason }`
+When Claude resumes a subagent with the [`SendMessage`](</docs/en/sub-agents#resume-subagents>) tool, your `agent.spawn` hook doesn’t run again. To refuse the `SendMessage` calls that resume a subagent, match that tool in a [`tool.call`](</docs/en/plugins/mods/events#guard-or-change-a-tool-call>) hook.
+
###
@@ -186,6 +188,8 @@
---|---|---
[`plugin.register`](</docs/en/plugins/mods/admin#enforce-a-policy-with-a-mod-of-your-own>)| A hooks module is about to load. `e.uses` lists its events, mods API calls, environment variables, and state, as `claude plugin validate` prints them. Each call is written without the `$.` prefix, such as `fs.read`.| `{ refuse: reason }`
`engine.create`| The mods API is being built for this mod| A changed mods API, to add a namespace. A mod outside the `user` tier can also withhold one.
+
+When another mod’s hook calls a method on a namespace you added in `engine.create`, your method’s `$` calls run in that hook’s context until every hook on that event returns. For example, a relative path resolves against that hook’s working directory, and `$.prompt.submit` rejects while the turn is waiting on that hook. Calls your method makes after that run in your mod’s own context.
###
@@ -343,6 +347,10 @@
`$.process.run` timeout| 30 seconds by default, 10 minutes at most
`$.model.complete` `maxTokens`| 1024 by default, up to 64,000 or the model’s output limit
`$.fs.read` and `$.fs.write`| 4 MiB for one file
+A `$.http.fetch` request body| 4 MiB, counted in characters. A call with a larger body rejects.
+A `$.http.fetch` response body| 4 MiB. `text` holds the first 4 MiB and the rest isn’t read. When the `Content-Length` header declares more, the call rejects instead, with a reason that ends `is over the 4194304-byte limit`, except when the last request after any redirects uses the `HEAD` method. The `HEAD` exemption requires Claude Code v2.1.296 or later.
+One `$.http.fetch` call, redirects and body included| 30 seconds
+Redirects one `$.http.fetch` call follows| 5
A hook’s `drop` reason or `config.set` `deny` reason| 4,096 characters. The end of a longer reason is cut, and the drop or deny still applies. The cut requires Claude Code v2.1.292 or later, and on earlier versions the hook [fails](</docs/en/plugins/mods/events#handle-a-hook-that-fails>) instead.
Text in one tree| The first 100,000 characters are drawn
A `Code`’s `language` or `path`, a `Select` option’s `value`, or a `Client`’s `module`| 10,000 characters. If one is longer, Claude Code [draws its own version of the site](</docs/en/plugins/mods/interface#build-a-tree-from-elements>).
--- a/reference.md
+++ b/reference.md
@@ -60,7 +60,7 @@
---|---|---
[`tool.call`](</docs/en/plugins/mods/events#guard-or-change-a-tool-call>)| A tool is about to run| `next(e)`, `{ deny: reason }`, or `{ result }`
[`tool.check`](</docs/en/plugins/mods/events#where-settings-hooks-run-in-the-order>)| Claude Code decides whether a tool call may run, after the `tool.call` and `PreToolUse` hooks. `next(e)` resolves to the decision the rules, the permission mode, and those hooks reached.| `{ decision }`, which is `allow`, `ask`, or `deny`
-`tool.describe`| Once for each tool, when its description is first sent to Claude| `{ description }`, optionally with `isDeferred` set to `true` to put the tool behind [tool search](</docs/en/mcp#scale-with-mcp-tool-search>) or `false` to load it upfront
+`tool.describe`| Once for each tool, when its description is first sent to Claude. A second time for an MCP tool when Claude loads it through [tool search](</docs/en/mcp#scale-with-mcp-tool-search>), with `e.description` set to the text Claude reads for the loaded tool.| `{ description }`, optionally with `isDeferred` set to `true` to put the tool behind tool search or `false` to load it upfront
####
@@ -139,7 +139,7 @@
`session.end`| The session ends, or `/clear`, `/resume`, or `/branch` runs. `e.reason` is `clear`, `resume`, `logout`, `prompt_input_exit`, or `other`. `/branch` reports `resume`.| `next(e)`
`session.compact`| The conversation is about to be compacted| `{ skip: reason }`
[`session.receive`](</docs/en/plugins/mods/api#send-and-receive-messages-between-sessions>), [`session.send`](</docs/en/plugins/mods/api#send-and-receive-messages-between-sessions>)| A message arrives from, or is about to go to, another agent or session. See [Send and receive messages between sessions](</docs/en/plugins/mods/api#send-and-receive-messages-between-sessions>).| `{ consumed: reason }` for `receive`, `{ isDelivered: false, reason }` for `send`
-`session.append`| Once for each row the conversation keeps, such as a prompt, a response block, a tool result, or a notice, before it’s stored| `next({ ...e, message })` to rewrite the row’s `content`
+`session.append`| Once for each row the conversation keeps, such as a prompt, a response block, a tool result, or a notice, before it’s stored| `next({ ...e, message })` with a changed `message.content`, to rewrite the row’s text blocks or the `content` of a `tool_result` block in it
`session.attach`, `session.detach`| Another app connects to or disconnects from the session| `next(e)`
`session.measure`| After each turn, and when a plan limit’s percent used changes| `next(e)`
@@ -352,6 +352,7 @@
`$.ui.invalidate('ui.render')` redraws| Throttled to 10 a second, or 30 in the terminal for the visible pane, the expanded band, and the hint line under the prompt. Calls that come sooner are coalesced.
`$.ui.toast`| Shown for 4 seconds unless you pass `{ timeoutMs }`
A pane opened without the user asking| Placed from 144 terminal columns, 110 after they’ve opened it once
+Scopes, such as functions, blocks, and loops, nested inside one another in one file of a hooks module| 2,000
Command, tool, subagent type, and pane names| Letters, digits, `_`, and `-`, up to 64 characters
One `claude plugin test` test| 5 seconds unless the test sets `timeoutMs`
--- a/reference.md
+++ b/reference.md
@@ -37,7 +37,8 @@
`next.origin`| `{ plugin, tier }` of whoever fired the event. Claude Code itself is `{ plugin: 'engine', tier: 'core' }`. A mod’s `tier` is its priority group in the [order mods run in](</docs/en/plugins/mods/events#the-order-mods-run-in>): `prepend`, `user`, `append`, or `builtin`.
`next.budget`| The hook’s time limit in milliseconds: `next.budget.ms` is the whole limit, and `next.budget.remainingMs` is what’s left now
`next.to(e, tier)`| Skips to a later tier, which is `append`, `builtin`, or `core`. `next.to(e, 'append')` skips the mods a user installed. Only a mod in `prependPlugins` or `appendPlugins` can call it.
-`next.error`, `next.called`| In a `.catch` handler only. `next.error.kind` is `throw` or `timeout`, `next.error.message` is the error’s text, and `next.called` is `true` when the failed hook had called `next`.
+`next.error`| In a `.catch` handler only. `kind` is `throw` or `timeout` when the hook failed, and `message` is the error’s text. `kind` is `re-entry` when the hook was skipped because the event came from inside one of its own mods API calls, and `cause` is `lent` if a method another mod adds to the mods API fired that event. `re-entry` and `cause` require Claude Code v2.1.292 or later.
+`next.called`| In a `.catch` handler only. `true` when the hook had called `next`.
##
@@ -60,6 +61,19 @@
[`tool.call`](</docs/en/plugins/mods/events#guard-or-change-a-tool-call>)| A tool is about to run| `next(e)`, `{ deny: reason }`, or `{ result }`
[`tool.check`](</docs/en/plugins/mods/events#where-settings-hooks-run-in-the-order>)| Claude Code decides whether a tool call may run, after the `tool.call` and `PreToolUse` hooks. `next(e)` resolves to the decision the rules, the permission mode, and those hooks reached.| `{ decision }`, which is `allow`, `ask`, or `deny`
`tool.describe`| Once for each tool, when its description is first sent to Claude| `{ description }`, optionally with `isDeferred` set to `true` to put the tool behind [tool search](</docs/en/mcp#scale-with-mcp-tool-search>) or `false` to load it upfront
+
+####
+
+
+
+Agent and organization fields on `tool.check`
+
+In a `tool.check` hook, read these fields to tell a subagent’s call from the main conversation’s, and to see whether your organization requires approval for a connector tool:
+
+ * **`e.agentId`** : set when a [subagent](</docs/en/sub-agents>) or an [in-process teammate](</docs/en/agent-teams#choose-a-display-mode>) makes the call, and absent when the main conversation does
+ * **`e.ceiling`** : `ask` for a connector tool your organization set to `ask`, in [sessions where that setting reaches Claude Code](</docs/en/mcp#organization-controls-on-connector-tools>)
+
+On `tool.check`, `e.agentId` and `e.ceiling` require Claude Code v2.1.290 or later.
###
@@ -215,7 +229,7 @@
[`$.ui`](</docs/en/plugins/mods/interface#pick-where-to-draw>)| `resolve`, `invalidate`, `open`, `close`, `panes`, `focus`, `scroll`, `toast`, `status`, `log`, `notice`, `ask`, `copy`, `selection`, `blit`
[`$.command`](</docs/en/plugins/mods/api#add-a-command>)| `register`, `run`, `list`
[`$.tool`](</docs/en/plugins/mods/api#add-a-tool>)| `register`, `call`, `check`, `list`
-`$.agent`| `register`, `spawn`, `list`
+`$.agent`| `register`, `spawn`, `list`. `list()` returns this session’s subagents and teammates, each with a `status` of `pending`, `running`, `waiting`, `idle`, `completed`, `failed`, or `killed`, where `idle` and `waiting` require Claude Code v2.1.289 or later.
[`$.model`](</docs/en/plugins/mods/api#call-a-model>)| `complete`, `fork`, `classify`
[`$.prompt`](</docs/en/plugins/mods/api#start-a-turn-from-a-background-job>)| `submit`, `read`, `fill`, `suggest`, `compose`. Claude reads text from `submit({ text })` after a sentence that names your mod as the sender. `submit({ text, asUser: true })` sends the text as the user’s own words, without that sentence.
`$.turn`| `abort`
@@ -278,7 +292,7 @@
[`Box`](</docs/en/plugins/mods/interface#build-a-tree-from-elements>)| `key`, flex layout, `gap`, `padding`, `margin`, `width`, `height`, `borderStyle`, `backgroundColor`, `position`, `hover`| ✓| ✓
[`Text`](</docs/en/plugins/mods/interface#build-a-tree-from-elements>)| `color`, `backgroundColor`, `bold`, `italic`, `underline`, `dimColor`, `inverse`, `wrap`| ✓| ✓
[`Button`](</docs/en/plugins/mods/interface#respond-to-presses-and-typing>)| `key`, `label`, `onPress`, `hotkey`, `plain`, `dimColor`, `autoFocus`, `action`| ✓| ✓
-`Link`| `href`, `label`| ✓| ✓
+[`Link`](</docs/en/plugins/mods/interface#link-in-the-desktop-app>)| `href`, `label`. See Limits.| ✓| ✓
[`Code`](</docs/en/plugins/mods/gallery#show-code-and-changes>)| `source`, `language`, `path`, `startLine`, `format`, `wrap`| ✓| ✓
`Markdown`| `text`, `key`, `dimColor`, `onLinkPress`, `pressableLinks`| ✓| ✓
[`Input`](</docs/en/plugins/mods/interface#take-typed-input-and-draw-a-row-for-each-item>)| `key`, `label`, `placeholder`, `value`, `submitLabel`, `onSubmit`, `onInput`, `autoFocus`| ✓| ✓
@@ -319,7 +333,7 @@
Limits
-Hooks and mods API calls run under time and size limits. Claude Code skips a hook that exceeds a time limit and rejects a call that exceeds a size limit.
+Hooks and mods API calls run under time and size limits. Claude Code skips a hook that exceeds a time limit.
Limit| Value
---|---
@@ -329,7 +343,10 @@
`$.process.run` timeout| 30 seconds by default, 10 minutes at most
`$.model.complete` `maxTokens`| 1024 by default, up to 64,000 or the model’s output limit
`$.fs.read` and `$.fs.write`| 4 MiB for one file
+A hook’s `drop` reason or `config.set` `deny` reason| 4,096 characters. The end of a longer reason is cut, and the drop or deny still applies. The cut requires Claude Code v2.1.292 or later, and on earlier versions the hook [fails](</docs/en/plugins/mods/events#handle-a-hook-that-fails>) instead.
Text in one tree| The first 100,000 characters are drawn
+A `Code`’s `language` or `path`, a `Select` option’s `value`, or a `Client`’s `module`| 10,000 characters. If one is longer, Claude Code [draws its own version of the site](</docs/en/plugins/mods/interface#build-a-tree-from-elements>).
+A `Link`’s `href`| 2,048 characters. A longer `href` keeps the whole tree from drawing.
`$.store`| 4 MiB of JSON in total
`$.session.messages()`| The newest 4,096 entries
`$.ui.invalidate('ui.render')` redraws| Throttled to 10 a second, or 30 in the terminal for the visible pane, the expanded band, and the hint line under the prompt. Calls that come sooner are coalesced.
--- a/reference.md
+++ b/reference.md
@@ -279,14 +279,14 @@
[`Text`](</docs/en/plugins/mods/interface#build-a-tree-from-elements>)| `color`, `backgroundColor`, `bold`, `italic`, `underline`, `dimColor`, `inverse`, `wrap`| ✓| ✓
[`Button`](</docs/en/plugins/mods/interface#respond-to-presses-and-typing>)| `key`, `label`, `onPress`, `hotkey`, `plain`, `dimColor`, `autoFocus`, `action`| ✓| ✓
`Link`| `href`, `label`| ✓| ✓
-`Code`| The code| ✓| ✓
+[`Code`](</docs/en/plugins/mods/gallery#show-code-and-changes>)| `source`, `language`, `path`, `startLine`, `format`, `wrap`| ✓| ✓
`Markdown`| `text`, `key`, `dimColor`, `onLinkPress`, `pressableLinks`| ✓| ✓
[`Input`](</docs/en/plugins/mods/interface#take-typed-input-and-draw-a-row-for-each-item>)| `key`, `label`, `placeholder`, `value`, `submitLabel`, `onSubmit`, `onInput`, `autoFocus`| ✓| ✓
`Select`| `key`, `label`, `options`, `value`, `onSelect`, `autoFocus`| ✓| ✓
`Svg`| An SVG document, up to 131,072 characters| | ✓
[`Client`](</docs/en/plugins/mods/interface#build-a-tree-from-elements>)| `module`, `key`| ✓| ✓
[`Raster`](</docs/en/plugins/mods/interface#draw-a-grid-of-colored-cells>)| `key`, `columns` up to 512, `rows` up to 256, `cells`. See [Draw a grid of colored cells](</docs/en/plugins/mods/interface#draw-a-grid-of-colored-cells>).| ✓|
-`Image`| PNG or RGBA bytes up to 2 MiB, or a file path| ✓|
+`Image`| PNG or RGBA bytes up to 2 MiB, or a file path, `columns` and `rows` up to 255, and `alt` text.| ✓|
More `Button` rules: `action` names one of Claude Code’s own [keybinding actions](</docs/en/keybindings>), and the user’s binding for it presses the button when that binding is a chord or a modified key. A digit `hotkey` on a button in the band also fires when the user types that digit alone into an empty prompt and pauses. When two buttons in one drawing name the same `hotkey`, the later one gets it. `autoFocus` accepts only `true` on any control, so omit the prop to leave it off.
@@ -351,7 +351,7 @@
`CLAUDE_CODE_PLUGIN_DIRS`| Environment, or `env` in `~/.claude/settings.json`| Plugin directories to load as `--plugin-dir` does, for apps you can’t pass a flag to. Absolute paths separated by `:`, or `;` on Windows.
`CLAUDE_CODE_PLUGIN_DIR_WATCH`| Environment| `1` makes a long-running non-interactive session reload `--plugin-dir` mods on save
`prependPlugins`, `appendPlugins`| Managed settings. User settings only on a machine with no managed settings, for a user who isn’t signed in with a Team or Enterprise plan.| Lists of plugin ids, such as `acme-guard@acme-tools`. Mods in `prependPlugins` run before every mod a user installs, and mods in `appendPlugins` run after, in the listed order. See [The order mods run in](</docs/en/plugins/mods/events#the-order-mods-run-in>).
-`allowManagedModsOnly`| Managed settings, as an [option on the built-in guard](</docs/en/plugins/mods/admin#set-options-on-the-built-in-guard>)| Only mods that [count as your organization’s](</docs/en/plugins/mods/admin#install-your-organizations-mods>), and mods built into Claude Code, load. Users’ settings hooks keep running.
+`allowManagedModsOnly`| Managed settings, as an [option on the built-in guard](</docs/en/plugins/mods/admin#set-options-on-the-built-in-guard>)| Only mods that [count as your organization’s](</docs/en/plugins/mods/admin#install-your-organizations-mods>), and mods built into Claude Code, run their hooks. Users’ settings hooks keep running.
`allowModsToOverrideDenyRules`| Managed settings, as an [option on the built-in guard](</docs/en/plugins/mods/admin#set-options-on-the-built-in-guard>)| Lets a mod a user installed approve a tool call that a `deny` rule refuses
`allowManagedHooksOnly`| Managed settings| Blocks hooks and installed mods that aren’t your organization’s. See [what keeps running](</docs/en/settings-reference#what-runs-under-allowmanagedhooksonly>).
`disableAllHooks`| Any settings file| In managed settings, no mod or hook from an installed plugin runs. In your own settings, what your organization manages keeps running. See [`disableAllHooks`](</docs/en/settings-reference#disableallhooks>).
--- a/reference.md
+++ b/reference.md
@@ -1,4 +1,4 @@
-Look up any event a [mod](</docs/en/plugins/mods/overview>) can handle, mods API method it can call, or render site it can draw in, for the Claude Code CLI and the Desktop app as of v2.1.289. Each entry gives the name and a one-line description, and links to the guide section that explains it where there is one.
+Look up any event a [mod](</docs/en/plugins/mods/overview>) can handle, mods API method it can call, or render site it can draw in, for the Claude Code CLI and the Desktop app as of v2.1.290. Each entry gives the name and a one-line description, and links to the guide section that explains it where there is one.
The complete reference is Claude Code’s [TypeScript declarations for mods](<https://github.com/anthropics/claude-code/blob/main/mods/types/claude-code.d.ts>), which describe every event, method, and element, with examples. The copy on GitHub can be older than the Claude Code version you have installed. When the two disagree, trust [the copy Claude Code writes for your version](</docs/en/plugins/mods/create#get-the-types-for-your-build>).
@@ -78,6 +78,7 @@
[`prompt.section`](</docs/en/plugins/mods/events#rewrite-or-add-to-a-prompt>)| Once for each named section of the system prompt. `e.name` is the section’s `id` in `prompt.compose`.| `{ text }`, or `{ text: null }` to omit the section
[`prompt.context`](</docs/en/plugins/mods/events#rewrite-or-add-to-a-prompt>)| Once for each conversation, for the context sent with the first message| `{ blocks }`
`prompt.attachment`| Claude Code adds a message of its own for Claude, such as a reminder. `e.type` names the kind, and for the kinds the types declare, `e.detail` holds the facts the text was written from.| `{ text }`, or `{ text: null }` to omit it
+`prompt.mention`| Claude Code is about to read a file that a prompt @-mentions. Requires Claude Code v2.1.290 or later.| `next({ ...e, path })` to read a different file, or `{ deny: reason }`
[`skill.prompt`](</docs/en/plugins/mods/events#rewrite-or-add-to-a-prompt>)| A skill’s text is expanded for Claude| `{ text }`
`attribution.text`| Claude Code composes commit or pull request attribution text| `{ text }`
@@ -170,7 +171,7 @@
Event| Fires when| A hook can return
---|---|---
[`plugin.register`](</docs/en/plugins/mods/admin#enforce-a-policy-with-a-mod-of-your-own>)| A hooks module is about to load. `e.uses` lists its events, mods API calls, environment variables, and state, as `claude plugin validate` prints them. Each call is written without the `$.` prefix, such as `fs.read`.| `{ refuse: reason }`
-`engine.create`| The mods API is being built for this mod| A changed mods API, to add a namespace or withhold one
+`engine.create`| The mods API is being built for this mod| A changed mods API, to add a namespace. A mod outside the `user` tier can also withhold one.
###
@@ -259,8 +260,8 @@
`e.viewport` holds `columns`, `rows`, and `isFullscreen`. It’s absent until the app has measured its window. Its `rows` is the height of the whole window, not of your pane. To fit a tree to its site, read these props in the hook:
* **Width of a`Pane` or the band**: draw to `e.props.bodyColumns`
- * **Height of a`Pane` beside the transcript**: where `e.props.placement` is `'dock'`, `e.props.scroll.bodyRows` is the number of rows the pane has
- * **Height of a`Pane` above the prompt**: where `e.props.placement` is `'inline'`, the pane grows with your tree up to a limit, and `bodyRows` counts only the rows showing now. The [`rows` field of `$.ui.open`](</docs/en/plugins/mods/interface#open-a-pane-at-the-right-time>) asks for a different limit.
+ * **Height of a`Pane` beside the transcript**: where `e.props.placement` is `'dock'`, `e.props.scroll.bodyRows` is the number of rows the pane has for your tree
+ * **Height of a`Pane` above the prompt**: where `e.props.placement` is `'inline'`, the pane grows with your tree up to a limit, and `bodyRows` is that limit. The [`rows` field of `$.ui.open`](</docs/en/plugins/mods/interface#open-a-pane-at-the-right-time>) asks for a different one.
A tree taller than the pane scrolls as a whole.
@@ -278,8 +279,8 @@
[`Text`](</docs/en/plugins/mods/interface#build-a-tree-from-elements>)| `color`, `backgroundColor`, `bold`, `italic`, `underline`, `dimColor`, `inverse`, `wrap`| ✓| ✓
[`Button`](</docs/en/plugins/mods/interface#respond-to-presses-and-typing>)| `key`, `label`, `onPress`, `hotkey`, `plain`, `dimColor`, `autoFocus`, `action`| ✓| ✓
`Link`| `href`, `label`| ✓| ✓
-`Code`| The code, up to 10,000 characters| ✓| ✓
-`Markdown`| `text`, up to 10,000 characters, `key`, `dimColor`, `onLinkPress`, `pressableLinks`| ✓| ✓
+`Code`| The code| ✓| ✓
+`Markdown`| `text`, `key`, `dimColor`, `onLinkPress`, `pressableLinks`| ✓| ✓
[`Input`](</docs/en/plugins/mods/interface#take-typed-input-and-draw-a-row-for-each-item>)| `key`, `label`, `placeholder`, `value`, `submitLabel`, `onSubmit`, `onInput`, `autoFocus`| ✓| ✓
`Select`| `key`, `label`, `options`, `value`, `onSelect`, `autoFocus`| ✓| ✓
`Svg`| An SVG document, up to 131,072 characters| | ✓
@@ -289,6 +290,29 @@
More `Button` rules: `action` names one of Claude Code’s own [keybinding actions](</docs/en/keybindings>), and the user’s binding for it presses the button when that binding is a chord or a modified key. A digit `hotkey` on a button in the band also fires when the user types that digit alone into an empty prompt and pauses. When two buttons in one drawing name the same `hotkey`, the later one gets it. `autoFocus` accepts only `true` on any control, so omit the prop to leave it off.
+###
+
+
+
+`Box` border styles
+
+To draw a border around a `Box`, set its `borderStyle` to one of these names, as in `borderStyle: 'round'`. Each row says what the terminal draws for that name and shows the top edge of the border.
+
+`borderStyle`| What the terminal draws| Top edge
+---|---|---
+`'single'`| Thin lines with square corners| `┌──┐`
+`'double'`| Double lines| `╔══╗`
+`'round'`| Thin lines with rounded corners| `╭──╮`
+`'bold'`| Thick lines| `┏━━┓`
+`'singleDouble'`| Thin lines on the top and bottom, double lines on the sides| `╓──╖`
+`'doubleSingle'`| Double lines on the top and bottom, thin lines on the sides| `╒══╕`
+`'classic'`| The ASCII characters `+`, `-`, and `|`| `+--+`
+`'arrow'`| Arrows that point into the `Box`| `↘↓↓↙`
+`'dashed'`| Dashed lines with blank corners| `╌╌`
+`'quote'`| A bar, `▎`, down the left side and blank cells on the other three sides| Blank
+
+A `Box` whose `borderStyle` names anything else, such as `'rounded'`, draws with no border.
+
##
@@ -305,7 +329,7 @@
`$.process.run` timeout| 30 seconds by default, 10 minutes at most
`$.model.complete` `maxTokens`| 1024 by default, up to 64,000 or the model’s output limit
`$.fs.read` and `$.fs.write`| 4 MiB for one file
-One string child of a `Text`| 10,000 characters
+Text in one tree| The first 100,000 characters are drawn
`$.store`| 4 MiB of JSON in total
`$.session.messages()`| The newest 4,096 entries
`$.ui.invalidate('ui.render')` redraws| Throttled to 10 a second, or 30 in the terminal for the visible pane, the expanded band, and the hint line under the prompt. Calls that come sooner are coalesced.
--- a/reference.md
+++ b/reference.md
@@ -1,4 +1,4 @@
-Look up any event a [mod](</docs/en/plugins/mods/overview>) can handle, mods API method it can call, or render site it can draw in, for the Claude Code CLI and the Desktop app as of v2.1.287. Each entry gives the name and a one-line description, and links to the guide section that explains it where there is one.
+Look up any event a [mod](</docs/en/plugins/mods/overview>) can handle, mods API method it can call, or render site it can draw in, for the Claude Code CLI and the Desktop app as of v2.1.289. Each entry gives the name and a one-line description, and links to the guide section that explains it where there is one.
The complete reference is Claude Code’s [TypeScript declarations for mods](<https://github.com/anthropics/claude-code/blob/main/mods/types/claude-code.d.ts>), which describe every event, method, and element, with examples. The copy on GitHub can be older than the Claude Code version you have installed. When the two disagree, trust [the copy Claude Code writes for your version](</docs/en/plugins/mods/create#get-the-types-for-your-build>).
@@ -134,12 +134,12 @@
Subagents
-Subagent events fire when a subagent type is offered to Claude and when one is about to start:
+Subagent events fire when a subagent type is offered to Claude and when a subagent or an agent-team teammate is about to start:
Event| Fires when| A hook can return
---|---|---
`agent.offer`| A subagent type is offered to Claude| `{ isOffered: false }` to withhold it
-`agent.spawn`| A subagent is about to start| `{ model }` or `{ deny: reason }`
+`agent.spawn`| A subagent or an [agent team](</docs/en/agent-teams>) teammate is about to start. For a teammate, `e.isTeammate` is `true`.| `next({ ...e, model })` to choose its model, or `{ deny: reason }`
###
@@ -157,6 +157,7 @@
`ui.focus`, `ui.scroll`| The focused control or the scroll position of a pane or the band is about to change
`ui.close`| A pane is about to close. `e.id` is the pane and `e.origin.kind` is `plugin`, `person`, or `unload`.
[`ui.message`](</docs/en/plugins/mods/interface#build-a-tree-from-elements>)| A `Client` element posts data to its mod
+[`ui.fault`](</docs/en/plugins/mods/interface#redraw-when-something-changes>)| A `Client` element your mod drew failed to load, draw, or run. `e.phase` is `load`, `render`, or `run`, and `e.reason` is the error message. Requires Claude Code v2.1.289 or later.
###
@@ -210,7 +211,7 @@
Namespace| Methods
---|---
`$.plugin`| `name`, `root`: this plugin’s name and directory
-[`$.ui`](</docs/en/plugins/mods/interface#pick-where-to-draw>)| `resolve`, `invalidate`, `open`, `close`, `panes`, `focus`, `scroll`, `toast`, `status`, `log`, `notice`, `ask`, `copy`, `blit`
+[`$.ui`](</docs/en/plugins/mods/interface#pick-where-to-draw>)| `resolve`, `invalidate`, `open`, `close`, `panes`, `focus`, `scroll`, `toast`, `status`, `log`, `notice`, `ask`, `copy`, `selection`, `blit`
[`$.command`](</docs/en/plugins/mods/api#add-a-command>)| `register`, `run`, `list`
[`$.tool`](</docs/en/plugins/mods/api#add-a-tool>)| `register`, `call`, `check`, `list`
`$.agent`| `register`, `spawn`, `list`
@@ -298,9 +299,9 @@
Limit| Value
---|---
-A hook’s own execution time for one event, not counting time inside `next` or a mods API call other than `$.clock.sleep`| 10 seconds
+A hook’s own execution time for one event, not counting time inside `next` or a mods API call other than `$.clock.sleep`| 10 seconds, or 50 milliseconds for a `prompt.edit` hook
A `.catch` handler’s execution time| 1 second
-All `session.end` hooks together| 1.5 seconds
+All `session.end` hooks together| As long as the [SessionEnd hook budget](</docs/en/hooks#sessionend-input>), 1.5 seconds unless you change it, counted from when your settings `SessionEnd` hooks finish
`$.process.run` timeout| 30 seconds by default, 10 minutes at most
`$.model.complete` `maxTokens`| 1024 by default, up to 64,000 or the model’s output limit
`$.fs.read` and `$.fs.write`| 4 MiB for one file
--- a/reference.md
+++ b/reference.md
@@ -59,7 +59,7 @@
---|---|---
[`tool.call`](</docs/en/plugins/mods/events#guard-or-change-a-tool-call>)| A tool is about to run| `next(e)`, `{ deny: reason }`, or `{ result }`
[`tool.check`](</docs/en/plugins/mods/events#where-settings-hooks-run-in-the-order>)| Claude Code decides whether a tool call may run, after the `tool.call` and `PreToolUse` hooks. `next(e)` resolves to the decision the rules, the permission mode, and those hooks reached.| `{ decision }`, which is `allow`, `ask`, or `deny`
-`tool.describe`| Once for each tool, when its description is first sent to Claude| `{ description }`
+`tool.describe`| Once for each tool, when its description is first sent to Claude| `{ description }`, optionally with `isDeferred` set to `true` to put the tool behind [tool search](</docs/en/mcp#scale-with-mcp-tool-search>) or `false` to load it upfront
###
Show diff (355 lines)
--- a/reference.md
+++ b/reference.md
@@ -0,0 +1,352 @@
+Look up any event a [mod](</docs/en/plugins/mods/overview>) can handle, mods API method it can call, or render site it can draw in, for the Claude Code CLI and the Desktop app as of v2.1.287. Each entry gives the name and a one-line description, and links to the guide section that explains it where there is one.
+
+The complete reference is Claude Code’s [TypeScript declarations for mods](<https://github.com/anthropics/claude-code/blob/main/mods/types/claude-code.d.ts>), which describe every event, method, and element, with examples. The copy on GitHub can be older than the Claude Code version you have installed. When the two disagree, trust [the copy Claude Code writes for your version](</docs/en/plugins/mods/create#get-the-types-for-your-build>).
+
+##
+
+
+
+Files
+
+A mod is a plugin directory with these files:
+
+File| Required| Contents
+---|---|---
+`.claude-plugin/plugin.json`| Yes| The plugin [manifest](</docs/en/plugins/manifest-reference>). Mods add no required fields.
+`hooks/hooks.json`| Yes| `modules`: an array with one path, relative to this file, to the hooks module, as in `"modules": ["./register.js"]`. Can also hold [settings hooks](</docs/en/hooks>) under `hooks`.
+The hooks module, such as [`hooks/register.js`](</docs/en/plugins/mods/create#write-a-mod-yourself>)| Yes| The mod’s entry point. Exports `register(on, options)`. Named `.js`, `.mjs`, `.cjs`, `.jsx`, `.ts`, `.mts`, `.cts`, or `.tsx`. An ES module.
+[`types/index.d.ts`](</docs/en/plugins/mods/interface#declare-the-values>), named by `types` in the manifest| When the mod uses `$.state` or adds a namespace to the mods API| Declares `PluginState` values and any namespace the mod adds
+Files whose names end in `.test.ts` or `.test.tsx`| No| Tests that [`claude plugin test`](</docs/en/plugins/mods/test#write-a-test>) runs
+
+`register` receives `on` and `options`. `options` holds the values of the [`userConfig`](</docs/en/plugins/components#user-configuration>) fields the manifest declares, with defaults filled in.
+
+##
+
+
+
+The hook function
+
+A mod registers each of its hooks, which are event handlers, by calling `on` inside `register`. `on` takes the event’s name, an optional [matcher](</docs/en/plugins/mods/events#filter-which-events-a-hook-handles>), which is a filter on the event’s fields, and the hook, as in `on('tool.call', { tool: 'Bash' }, async ($, e, next) => next(e))`. `on` returns a registration with one method, `.catch(handler)`, which sets the hook’s [error handler](</docs/en/plugins/mods/events#handle-a-hook-that-fails>).
+
+Argument| What it is
+---|---
+[`$`](</docs/en/plugins/mods/events#how-a-hook-handles-an-event>)| The mods API: every method in mods API methods. Write each call in full, namespace then method, as in `$.fs.read('notes.md')`.
+[`e`](</docs/en/plugins/mods/events#how-a-hook-handles-an-event>)| The event’s input, as deeply frozen plain data. To change it, pass a copy to `next`.
+[`next(e)`](</docs/en/plugins/mods/events#how-a-hook-handles-an-event>)| The next handler, as in middleware. Runs the hooks after this one, then Claude Code’s behavior. Resolves to the event’s result.
+[`next.signal`](</docs/en/plugins/mods/api#stop-background-work>)| An `AbortSignal` that aborts when the event is abandoned
+`next.origin`| `{ plugin, tier }` of whoever fired the event. Claude Code itself is `{ plugin: 'engine', tier: 'core' }`. A mod’s `tier` is its priority group in the [order mods run in](</docs/en/plugins/mods/events#the-order-mods-run-in>): `prepend`, `user`, `append`, or `builtin`.
+`next.budget`| The hook’s time limit in milliseconds: `next.budget.ms` is the whole limit, and `next.budget.remainingMs` is what’s left now
+`next.to(e, tier)`| Skips to a later tier, which is `append`, `builtin`, or `core`. `next.to(e, 'append')` skips the mods a user installed. Only a mod in `prependPlugins` or `appendPlugins` can call it.
+`next.error`, `next.called`| In a `.catch` handler only. `next.error.kind` is `throw` or `timeout`, `next.error.message` is the error’s text, and `next.called` is `true` when the failed hook had called `next`.
+
+##
+
+
+
+Events
+
+Events are grouped by what they concern, each with when it fires and what a hook on it can return. Hooks on `turn.step` and `process.spawn` are async generators, and other hooks are async functions. The last column of each table uses shorthand. `next(e)` passes the event on unchanged. `next({ ...e, text })` passes on a copy with the named field changed, as in `next({ ...e, text: e.text.trim() })`. An object answers the event without calling `next`, and a word such as `reason` stands for a string you write, as in `{ deny: 'Use the file tools.' }`.
+
+###
+
+
+
+Tools
+
+Tool events fire around each tool call Claude makes, from the description Claude reads to the decision on whether the call runs:
+
+Event| Fires when| A hook can return
+---|---|---
+[`tool.call`](</docs/en/plugins/mods/events#guard-or-change-a-tool-call>)| A tool is about to run| `next(e)`, `{ deny: reason }`, or `{ result }`
+[`tool.check`](</docs/en/plugins/mods/events#where-settings-hooks-run-in-the-order>)| Claude Code decides whether a tool call may run, after the `tool.call` and `PreToolUse` hooks. `next(e)` resolves to the decision the rules, the permission mode, and those hooks reached.| `{ decision }`, which is `allow`, `ask`, or `deny`
+`tool.describe`| Once for each tool, when its description is first sent to Claude| `{ description }`
+
+###
+
+
+
+Prompts and what Claude reads
+
+Prompt events cover the text the user types and the text Claude Code sends to Claude on its own, such as the system prompt and reminders:
+
+Event| Fires when| A hook can return
+---|---|---
+[`prompt.submit`](</docs/en/plugins/mods/events#rewrite-or-add-to-a-prompt>)| A prompt is submitted| `next({ ...e, text })`, `next({ ...e, context })`, or `{ drop: reason }`
+`prompt.fill`, `prompt.suggest`| Text is about to go into the prompt box as a draft, or as a dim suggestion| `next(e)` with changed text
+`prompt.edit`| The user edits the prompt box| `next(e)`
+`prompt.compose`| Claude Code renders a system prompt| `{ sections }`, a list of `{ id, text, scope }` in the order they’re sent
+[`prompt.section`](</docs/en/plugins/mods/events#rewrite-or-add-to-a-prompt>)| Once for each named section of the system prompt. `e.name` is the section’s `id` in `prompt.compose`.| `{ text }`, or `{ text: null }` to omit the section
+[`prompt.context`](</docs/en/plugins/mods/events#rewrite-or-add-to-a-prompt>)| Once for each conversation, for the context sent with the first message| `{ blocks }`
+`prompt.attachment`| Claude Code adds a message of its own for Claude, such as a reminder. `e.type` names the kind, and for the kinds the types declare, `e.detail` holds the facts the text was written from.| `{ text }`, or `{ text: null }` to omit it
+[`skill.prompt`](</docs/en/plugins/mods/events#rewrite-or-add-to-a-prompt>)| A skill’s text is expanded for Claude| `{ text }`
+`attribution.text`| Claude Code composes commit or pull request attribution text| `{ text }`
+
+###
+
+
+
+Commands and configuration
+
+Command and configuration events fire when a command runs or is listed, and when a `/config` row is shown or changed:
+
+Event| Fires when| A hook can return
+---|---|---
+[`command.run`](</docs/en/plugins/mods/api#add-a-command>)| A command is about to run| `{ text }`, `{}`, or `next(e)`
+`command.describe`| Once for each command, for the command list| `{ description, argumentHint, isHidden }`
+`config.set`| A `/config` row is about to change| `next({ ...e, value })` or `{ deny: reason }`
+`config.describe`| Once for each `/config` row| `{ label, description, isHidden }`
+
+###
+
+
+
+Turns
+
+Turn events follow one answer from start to finish, including each request to the model within it:
+
+Event| Fires when| A hook can return
+---|---|---
+[`turn.start`](</docs/en/plugins/mods/events#follow-a-turn>)| A turn begins| `next(e)`
+[`turn.step`](</docs/en/plugins/mods/events#follow-a-turn>)| One request is about to go to the model| `yield* next(e)`, or `next({ ...e, model })`, `next({ ...e, effort })`
+[`turn.complete`](</docs/en/plugins/mods/events#follow-a-turn>)| A turn ended| `next(e)`, or `{ text }` to show a line under the answer
+
+###
+
+
+
+Session
+
+Session events mark the session starting, ending, compacting, and exchanging messages with other sessions:
+
+Event| Fires when| A hook can return
+---|---|---
+[`session.start`](</docs/en/plugins/mods/api#add-a-command-or-a-tool>)| Once for each loaded mod, before the first prompt, and again after a reload of that mod. Not after `/clear`, `/resume`, or `/branch`.| `next(e)`
+`session.end`| The session ends, or `/clear`, `/resume`, or `/branch` runs. `e.reason` is `clear`, `resume`, `logout`, `prompt_input_exit`, or `other`. `/branch` reports `resume`.| `next(e)`
+`session.compact`| The conversation is about to be compacted| `{ skip: reason }`
+[`session.receive`](</docs/en/plugins/mods/api#send-and-receive-messages-between-sessions>), [`session.send`](</docs/en/plugins/mods/api#send-and-receive-messages-between-sessions>)| A message arrives from, or is about to go to, another agent or session. See [Send and receive messages between sessions](</docs/en/plugins/mods/api#send-and-receive-messages-between-sessions>).| `{ consumed: reason }` for `receive`, `{ isDelivered: false, reason }` for `send`
+`session.append`| Once for each row the conversation keeps, such as a prompt, a response block, a tool result, or a notice, before it’s stored| `next({ ...e, message })` to rewrite the row’s `content`
+`session.attach`, `session.detach`| Another app connects to or disconnects from the session| `next(e)`
+`session.measure`| After each turn, and when a plan limit’s percent used changes| `next(e)`
+
+###
+
+
+
+Subagents
+
+Subagent events fire when a subagent type is offered to Claude and when one is about to start:
+
+Event| Fires when| A hook can return
+---|---|---
+`agent.offer`| A subagent type is offered to Claude| `{ isOffered: false }` to withhold it
+`agent.spawn`| A subagent is about to start| `{ model }` or `{ deny: reason }`
+
+###
+
+
+
+Interface
+
+Interface events fire when Claude Code draws a render site and when the user uses a control a mod drew. [Draw in the interface](</docs/en/plugins/mods/interface>) shows what a `ui.render` hook returns:
+
+Event| Fires when
+---|---
+[`ui.render`](</docs/en/plugins/mods/interface#pick-where-to-draw>)| A render site is about to be drawn
+`ui.resolve`| Mods load, once for each app, render site, and mod. The result is the element table that `$.ui.resolve(e)` reads.
+[`ui.press`](</docs/en/plugins/mods/interface#respond-to-presses-and-typing>), [`ui.input`](</docs/en/plugins/mods/interface#respond-to-presses-and-typing>), [`ui.select`](</docs/en/plugins/mods/interface#respond-to-presses-and-typing>)| A `Button`, `Input`, or `Select` a mod drew is used
+`ui.focus`, `ui.scroll`| The focused control or the scroll position of a pane or the band is about to change
+`ui.close`| A pane is about to close. `e.id` is the pane and `e.origin.kind` is `plugin`, `person`, or `unload`.
+[`ui.message`](</docs/en/plugins/mods/interface#build-a-tree-from-elements>)| A `Client` element posts data to its mod
+
+###
+
+
+
+Other mods
+
+These events let a mod act on other mods as they load, to refuse one or change the mods API it receives:
+
+Event| Fires when| A hook can return
+---|---|---
+[`plugin.register`](</docs/en/plugins/mods/admin#enforce-a-policy-with-a-mod-of-your-own>)| A hooks module is about to load. `e.uses` lists its events, mods API calls, environment variables, and state, as `claude plugin validate` prints them. Each call is written without the `$.` prefix, such as `fs.read`.| `{ refuse: reason }`
+`engine.create`| The mods API is being built for this mod| A changed mods API, to add a namespace or withhold one
+
+###
+
+
+
+Telemetry
+
+Telemetry events fire for the usage records Claude Code logs:
+
+Event| Fires when| A hook can return
+---|---|---
+`telemetry.log`, `telemetry.mark`| A telemetry record is about to be logged, or one use of a feature is marked. In a mod you install, give a telemetry hook the filter `{ to: 'collector' }`, as in `on('telemetry.log', { to: 'collector' }, hook)`. Without the filter, the mod fails `claude plugin validate`. `*` doesn’t match these events.| `next(e)`, or `{ deny: reason }`
+
+###
+
+
+
+Settings hook events
+
+Each [settings hook event](</docs/en/hooks#hook-events>) is an event named `classic.<Event>`, such as `classic.Stop` or `classic.PostToolUse`. `e` is the hook’s stdin JSON.
+
+###
+
+
+
+Mods API calls
+
+Every mods API method is also an event, named for its namespace and method, such as `fs.read`, `model.complete`, or `ui.open`. A hook on one intercepts calls from the mods that run after it, and can return `next(e)`, `{ deny: reason }`, or `{ value }`.
+
+##
+
+
+
+Mods API methods
+
+The mods API is the `$` argument every hook receives. Its methods are grouped in namespaces, such as `$.ui`. This table lists each namespace’s methods by name, so `open` in the `$.ui` row is the call `$.ui.open(...)`. The guides show the common ones in use, and [the types for your build](</docs/en/plugins/mods/create#get-the-types-for-your-build>) document every method with an example.
+
+Namespace| Methods
+---|---
+`$.plugin`| `name`, `root`: this plugin’s name and directory
+[`$.ui`](</docs/en/plugins/mods/interface#pick-where-to-draw>)| `resolve`, `invalidate`, `open`, `close`, `panes`, `focus`, `scroll`, `toast`, `status`, `log`, `notice`, `ask`, `copy`, `blit`
+[`$.command`](</docs/en/plugins/mods/api#add-a-command>)| `register`, `run`, `list`
+[`$.tool`](</docs/en/plugins/mods/api#add-a-tool>)| `register`, `call`, `check`, `list`
+`$.agent`| `register`, `spawn`, `list`
+[`$.model`](</docs/en/plugins/mods/api#call-a-model>)| `complete`, `fork`, `classify`
+[`$.prompt`](</docs/en/plugins/mods/api#start-a-turn-from-a-background-job>)| `submit`, `read`, `fill`, `suggest`, `compose`. Claude reads text from `submit({ text })` after a sentence that names your mod as the sender. `submit({ text, asUser: true })` sends the text as the user’s own words, without that sentence.
+`$.turn`| `abort`
+[`$.session`](</docs/en/plugins/mods/api#send-and-receive-messages-between-sessions>)| `messages`, `cwd`, `root`, `model`, `turns`, `id`, `repo`, `surfaces`, `usage`, `version`, `compact`, `send`, `append`, `authorize`. `usage()` returns `{ startedAt, context, rateLimits, cost }`: `context` has `tokens`, `window`, and `percent`, and `rateLimits` is a list of `{ kind, percentUsed, resetsAt }`.
+`$.config`| `list`, `set`
+[`$.settings`](</docs/en/plugins/mods/api#reach-files-processes-and-the-network>)| `read`
+[`$.env`](</docs/en/plugins/mods/api#reach-files-processes-and-the-network>)| `get`, `set`
+[`$.fs`](</docs/en/plugins/mods/api#reach-files-processes-and-the-network>)| `read`, `write`, `list`, `exists`, `stat`, `ancestors`. `write` isn’t atomic: it replaces the file’s content in place, so another process can read a partly written file. Keep data that several sessions change in `$.store`.
+[`$.store`](</docs/en/plugins/mods/interface#keep-state>)| `get`, `set`, `delete`, `keys`. A key-value store that every session on the machine shares. See [Save from more than one session](</docs/en/plugins/mods/interface#save-from-more-than-one-session>).
+[`$.state`](</docs/en/plugins/mods/interface#keep-a-value-in-$-state>)| Reactive state: `get`, `set`, with the helpers `atom`, `read`, `update`, `derive`, and `memberOf` imported from `claude-code`
+[`$.clock`](</docs/en/plugins/mods/api#run-work-in-the-background>)| `now`, `sleep`, `after`, `every`
+[`$.http`](</docs/en/plugins/mods/api#reach-files-processes-and-the-network>)| `fetch`
+[`$.process`](</docs/en/plugins/mods/api#reach-files-processes-and-the-network>)| `run`, `spawn`
+[`$.mcp`](</docs/en/plugins/mods/api#reach-files-processes-and-the-network>)| `call`, `connect`. `connect(server)` connects an MCP server that your own plugin’s manifest lists.
+`$.audio`| `play`, `speak`
+`$.telemetry`| `log`, `mark`. A record is sent only when Claude Code or a built-in mod makes the call.
+
+##
+
+
+
+Render sites
+
+A render site is an extension point in Claude Code’s interface. Each row is a value of `e.component` in a `ui.render` hook, with the fields of `e.props` and the apps that render it. `e.surface` is `terminal` or `desktop`. [Change what Claude Code already draws](</docs/en/plugins/mods/interface#change-what-claude-code-already-draws>) shows what a hook can do at a site, with an example of each choice.
+
+Site| `e.props`| `e.requestId`| Rendered on
+---|---|---|---
+[`Pane`](</docs/en/plugins/mods/interface#pick-where-to-draw>)| `title`, `isFocused`, `bodyColumns`, `placement`, `scroll`, `view`| The pane’s `id`| Terminal, Desktop
+[`AbovePrompt`](</docs/en/plugins/mods/interface#pick-where-to-draw>)| `hasSurvey`, `isWorking`, `maxRows`, `bodyColumns`, `scroll`, `view`| One instance| Terminal, Desktop
+`UserMessage`| `text`, `origin`, `isExpanded`, and `task` or `from` by origin| The message id| Terminal, Desktop
+`AssistantMessage`| The reply’s text| The message id| Terminal, Desktop
+`ToolUse`, `ToolResult`, `ToolGroup`| The tool’s name, input, and result| The tool call id| Terminal, Desktop
+`CommandOutput`| `command`, `text`| The message id| Terminal, Desktop
+[`AskUserQuestion`](</docs/en/plugins/mods/interface#change-what-claude-code-already-draws>)| The question and options| The tool call id| Terminal, Desktop
+`ToolProgress`| `kind`| The tool call id| Terminal
+[`Spinner`](</docs/en/plugins/mods/interface#change-what-claude-code-already-draws>)| `word`, `message`, `suffix`, `mode`| The agent id| Terminal, Desktop
+`TurnDuration`| `word`, `durationMs`| The message id| Terminal
+`InfoNotice`| `text`, `command`| The message id| Terminal
+`SessionMode`| `modes`| One instance| Terminal, Desktop
+`PromptHint`| `isDraft`, `isWorking`, `hint`| One instance| Terminal, Desktop
+
+`e.viewport` holds `columns`, `rows`, and `isFullscreen`. It’s absent until the app has measured its window. Its `rows` is the height of the whole window, not of your pane. To fit a tree to its site, read these props in the hook:
+
+ * **Width of a`Pane` or the band**: draw to `e.props.bodyColumns`
+ * **Height of a`Pane` beside the transcript**: where `e.props.placement` is `'dock'`, `e.props.scroll.bodyRows` is the number of rows the pane has
+ * **Height of a`Pane` above the prompt**: where `e.props.placement` is `'inline'`, the pane grows with your tree up to a limit, and `bodyRows` counts only the rows showing now. The [`rows` field of `$.ui.open`](</docs/en/plugins/mods/interface#open-a-pane-at-the-right-time>) asks for a different limit.
+
+A tree taller than the pane scrolls as a whole.
+
+##
+
+
+
+Elements
+
+Elements are the building blocks of a tree a `ui.render` hook returns, and you get them from `$.ui.resolve(e)`. [Build a tree from elements](</docs/en/plugins/mods/interface#build-a-tree-from-elements>) shows the common ones with how the terminal draws them, and the [interface gallery](</docs/en/plugins/mods/gallery>) has screenshots of most. A check mark means the app can draw the element.
+
+Element| Main props| Terminal| Desktop
+---|---|---|---
+[`Box`](</docs/en/plugins/mods/interface#build-a-tree-from-elements>)| `key`, flex layout, `gap`, `padding`, `margin`, `width`, `height`, `borderStyle`, `backgroundColor`, `position`, `hover`| ✓| ✓
+[`Text`](</docs/en/plugins/mods/interface#build-a-tree-from-elements>)| `color`, `backgroundColor`, `bold`, `italic`, `underline`, `dimColor`, `inverse`, `wrap`| ✓| ✓
+[`Button`](</docs/en/plugins/mods/interface#respond-to-presses-and-typing>)| `key`, `label`, `onPress`, `hotkey`, `plain`, `dimColor`, `autoFocus`, `action`| ✓| ✓
+`Link`| `href`, `label`| ✓| ✓
+`Code`| The code, up to 10,000 characters| ✓| ✓
+`Markdown`| `text`, up to 10,000 characters, `key`, `dimColor`, `onLinkPress`, `pressableLinks`| ✓| ✓
+[`Input`](</docs/en/plugins/mods/interface#take-typed-input-and-draw-a-row-for-each-item>)| `key`, `label`, `placeholder`, `value`, `submitLabel`, `onSubmit`, `onInput`, `autoFocus`| ✓| ✓
+`Select`| `key`, `label`, `options`, `value`, `onSelect`, `autoFocus`| ✓| ✓
+`Svg`| An SVG document, up to 131,072 characters| | ✓
+[`Client`](</docs/en/plugins/mods/interface#build-a-tree-from-elements>)| `module`, `key`| ✓| ✓
+[`Raster`](</docs/en/plugins/mods/interface#draw-a-grid-of-colored-cells>)| `key`, `columns` up to 512, `rows` up to 256, `cells`. See [Draw a grid of colored cells](</docs/en/plugins/mods/interface#draw-a-grid-of-colored-cells>).| ✓|
+`Image`| PNG or RGBA bytes up to 2 MiB, or a file path| ✓|
+
+More `Button` rules: `action` names one of Claude Code’s own [keybinding actions](</docs/en/keybindings>), and the user’s binding for it presses the button when that binding is a chord or a modified key. A digit `hotkey` on a button in the band also fires when the user types that digit alone into an empty prompt and pauses. When two buttons in one drawing name the same `hotkey`, the later one gets it. `autoFocus` accepts only `true` on any control, so omit the prop to leave it off.
+
+##
+
+
+
+Limits
+
+Hooks and mods API calls run under time and size limits. Claude Code skips a hook that exceeds a time limit and rejects a call that exceeds a size limit.
+
+Limit| Value
+---|---
+A hook’s own execution time for one event, not counting time inside `next` or a mods API call other than `$.clock.sleep`| 10 seconds
+A `.catch` handler’s execution time| 1 second
+All `session.end` hooks together| 1.5 seconds
+`$.process.run` timeout| 30 seconds by default, 10 minutes at most
+`$.model.complete` `maxTokens`| 1024 by default, up to 64,000 or the model’s output limit
+`$.fs.read` and `$.fs.write`| 4 MiB for one file
+One string child of a `Text`| 10,000 characters
+`$.store`| 4 MiB of JSON in total
+`$.session.messages()`| The newest 4,096 entries
+`$.ui.invalidate('ui.render')` redraws| Throttled to 10 a second, or 30 in the terminal for the visible pane, the expanded band, and the hint line under the prompt. Calls that come sooner are coalesced.
+`$.ui.toast`| Shown for 4 seconds unless you pass `{ timeoutMs }`
+A pane opened without the user asking| Placed from 144 terminal columns, 110 after they’ve opened it once
+Command, tool, subagent type, and pane names| Letters, digits, `_`, and `-`, up to 64 characters
+One `claude plugin test` test| 5 seconds unless the test sets `timeoutMs`
+
+##
+
+
+
+Settings and environment variables
+
+These are the settings and environment variables that affect mods. The Where column says which settings file or environment each one is read from:
+
+Name| Where| What it does
+---|---|---
+`CLAUDE_CODE_PLUGIN_DIRS`| Environment, or `env` in `~/.claude/settings.json`| Plugin directories to load as `--plugin-dir` does, for apps you can’t pass a flag to. Absolute paths separated by `:`, or `;` on Windows.
+`CLAUDE_CODE_PLUGIN_DIR_WATCH`| Environment| `1` makes a long-running non-interactive session reload `--plugin-dir` mods on save
+`prependPlugins`, `appendPlugins`| Managed settings. User settings only on a machine with no managed settings, for a user who isn’t signed in with a Team or Enterprise plan.| Lists of plugin ids, such as `acme-guard@acme-tools`. Mods in `prependPlugins` run before every mod a user installs, and mods in `appendPlugins` run after, in the listed order. See [The order mods run in](</docs/en/plugins/mods/events#the-order-mods-run-in>).
+`allowManagedModsOnly`| Managed settings, as an [option on the built-in guard](</docs/en/plugins/mods/admin#set-options-on-the-built-in-guard>)| Only mods that [count as your organization’s](</docs/en/plugins/mods/admin#install-your-organizations-mods>), and mods built into Claude Code, load. Users’ settings hooks keep running.
+`allowModsToOverrideDenyRules`| Managed settings, as an [option on the built-in guard](</docs/en/plugins/mods/admin#set-options-on-the-built-in-guard>)| Lets a mod a user installed approve a tool call that a `deny` rule refuses
+`allowManagedHooksOnly`| Managed settings| Blocks hooks and installed mods that aren’t your organization’s. See [what keeps running](</docs/en/settings-reference#what-runs-under-allowmanagedhooksonly>).
+`disableAllHooks`| Any settings file| In managed settings, no mod or hook from an installed plugin runs. In your own settings, what your organization manages keeps running. See [`disableAllHooks`](</docs/en/settings-reference#disableallhooks>).
+`disableSideloadFlags`| Managed settings| Rejects `--plugin-dir` and `--plugin-url` at startup
+`pluginConfigs`| User or managed settings| Holds `userConfig` values for a mod, keyed by the plugin’s id, such as `acme-guard@acme-tools`, or its name and `@inline`, such as `first-mod@inline`, for one loaded with `--plugin-dir`
+
+`sec-default@builtin` is a guard built into Claude Code, listed as `cc-plugin-sec-default` in `/plugin` and the debug log. It loads ahead of every mod a person installs on a machine with managed settings, or for a user signed in with a Team or Enterprise plan. If managed `prependPlugins` is set, the guard loads only when that list names it, at the position listed. Its source is in the [`mods/sec-default` directory of the Claude Code repository](<https://github.com/anthropics/claude-code/tree/main/mods/sec-default>).
+
+##
+
+
+
+Commands
+
+These commands and flags load, inspect, and test a mod. The `claude` commands run in your shell and the `/` commands at the Claude Code prompt. In the table, `<directory>` stands for a path you type, as in `claude plugin validate ./first-mod`. Square brackets mark an optional argument.
+
+Command| What it does
+---|---
+[`/plugin`](</docs/en/plugins/mods/overview#see-which-mods-a-session-loaded>)| Shows a line such as `1 mod active · first-mod` under its tabs when a mod that isn’t built in has loaded
+[`claude plugin validate <directory>`](</docs/en/plugins/mods/create#check-what-claude-code-reads-from-your-mod>)| Reads a plugin’s manifest and hooks module and reports errors, the events it handles, and the mods API calls it makes. `--strict` treats warnings as errors and `--json` prints a machine-readable report.
+[`claude plugin test [directory]`](</docs/en/plugins/mods/test#write-a-test>)| Runs every file under the directory, or the current directory when you give none, whose name ends in `.test.ts` or `.test.tsx`. Exits with status 1 when a test fails.
+[`claude --plugin-dir <directory>`](</docs/en/plugins/mods/create#write-a-mod-yourself>)| Loads a plugin directory for one session and reloads its hooks module when you save. Repeat the flag to load several.
+`/reload-plugins`| Reloads plugins when you run it