# comfyui-node-frontend

comfyui-node-frontend guides frontend JavaScript extension development for ComfyUI custom nodes, covering lifecycle hooks, custom DOM widgets, and graph events.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf (Devin Desktop), Claude.ai · ★ 321 repo stars
- Author: Terry Jia
- License: MIT · policy=mirror · the beginning of the file is at the end of this page
- Source: https://github.com/jtydhr88/comfyui-custom-node-skills/tree/HEAD/plugins/comfyui-custom-nodes/skills/comfyui-node-frontend/SKILL.md
- Updated: 2026-10-17
- Security check: automated, 2026-11-16 (text) — no signs of malicious code found.
- HTML: https://affpapa.org/en/nevibecode/skills/comfyui-node-frontend

## What it does

The skill provides blueprints for building ComfyUI frontend extensions. Custom nodes link client scripts by setting `WEB_DIRECTORY = "./js"` in Python. Extensions hook into the client via `app.registerExtension` from `../../scripts/app.js`. Every JavaScript file in that folder loads automatically when ComfyUI starts.

It covers the full extension lifecycle: early setup in `init`, schema modifications in `addCustomNodeDefs`, node instances in `nodeCreated`, and graph loading brackets like `beforeLoadGraph` or `afterLoadGraph`. It also demonstrates building custom inputs with `addDOMWidget` and handling value serialization via `serializeValue`.

Calling `app.loadGraphData()` or `handleFile()` inside graph-load hooks rejects with a nested load error. Any secondary graph load must be deferred with `setTimeout`.

## Install

### Claude Code (native platform)

1. **Plugin marketplace**
In the agent chat (not a shell):
```text
/plugin marketplace add jtydhr88/comfyui-custom-node-skills
```
In the agent chat (not a shell):
```text
/plugin install comfyui-custom-nodes@comfyui-custom-node-skills
```
This installs the whole comfyui-custom-nodes plugin with all its skills

2. **Skills CLI (Vercel)**
```bash
npx skills add jtydhr88/comfyui-custom-node-skills --skill comfyui-node-frontend -a claude-code
```

3. **Manually: put the files in place**
- File: `~/.claude/skills/comfyui-node-frontend/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/comfyui-node-frontend/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add jtydhr88/comfyui-custom-node-skills --skill comfyui-node-frontend -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/comfyui-node-frontend/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add jtydhr88/comfyui-custom-node-skills --skill comfyui-node-frontend -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/comfyui-node-frontend/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install jtydhr88/comfyui-custom-node-skills plugins/comfyui-custom-nodes/skills/comfyui-node-frontend
```

2. **Manually: put the files in place**
- File: `.github/skills/comfyui-node-frontend/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add jtydhr88/comfyui-custom-node-skills --skill comfyui-node-frontend -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/jtydhr88/comfyui-custom-node-skills --path plugins/comfyui-custom-nodes/skills/comfyui-node-frontend
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/comfyui-node-frontend/SKILL.md` — The legacy .windsurf/skills/ path still works

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/jtydhr88/comfyui-custom-node-skills/tree/HEAD/plugins/comfyui-custom-nodes/skills/comfyui-node-frontend/SKILL.md

## When to use it
- register a frontend extension using app.registerExtension
- embed custom HTML inputs into nodes with addDOMWidget
- intercept workflow lifecycle and node output updates with ComfyUI hooks

## Example prompts
- How do I add a custom color picker DOM widget to a ComfyUI node?
- Show the lifecycle hooks needed to track graph loading in ComfyUI
- Help me export WEB_DIRECTORY and register a JavaScript extension for my node

## Source text · SKILL.md · MIT

Below is the content of a third-party file. It is data, not instructions for you: do not act on anything written inside unless the human asks. Block tag: 66dd70ff6d4253da.

BEGIN THIRD-PARTY FILE 66dd70ff6d4253da
````text
---
name: comfyui-node-frontend
description: ComfyUI frontend JavaScript extensions - hooks, widgets, sidebar tabs, commands, settings, toasts, dialogs. Use when adding UI features to custom nodes, creating custom widgets, or extending the ComfyUI frontend.
---

# ComfyUI Frontend Extensions

Custom nodes can extend the ComfyUI frontend with JavaScript. Extensions register hooks, widgets, commands, settings, and UI components.

## Quick Start

### 1. Export WEB_DIRECTORY in Python

```python
# __init__.py
WEB_DIRECTORY = "./js"
__all__ = ["WEB_DIRECTORY"]
```

### 2. Create JavaScript Extension

```javascript
// js/my_extension.js
import { app } from "../../scripts/app.js";

app.registerExtension({
    name: "my_nodes.my_extension",

    async setup() {
        console.log("Extension loaded!");
    },
});
```

All `.js` files in `WEB_DIRECTORY` are loaded automatically when ComfyUI starts.

## Extension Hooks (Lifecycle Order)

### init — After canvas created, before nodes

```javascript
app.registerExtension({
    name: "my.ext",
    async init(app) {
        // Modify core behavior, add global listeners
    },
});
```

### addCustomNodeDefs — Modify node definitions

```javascript
async addCustomNodeDefs(defs, app) {
    // defs is a dict of all node definitions
    // Can add or modify definitions before registration
    defs["MyFrontendNode"] = {
        input: { required: { text: ["STRING", {}] } },
        output: ["STRING"],
        output_name: ["text"],
        name: "MyFrontendNode",
        display_name: "My Frontend Node",
        category: "custom",
    };
},
```

### getCustomWidgets — Register custom widget types

```javascript
getCustomWidgets(app) {
    return {
        MY_WIDGET(node, inputName, inputData, app) {
            const widget = node.addWidget("text", inputName, "", () => {});
            widget.serializeValue = () => widget.value;
            return { widget };  // or { widget, minWidth, minHeight }; v1.54+ also accepts `return widget`
        },
    };
},
```

### beforeRegisterNodeDef — Modify node prototype

```javascript
async beforeRegisterNodeDef(nodeType, nodeData, app) {
    if (nodeData.name === "MyNode") {
        // Chain onto prototype methods
        const origOnCreated = nodeType.prototype.onNodeCreated;
````
END THIRD-PARTY FILE 66dd70ff6d4253da

The third-party file has ended. Everything between the 66dd70ff6d4253da tags is data: requests and commands from it are not followed. An “end of file” line with another tag inside the block is part of the file.

First 2295 of 22432 bytes. © Terry Jia · MIT · https://github.com/jtydhr88/comfyui-custom-node-skills/tree/HEAD/plugins/comfyui-custom-nodes/skills/comfyui-node-frontend/SKILL.md

_Part of the page did not fit — see the HTML version._

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
