artokun/comfyui-mcp/comfyui-frontend-extensions

Claude Code and agent skill by artokun/comfyui-mcp

Trust tier 2
  • community
  • ext:[{"type":"hook","description":"Pre/post lifecycle hooks"}]
Source check pending

Checking that the SKILL.md file is still in the repository.

Authoring ComfyUI v2 frontend extensions with @comfyorg/extension-api, covering defineNode/defineExtension/defineWidget, shell UI (sidebar tabs, commands, hotkeys), typed events, and handles. Use when writing or editing ComfyUI web-UI extension code (custom node JS, sidebar panels, widgets).

Install

npx vskill@latest install artokun/comfyui-mcp/comfyui-frontend-extensions

Semi-extensibleMentions customization, but needs skill-specific knowledge. Read the extensible skills standard

SKILL.md

The same SKILL.md was published earlier as artokun/comfyui-mcp/comfyui-frontend-extensions.

ComfyUI v2 Frontend Extension API

The v2 extension API is the published npm package @comfyorg/extension-api. It replaces the legacy app.registerExtension() / nodeType.prototype monkey-patching model with a typed, tree-shakeable, import-based API.

If you are converting an existing v1 extension, read
pattern-by-pattern mapping.

Mental model

v1 (legacy)v2 (@comfyorg/extension-api)
One giant app.registerExtension({...}) callOne defineX per concern, each independently disposable
window.app / app.* globalsDirect import from the package; no window.app at module-eval time
nodeType.prototype.onExecuted = ... patchingnode.on('executed', fn) on a NodeHandle
Mutate widget.value, assign widget.callbackwidget.setValue(v) / widget.on('valueChange', fn)
api.addEventListener('execution_start', fn)execution.on('start', fn) (typed namespaces)
Manual removeEventListener bookkeepingEvery subscription returns Unsubscribe; every defineX returns DisposableHandle

Core principles baked into the API:

  • Import, don't reach for globals. import { defineNode } from '@comfyorg/extension-api'. No window.app dependency at module evaluation time.
  • Read via getters, write via command-dispatch setters. getValue() reads; setValue() dispatches an undo-able, serializable command. Read-only invariants (set at construction) are readonly accessors (node.type, widget.name).
  • Observe via typed `on(...)` subscriptions. Each returns an Unsubscribe cleanup function. No Vue refs/signals are ever exposed; Vue reactivity is the internal engine only.
  • Everything is disposable. Every defineX returns a DisposableHandle with an idempotent, synchronous dispose().

Registration entry points

All imported from @comfyorg/extension-api:

FunctionPurposeReturns
defineNode(opts)Primary entry — react to node lifecycle (replaces prototype patching)NodeExtensionOptions
defineExtension(opts)App-scoped lifecycle (init/setup) + shell UI hostExtensionOptions
defineWidget(opts)Register a custom widget type (DOM via mount)WidgetExtensionOptions
defineSidebarTab(opts)Add a left-sidebar tab (Vue or custom)DisposableHandle
defineBottomPanelTab(opts)Add a bottom-panel tabDisposableHandle
defineToolbarButton(opts)Add an action-bar buttonDisposableHandle
defineCommand(opts)Register an invokable commandDisposableHandle
defineHotkey(opts)Bind a key combo to a command idDisposableHandle
defineSetting(opts)Add a settings-menu entryDisposableHandle
defineAboutBadge(opts)Add a badge to the About pageDisposableHandle

Imperative carve-outs (fire-and-forget, not defineX, no handle): toast, notify.

A single extension file typically exports a default defineExtension/defineNode result and calls the shell-UI defineX functions inside setup() or at module scope. They queue safely before the app boots.

defineNode — the primary entry point

Reacts to node lifecycle. nodeCreated fires once per node instance (typed in, pasted, duplicated, or loaded without an existing workflow). loadedGraphNode fires once when a node is restored from a saved workflow (widget values already populated). Exactly one of them fires per node entity, never both.

