Skip to main content
The type declarations on GitHub document the events, mods API methods, and props a mod 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 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.
  • A render 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. 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 into your mod’s directory.

Files

A mod is a plugin directory with these files: register receives on and options. options holds the values of the userConfig fields the manifest declares, with defaults filled in.

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, such as on a Team or Enterprise login, ask the organization’s administrator to install your mod as theirs. If you or another user installs it instead, the hook doesn’t run in those sessions 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 for a section or a tool loaded upfront until a new conversation or a compaction. The changed text reaches Claude on the next turn, and the prompt cache 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 then starts over. Requires Claude Code v2.1.331 or later.

Subagent starts

agent.spawn fires when a subagent or an agent team 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 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 hook.

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

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 is loaded, your hook doesn’t get these events unless your mod counts as your organization’s. On these events, e.init and the value that next(e) resolves to can hold these fields, among others: These events and fields require Claude Code v2.1.321 or later.

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 or 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. 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
  • 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.
A tree taller than the pane scrolls as a whole.

Elements

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. 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
  • 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, and rows on an Input
  • Svg: isInteractive
The terminal also ignores size, mono, and tabular on a Text.

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. A Box whose borderStyle names anything else, such as 'rounded', draws with no border.

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.

Related resources