plugin-authoring
БесплатноБез исполняемых скриптовНе проверенWrite or debug a Claude Code plugin made of function hooks (a hooks module exporting register(on, options), hooks ($, e, next) on events like tool.call…
от lza6★ 19 звёзд на GitHubОб этом скилле
You are about to write, extend or debug a plugin made of function hooks. This note is orientation: what such a plugin is, where its exact contract is written down for the build you are running in, and where to look when something does not take. The API is early access and moves between releases, so treat the generated declarations as the authority and this note as the map to them.
What a plugin of function hooks is
A plugin is a folder with a .claude-plugin/plugin.json manifest. Its
function hooks live in one hooks module: a TypeScript or JavaScript file
that hooks/hooks.json names under modules (one path, relative to that
file), exporting register(on, options). on(event, matcher?, hook) adds a
hook; options holds the values of the fields the manifest's userConfig
declares. Every hook has the shape ($, e, next): $ is the engine
interface (display, model, session, prompt, tools, filesystem, store,
clock, network, host commands, settings, environment, the config menu's rows and the rest), e is the event's input as a plain value,
and next(e) continues to the other plugins and then the engine's own
behaviour, resolving to the event's result. A hook that returns without
calling next answers for itself; one that calls next({ ...e, ... })
rewrites what the rest of the chain sees, within what that event allows.
The module runs in an environment of its own, with no DOM and no Node:
everything outside it is reached through $. JSX is available with h as
the factory.
The events cover tool calls and their descriptions, the prompt as submitted, the system prompt's sections and the first message's context blocks, what the interface
draws, the turn's start, steps and completion, the session's start and deliveries, each hooks module's admission, skills, subagents and attribution text. Which of them a
feature is, and what it needs from $, are the two questions worth settling before writing. One event streams: turn.step, a model request of the turn, whose hook is an
async generator (async function* ($, e, next) {}, the one form that loads there); next(e) is the stream beneath, yield* next(e) forwards it and evaluates to the
step's result, for await over it rewrites the chunks (TurnStepChunk) one at a time, yielding without next answers alone, and a chunk once yielded stays, so a hook
that fails mid-stream is left where it stood and the rest of the response comes from beneath it.
The types are the reference
Do not guess at an event's input, a method on $, or an element's props.
Run /plugin-types in the session (it takes an optional directory and
defaults to .claude/types). It writes two files from the running build:
claude-code.d.ts, which declares the module claude-code (import types
from it; at run time the import is empty), the globals a hooks module has,
and the inputs of this build's built-in tools; and claude-code-mcp.d.ts,
the inputs of the MCP tools connected right now, so e narrows per tool.
The header of claude-code.d.ts carries a tsconfig.json that fits a hooks
module and shows how to type register against Register.
Read that file for every event's input and result, every noun and method on
$ with its doc comment and example, every element each surface draws and
the props each element accepts, and the limits it states. Shapes there are
the engine's own, not the Messages API's: $.session.messages(), for one,
answers SessionMessage rows of { role, text, toolUses }, not content
blocks. When the build updates, regenerate rather than edit.
claude plugin validate <path> reads a plugin's manifest and its hooks
module's source and reports what the module hooks and calls, which is the
quickest check that the engine sees what you meant.
Developing one
claude --plugin-dir <folder> loads the plugin from disk for that session
only (repeat the flag for several). In an interactive session the folder is
watched: saving a file reloads the hooks module, so register runs again in
a fresh environment and the previous environment's timers are dropped.
Options for a plugin loaded this way are read from settings under
pluginConfigs, keyed by the plugin's <name> (or <name>@inline); each non-secret userConfig field is a row in the config menu too, and a change there reloads the module with the new options.
Run with claude --debug while developing. A hook that fails is skipped and
the chain continues without it, unless its registration's .catch handler
answers in its place; the transcript says so once, in a dim line naming the
plugin, the event and the reason, as it names a module that did not load. The debug log has every occurrence and each result the engine
refused, so a plugin that seems to do nothing has usually been told why.
Drawing: ui.render
A ui.render hook receives one component instance. e.component says
which component, e.surface where it is drawn (terminal, desktop or
mobile), e.requestId which
Установить plugin-authoring в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл plugin-authoring?
Write or debug a Claude Code plugin made of function hooks (a hooks module exporting register(on, options), hooks ($, e, next) on events like tool.call, prompt.submit, ui.render, session.start). Load it before writing or changing such a plugin; it says where the exact types come from, how to run a plugin under development, and where the engine reports what it refused.
Как установить скилл plugin-authoring?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл plugin-authoring запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
doc-coauthoring
Guide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision…
от Anthropicacademy-guide
Stop and check this skill before finishing any reply to a question about how to use Claude or a Claude product — it recommends matching courses, tutorials…
от Anthropicinternal-comms
A set of resources to help me write all kinds of internal communications, using the formats that my company likes to use. Claude should use this skill…
от Anthropicskill-development
This skill should be used when the user wants to "create a skill", "add a skill to plugin", "write a new skill", "improve skill description", "organize skill…
от Anthropic