ts
import { defineNode, onNodeMounted, onNodeRemoved } from '@comfyorg/extension-api'
export default defineNode({
name: 'my-org.executed-logger',
// Filter to specific comfyClass names. Omit to receive every node type.
nodeTypes: ['KSampler', 'KSamplerAdvanced'],
// MUST be synchronous. Runs inside a Vue EffectScope; everything registered
// here (subscriptions, onNodeMounted) auto-disposes when the node is removed.
nodeCreated(node) {
// Read-only invariants
console.log(node.type, node.comfyClass, node.id)
// Subscribe to backend execution completion (replaces onExecuted patching)
node.on('executed', (e) => {
console.log('output:', e.output) // Record<string, unknown>
})
// Lifecycle hooks — call SYNCHRONOUSLY (never after an await)
onNodeMounted(() => {
// Node fully mounted; DOM/canvas ready.
})
onNodeRemoved(() => {
// Cleanup: abort fetches, close sockets. Does NOT fire on subgraph promotion.
})
},
loadedGraphNode(node) {
// Node restored from a saved workflow; widget values are already set.
}
})
NodeHandle surface (Phase A)
MemberKindNotes
id: stringreadonlyOpaque token. Compare with node.equals(other), never by slicing.
equals(other)methodCanonical identity comparison.
type: stringreadonlyLiteGraph node type.
comfyClass: stringreadonlyBackend class name.
getProperty<T>(key) / getProperties() / setProperty(key, v)methodsPer-instance props (migration shim — prefer widget values).
getInputs() / getOutputs()methodsReadonlyArray<Readonly<SlotInfo>> — frozen views.
on('executed', fn)methodExecution complete → NodeExecutedEvent { output }.
on('removed', fn)methodNode deleted (not subgraph promotion).
on('configured', fn)methodLoaded from saved workflow (after widget values restored).
on('beforeSerialize', fn)methodDeprecated — use widget-level beforeSerialize (ADR-0010).
Position/size/title/mode getters and slot/connection events are deferred in Phase A. Do not rely on getPosition, setSize, getMode, on('connected').
Nodes cannot enumerate or reference their widgets (node.getWidget(name) was removed). Use defineWidget and the mount context's ctx.widget handle.

defineExtension — app lifecycle + shell UI

Use for app-wide setup and to host shell-UI registrations. setup() runs at the early registration point; use the imported onMounted hook for work that needs the app fully initialized.

