Follow Discord
Sweep 06 Nov 2026 · 01:32Z Build v2.1.319 537 read Stable v2.1.311 Latest v2.1.318 Next v2.1.319 Feeds RSS JSON llms.txt llms-full.txt Unofficial
Mods API

The whole surface.

Every noun, verb, event and type a Claude Code mod can reach, with the signature and the doc comment Claude Code wrote for it. Anthropic's Mods reference covers the same surface a table at a time. This is every declaration in full, and none of it is written by hand here: the release pipeline pulls the declarations out of the shipped binary and this section renders what it found.

Search to find a name. The three pages under it are the same symbols in full, with the source text.

Symbols866every one, in the index below
Mined from2.1.319the shipped binary
Machine readableapi.jsonin pages, sized for an agent's fetch; api-full.json is the whole document
What changed

v2.1.319

+9 added · 4 removed · 3 changed · 3 docs only 5 may break Every release since v2.1.259
  1. The engineEvery noun and verb on $, with its signature, its parameters and the example the declarations carry.
  2. $.clock.every verb Calls fn every ms milliseconds (at least 1) until cancel().
  3. $.http noun The network, through the host.
  4. $.http.fetch verb Fetches url through the host (never the plugin's own network) and resolves { status, ok, headers, text } once the body is read.
  5. $.process noun Commands on the host, run as the user the session runs as. CLI only.
  6. $.process.run verb Runs a command on the host by its argument vector (no shell) and resolves { exitCode, stdout, stderr } once it exits, any exit code.
  7. $.process.spawn verb Starts a command on the host by its argument vector (no shell) and streams what it writes, piece by piece, then how it ended.
  8. $.settings noun What the settings files, --settings and managed policy hold, as the engine runs under it; read only.
  9. $.settings.read verb Resolves with the settings merged over every source, with one source's settings as loaded ({ source }), or with the value of one top-level key ({ key }), undefined when the settings hold none.
  10. $.env noun The environment of this process, the one every Bash child, MCP server and $.process.run command started after inherits.
  11. $.env.get verb Resolves with the variable's value, or undefined when it is unset.
  12. $.env.set verb Sets the variable for this process and everything it starts after, or unsets it when value is undefined.
  13. EventsEvery event a hook can be registered for, with the payload it arrives with and the result it may return.
  14. tool.call event Fires when the engine is about to run a tool. Each next(e) runs the hooks beneath, then core (the permission prompt, the tool itself).
  15. tool.check event Fires when the engine decides whether a tool call may run, after the tool.call and PreToolUse hooks and before the mode settles an ask.
  16. ui.render event Fires when the engine is about to draw a component: once per input value (props, viewport width), plugin load or $.ui.invalidate("ui.render").
  17. ui.resolve event Fires when the plugins load (not per draw), once per surface, component and plugin: e names the surface and component, never the props.
  18. ui.press event Fires when a Button a render hook drew is pressed on a surface; e is { plugin, element, component, surface }, element the button's key.
  19. ui.input event Fires when an Input a render hook drew changes or is submitted; e is { plugin, element, component, surface, kind, value }.
  20. ui.select event Fires when a Select a render hook drew is picked from; e is { plugin, element, component, surface, value }.
  21. ui.message event Fires when a Client THIS plugin drew posts from its surface module (surface.post(data)); only this plugin's hooks see it.
  22. ui.fault event Fires when a Client THIS plugin drew failed on a surface: its module did not load, its drawing failed, or its code failed after it had drawn.
  23. ui.scroll event Fires before a site's window moves: the person's wheel or scroll keys on a Pane body or the AbovePrompt band, at its edges too; $.ui.scroll.
  24. ui.focus event Fires before a site's focus ring moves: the person's Tab, arrows or click in a Pane or the band; an autoFocus element taking it; $.ui.focus.
  25. agent.offer event Fires when the engine offers an agent type to the model, in the agent listing and again at dispatch; next(e) resolves to { isOffered: true }.
  26. agent.spawn event Fires when the Agent tool, or a workflow script's agent() (e.workflow), is about to start an agent, its model not yet resolved.
  27. prompt.submit event Fires when a prompt is submitted, before the turn starts. next(e) runs the hooks beneath and the UserPromptSubmit settings hooks, then it enters.
  28. prompt.fill event Fires when a text is about to be put in the prompt box as the person's draft (a plugin's $.prompt.fill); next(e) writes it by e.mode.
  29. prompt.suggest event Fires when a text is proposed as the prompt box's dim suggestion, Tab to take: the engine's guess after a turn, or a plugin's $.prompt.suggest.
  30. prompt.edit event Fires when the person edits the main prompt box: a key the editor took as an edit, or a paste; next(e) resolves the box the editor shows.
  31. prompt.change event Fires after the main prompt box's text changed and no prompt.edit carried it: a recalled history entry, a clear, a plugin's fill.
  32. prompt.autocomplete event Fires as the person types in the main prompt box, for the token at the cursor; next(e) resolves to { suggestions }, rows for the typeahead.
  33. prompt.section event Fires once per named section of the system prompt, when the engine assembles it; next(e) resolves to { text } as core computed it.
  34. prompt.context event Fires once per conversation, when the engine computes the context blocks its first user message carries; next(e) resolves to { blocks }.
  35. prompt.compose event Fires when the engine renders a system prompt; next(e) resolves to { sections }, each { id, text, scope }, in the order they are sent.
  36. prompt.attachment event Fires once per message the engine injects for the model on its own (a reminder, a mode transition, a mentioned file), as a request carries it.
  37. prompt.mention event Fires once per path a prompt names after an @, a directory aside, before the engine reads it; next(e) reads it and resolves { type }.
  38. tool.describe event Fires when the engine first renders the tool's schema in a session; next(e) resolves to { description, isDeferred? }.
  39. command.run event Fires when a slash command is about to run (/name args typed, or a plugin's $.command.run); next(e) resolves to { text }, its output.
  40. command.describe event Fires once per command, when the engine lists it for the typeahead and /help; next(e) resolves to { description, argumentHint, isHidden }.
  41. config.set event Fires when a /config row is about to change, from the menu or a plugin's $.config.set; next(e) resolves to { value } once written.
  42. config.describe event Fires once per /config row, when the menu lists it and for $.config.list; next(e) resolves to { label, description, isHidden }.
  43. telemetry.log event Fires when a record is about to be logged to the destination e.to names: a built-in's $.telemetry.log, or the engine's own events.
  44. telemetry.mark event Fires when one use of a feature is marked ($.telemetry.mark), as the CLI's own feature events mark one; always for anthropic, no to.
  45. skill.prompt event Fires when the engine expands a skill's prompt for the model (/name, the Skill tool, a preload); next(e) resolves to { text } as computed.
  46. attribution.text event Fires when the engine composes a git text the model is to write (kind: commit, pr, exemption, remedy); next(e) resolves to { text }.
  47. session.start event Fires once per process for each loaded plugin, before the first prompt, then once per fresh load of one (never /clear); next(e) is { cwd }.
  48. session.receive event Fires when a delivery reaches the session, before it is queued: a relay's event, a peer's message, a Remote Control prompt, room events; { text }.
  49. session.append event Fires once per row a conversation of this session keeps (a prompt, a response block, a tool result, a notice), before it is stored.
  50. session.send event Fires when a plain-text message is about to leave this conversation for another agent or session (the SendMessage tool, or $.session.send).
  51. session.compact event Fires when the conversation is about to be compacted (/compact, the threshold, a plugin, or ahead of time); next(e) resolves { messages }.
  52. session.attach event Fires when a remote client joins the session's roster of attached surfaces: it said so (ui_attach), or it first asked to draw.
  53. session.detach event Fires when a client leaves the roster: it detached, or the session ended with it attached (e.reason). Observe; next(e) echoes { clientId }.
  54. session.measure event Fires when the engine measures the session and a unit moved: after each main-thread turn, and when a rate-limit window moves a whole point.
  55. session.end event Fires once when the session ends (exit, /clear, resume, logout, signal, a -p run done), after its SessionEnd settings hooks; e.reason says which.
  56. plugin.register event Fires once per hooks module about to join the chain, at load (the set folded and built, nothing swapped in) and at reload; core allows.
  57. turn.start event Fires when a model turn begins, main's or a subagent's (e.agentId), before its first model call; next(e) resolves to { turnId }.
  58. turn.step event Fires when the engine is about to send a model request of a turn, main's or a subagent's (e.agentId); next(e) resolves to the whole response.
  59. turn.complete event Fires when a model turn has ended, at the point its duration is reported; next(e) resolves to { text }, the answer. e.reason says why.
  60. engine.create event Runs while $ is being built, once per load or reload of this plugin and before any other hook of it; next(e) resolves to $ built so far.
  61. model.complete event The argument of $.model.complete(request, { signal }), its text as strings and its blocks beside them (ModelCompleteInput).
  62. model.fork event The argument of $.model.fork(request).
  63. audio.speak event The argument of $.audio.speak(text, { voice }).
  64. session.cwd event The argument of $.session.cwd().
  65. session.root event The argument of $.session.root().
  66. session.model event The argument of $.session.model().
  67. session.turns event The argument of $.session.turns().
  68. session.id event The argument of $.session.id().
  69. session.messages event The argument of $.session.messages(args): {} for the main conversation, { agentId } for one of its agents, as for the form.
  70. session.repo event The argument of $.session.repo().
  71. session.surface event The argument of $.session.surface().
  72. session.surfaces event The argument of $.session.surfaces().
  73. session.authorize event The argument of $.session.authorize().
  74. session.identity event The argument of $.session.identity().
  75. session.usage event The argument of $.session.usage({ breakdown, columns }).
  76. session.version event The argument of $.session.version().
  77. prompt.read event The argument of $.prompt.read().
  78. prompt.paint event The argument of $.prompt.paint(...): the draft and this plugin's runs.
  79. tool.list event The argument of $.tool.list().
  80. tool.register event The argument of $.tool.register(spec).
  81. command.list event The argument of $.command.list().
  82. command.register event The argument of $.command.register(spec).
  83. config.list event The argument of $.config.list().
  84. agent.list event The argument of $.agent.list().
  85. agent.register event The argument of $.agent.register(spec): the agent type as the plugin defined it. A hook above rewrites any of it; the type stays the caller's.
  86. ui.open event The argument of $.ui.open({ id, title, focus }); a hook above the opener may retitle it or refuse it with { deny }, never rename it.
  87. ui.close event The argument of $.ui.close({ id }) with origin plugin; the engine raises it too, for the person (person) and an unload (unload).
  88. ui.panes event The argument of $.ui.panes().
  89. ui.place event The argument of $.ui.place({ id }).
  90. theme.set event The argument of $.theme.set(attributes): the attributes themselves.
  91. theme.clear event The argument of $.theme.clear().
  92. ui.selection event The argument of $.ui.selection().
  93. ui.copy event The argument of $.ui.copy({ text, surface }), surface filled with the session's first when left out; rewritable, deniable, answerable.
  94. ui.view event The argument of $.ui.view({ agentId }): whose transcript the main view is to show, none for the main conversation; rewritable and deniable.
  95. ui.blit event The argument of $.ui.blit(...): a Raster's cells or a keyed Image's source; a hook above may rewrite either with next, or { deny }.
  96. fs.ancestors event The argument of $.fs.ancestors({ names, of, below }).
  97. store.keys event The argument of $.store.keys().
  98. state.get event The argument of $.state.get(ref): the reference itself, plugin, key and a family member's id; identity, pinned.
  99. state.set event The argument of $.state.set(ref, value, { ifVersion }): the reference, the value, the condition, and previous, what stood there (the host's).
  100. clock.now event The argument of $.clock.now().
  101. clock.sleep event The argument of $.clock.sleep(ms, { signal }); the signal does not cross, it aborts the dispatch.
  102. clock.after event The argument of $.clock.after(ms, fn): the wait before fn, which stays in the plugin's environment and runs once the dispatch resolves.

What the file says about itself

Claude Code writes the declarations with an introduction at the top, and this is it, reproduced as it ships. Until Anthropic published their mods docs with 2.1.287, it was the only guidance that came with the surface.

EARLY ACCESS: this surface may change between releases without notice. Written by the engine each time it loads a mod from a folder the person owns, beside that mod as .claude-plugin/types/claude-code/index.d.ts; written again after an update rather than edited. The first line names the Claude Code version that wrote it. TypeScript 5.4 or newer reads it. `claude plugin validate <dir>` is the other half: it reads a plugin's manifest and its hooks module's source the way the engine will and reports what the module hooks and calls and everything the engine would refuse, before any session loads it.

What is here: the module a hooks module may import types from,

import type { Register, On, EngineInterface } from 'claude-code'

(at run time the import is empty), and the globals a hooks module has: `h` and `Fragment` (what JSX compiles against), the JSX namespace, and the environment's web APIs (URL, TextEncoder, AbortController, crypto.subtle, ...). A hooks module runs in an environment of its own: no DOM, no Node. The module, and every file it imports from the plugin, is named .ts, .tsx, .jsx, .js, .mjs, .cjs, .mts or .cts (a file named otherwise is not loaded) and is an ES module whatever its suffix: there is no `require`. A file of the plugin is imported with an `import` declaration. A module holding `import()` does not load. The elements a render hook draws with (`Box`, `Text`, `Button`, ...) are not globals: they come from the surface's table,

const { Box, Text } = $.ui.resolve(e)

Also here: 'claude-code/testing', the kit a plugin's *.test.ts and *.test.tsx files import under `claude plugin test <dir>`, which runs each in an environment like the one a plugin's hooks run in (no fs, network or process), the plugin loaded from the folder by the engine's own host: `test(name, async ($, on) => { ... })`, where `$` is the engine's own and the hooks `on` registers sit beneath every plugin; with describe, expect, tier, and `mock`, whose clock, store and env answer those nouns beneath the plugins from memory. `$.ui.mount` draws a component through the plugin on the surface the test names (terminal, desktop, vscode or mobile: never assumed) and hands back the drawing to read and act on by key: find an element, press a Button, type into an Input, drive a `Client`'s module (keys, pointer, posts, its frame clock), each act typed by that surface's element table, so one test body run over several surfaces covers the mod's hooks and description on each. It exercises the mod (its hooks, the tree they return under each surface's rules, its `Client` modules), never a surface's paint (Ink's, the desktop page's):

test('notes add up on every surface that takes input', async $ => {
  for (const surface of ['terminal', 'desktop'] as const) {
    const ui = await $.ui.mount({ plugin: 'notes', surface, ...BAND })
    await ui.input({ key: 'new', text: 'milk' })
    expect((await ui.find({ key: 'count' }))?.text).toBe('1 note')
    await ui.key({ key: 'down', in: 'list' })
    await ui.unmount()
  }
  for (const surface of ['terminal', 'desktop', 'vscode', 'mobile'] as const) {
    const ui = await $.ui.mount({ plugin: 'notes', surface, ...HINT })
    expect(await ui.find({ type: 'Text', text: /notes/ })).toBeDefined()
    await ui.press({ key: 'dismiss' })
  }
})

Typing a plugin against it:

export const register: Register = (on, options) => { ... }

or, in a .js module,

/** @type {import('claude-code').Register} */
export const register = (on, options) => { ... }

A tsconfig.json (or jsconfig.json) that fits a hooks module:

{
  "compilerOptions": {
    "target": "es2023", "lib": ["es2023"], "types": [],
    "module": "esnext", "moduleResolution": "bundler",
    "strict": true, "noUncheckedIndexedAccess": true,
    "noEmit": true, "skipLibCheck": true,
    "jsx": "react", "jsxFactory": "h", "jsxFragmentFactory": "Fragment"
  },
  "include": [".claude-plugin/types", "hooks", "types", "tests"]
}

".claude-plugin/types" is where the engine lays this file (claude-code/) and, beside it, this build's built-in tools (claude-code-tools/), the MCP tools connected when the mod last reloaded (claude-code-mcp/) and one entry per plugin the mod's plugin.json lists under "dependencies" (that plugin's own contract): what it adds to `$` in engine.create, so a plugin you depend on is typed with nothing copied (the include above takes the whole folder). "hooks" is the plugin's hooks/ folder, "types" its own contract and "tests" its test files. `lib` names no DOM: the environment has none, and its `Text` would shadow the element. A mod with no tsconfig of its own has these options without writing them: the engine gives it a tsconfig.json that extends .claude-plugin/types/tsconfig.json, which carries them with that folder as the one type root.

A plugin that adds a noun to `$` ships its own contract: a .d.ts its plugin.json names as "types", exporting the noun's types at its top level and declaring the noun on the engine's interface,

export type Topo = { ... }
declare module 'claude-code' {
  interface EngineInterface { topo: Topo }
}

with no import or reference, its exported names led by the noun's PascalCase name; the plugin's own hooks module imports them from it.

Where this comes from

Claude Code carries its own type declarations for the hooks runtime. From 2.1.287 it writes them into .claude-plugin/types/ each time it loads a mod from --plugin-dir, and before that /plugin-types wrote them on request. They are not in the npm package as a file and not in the JavaScript bundle either: Claude Code decompresses an asset embedded in the binary. So documenting the surface used to mean installing a build and running it by hand, which is why nobody did it twice.

The release pipeline reads that asset straight out of the binary it already downloads, parses it, and writes a JSON document beside the rest of the release data. This section renders that document. Which means it is never a release behind, and nobody has to remember anything.

The prose about how to use any of this, what the calls cost, and which ones do not behave the way their shape suggests is the Mods Guide. This section is the inventory.

Mined from build 2.1.319 on 6 Nov 2026 . The declarations are Claude Code's own writing about itself, reproduced here; everything around them is this site's.

Feedback