ts
import {
defineExtension,
onMounted,
onUnmounted,
execution,
toast
} from '@comfyorg/extension-api'
export default defineExtension({
name: 'my-org.my-extension',
setup() {
// Register late-lifecycle work via onMounted (called synchronously here).
onMounted(() => {
const off = execution.on('start', () => {
toast.show({ severity: 'info', summary: 'Run started' })
})
onUnmounted(off) // tidy teardown
})
}
})
A note on the setup() signature. The source-of-truth API uses implicit-context
hooks: import onMounted/onNodeMounted/etc. and call them synchronously inside
setup() (mirrors Vue's Composition API). An early package draft showed a
setup(ctx) { ctx.onNodeMounted(...) } context-argument style; prefer the imported-hook
form above, which is what the current API exports.

Context-scoped lifecycle hooks are imported and called synchronously inside defineExtension's setup(): onBeforeMount, onMounted, onUnmounted, onActivated, onDeactivated. defineSidebarTab/defineBottomPanelTab take no setup field; adding one is a type error. onActivated/onDeactivated fire when the surrounding tab or panel is shown or hidden.

defineWidget — custom widget types with DOM

Widgets are declared in the Python node's INPUT_TYPES, never created at runtime (node.addWidget is forbidden). defineWidget registers a type and the DOM mount hook the runtime invokes against a host <div> it owns. mount is optional; omit it for value-only widgets that render through the native renderer.

ts
import { defineWidget, type WidgetCleanup } from '@comfyorg/extension-api'
export default defineWidget({
name: 'my-org.color-picker',
type: 'COLOR_PICKER', // referenced from Python INPUT_TYPES
// The SOLE DOM seam. Capture host + constructed DOM via closure — there is
// no widget.element accessor.
mount(host, ctx): WidgetCleanup {
const input = document.createElement('input')
input.type = 'color'
input.value = String(ctx.widget.getValue() ?? '#000000')
input.addEventListener('input', () => ctx.widget.setValue(input.value))
host.appendChild(input)
// ctx.widget / ctx.node are the only legal handles here.
ctx.widget.on('valueChange', (e) => {
input.value = String(e.newValue ?? '#000000')
})
// Optional cleanup — fires once on widget destruction (NOT on host remount).
return () => input.remove()
}
})

WidgetMountContext also exposes onUnmount(fn), onBeforeRemount(fn), and onAfterRemount(fn => ...) for host-move scenarios (graph↔app mode, subgraph promotion). The mount body is not re-invoked across a remount; only the remount hooks fire.

WidgetHandle surface
MemberKindNotes
id / equals(other)readonly / methodOpaque identity.
name / widgetType / labelreadonlySet from INPUT_TYPES schema.
getValue<T>() / setValue(v)methodssetValue dispatches an undo-able command.
optionsreadonlyReadonly<WidgetOptions> snapshot. Writes raise TS errors.
getOption<K>(key) / setOption(key, v)methodsPer-instance overrides (e.g. min/max/step).
setHeight(px)methodResize the reserved host height (DOM widgets).
on('valueChange', fn)methodWidgetValueChangeEvent { oldValue, newValue }.
on('optionChange', fn)methodWidgetOptionChangeEvent { key, oldValue, newValue }.
on('beforeSerialize', fn)methodOnly async-allowed event. e.value + e.setSerializedValue(v).
on('beforeQueue', fn)methodPre-queue validation. Call e.reject(msg) to cancel.
ts
// Serialization override (the SOLE serialization interface in v2):
widget.on('beforeSerialize', (e) => {
e.setSerializedValue(processDynamicPrompt(widget.getValue()))
})
// Async serialization (e.g. capture a webcam frame before queueing):
widget.on('beforeSerialize', async (e) => {
e.setSerializedValue(await captureFrame())
})
// Pre-queue validation (replaces app.queuePrompt monkey-patching):
widget.on('beforeQueue', (e) => {
if (!widget.getValue()) e.reject('Prompt text is required before queueing.')
})

Typed event namespaces

Four module-level singletons replace api.addEventListener('...'). Each on() returns an Unsubscribe. Subscriptions made inside a setup() body auto-dispose on unmount; subscriptions made elsewhere are the caller's responsibility.

NamespaceEvents (canonical)Wire mapping
executionstart, end, error, interrupted, cached, executing, progress, previewexecution_<evt>
graphchanged, …graph:<evt>
serverstatus, logs, reconnected, feature_flags, assets, + custom-node eventsraw event name
workbenchnotification, …workbench:<evt>
ts
import { execution, server } from '@comfyorg/extension-api'
const off = execution.on('progress', (e) => console.log('progress', e))
// Custom-node events ride the `server` namespace with arbitrary names:
server.on('my-org.my-node.update', (e) => console.log(e))
// later:
off()

Payloads default to unknown today. Narrow them with TS module augmentation:

ts
declare module '@comfyorg/extension-api' {
interface ExecutionEventPayloads {
start: { promptId: string }
progress: { value: number; max: number }
}
interface ServerEventPayloads {
'my-org.my-node.update': { nodeId: string; text: string }
}
}

The augmentable interfaces are GraphEventPayloads, ExecutionEventPayloads, ServerEventPayloads, and WorkbenchEventPayloads.

Shell UI registrations

This is the start of the file. Read the full SKILL.md on GitHub.

Security

  • Security scanPassed, 93 of 100Pattern checks on the skill's files.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

Repository stars
651
Repository forks
101
7-day trend score
32

Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.

Extension points

  • hookPre/post lifecycle hooks

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/artokun/comfyui-mcp/comfyui-frontend-extensions/badge)](https://verified-skill.com/skills/artokun/comfyui-mcp/comfyui-frontend-extensions)

Something wrong with this skill or its page? Tell us.