← 返回 Skills 市场
xujianjian2004

Comfyui Node Basics

作者 穿山阅海 · GitHub ↗ · v0.1.0 · MIT-0
cross-platform ✓ 安全检测通过
29
总下载
0
收藏
0
当前安装
1
版本数
在 OpenClaw 中安装
/install comfyui-node-basics
功能描述
ComfyUI custom node fundamentals - V3 node structure, Schema, inputs/outputs, registration. Use when creating new ComfyUI custom nodes, defining node classes...
使用说明 (SKILL.md)

ComfyUI Custom Node Basics (V3 API)

ComfyUI uses Python classes to define nodes. The V3 API is the current recommended approach. Nodes inherit from io.ComfyNode and define a schema + execute method.

Quick Start

from comfy_api.latest import ComfyExtension, io

class MyNode(io.ComfyNode):
    @classmethod
    def define_schema(cls):
        return io.Schema(
            node_id="MyNode",
            display_name="My Custom Node",
            category="my_category",
            inputs=[
                io.Image.Input("image"),
                io.Float.Input("strength", default=1.0, min=0.0, max=1.0, step=0.01),
            ],
            outputs=[
                io.Image.Output("IMAGE"),
            ],
        )

    @classmethod
    def execute(cls, image, strength):
        result = image * strength
        return io.NodeOutput(result)

V3 Node Class Structure

Every V3 node requires:

  1. Inherit from io.ComfyNode
  2. define_schema(cls) - classmethod returning io.Schema
  3. execute(cls, ...) - classmethod performing the computation
from typing_extensions import override
from comfy_api.latest import ComfyExtension, io

class ImageBrighten(io.ComfyNode):
    @classmethod
    def define_schema(cls):
        return io.Schema(
            node_id="ImageBrighten",          # unique identifier
            display_name="Brighten Image",     # shown in UI
            category="image/adjust",           # menu path
            description="Adjusts image brightness",
            inputs=[
                io.Image.Input("image"),
                io.Float.Input("factor", default=1.2, min=0.0, max=3.0, step=0.1),
            ],
            outputs=[
                io.Image.Output("IMAGE"),
            ],
        )

    @classmethod
    def execute(cls, image, factor):
        result = torch.clamp(image * factor, 0.0, 1.0)
        return io.NodeOutput(result)

io.Schema Fields

io.Schema(
    node_id="UniqueNodeID",            # required: unique string ID
    display_name="Display Name",        # optional: shown in UI menus
    category="category/subcategory",    # menu hierarchy (default "sd")
    description="Node description",     # optional: tooltip text
    inputs=[...],                       # list of Input objects
    outputs=[...],                      # list of Output objects
    hidden=[...],                       # list of Hidden enum values
    is_output_node=False,               # True for nodes with side effects (save, preview)
    is_experimental=False,              # marks as experimental
    is_deprecated=False,                # marks as deprecated
    is_dev_only=False,                  # hidden unless dev mode enabled
    is_api_node=False,                  # marks as API-only node
    is_input_list=False,                # receive full lists instead of individual items
    not_idempotent=False,               # prevents caching
    accept_all_inputs=False,            # accept arbitrary inputs via **kwargs
    enable_expand=False,                # allow node expansion (subgraphs)
    search_aliases=["alias1", "alias2"],# alternative search terms
    essentials_category="Basic",        # optional: Essentials tab category
    price_badge=None,                   # optional: PriceBadge for API nodes
    has_intermediate_output=False,      # True for nodes with interactive UI that produce intermediate outputs
)

V3 Node Registration

V3 nodes are registered via ComfyExtension and comfy_entrypoint():

from typing_extensions import override
from comfy_api.latest import ComfyExtension, io

class MyNode(io.ComfyNode):
    @classmethod
    def define_schema(cls):
        return io.Schema(
            node_id="MyNode",
            display_name="My Node",
            category="my_nodes",
            inputs=[io.String.Input("text", multiline=True)],
            outputs=[io.String.Output()],
        )

    @classmethod
    def execute(cls, text):
        return io.NodeOutput(text.upper())


class MyExtension(ComfyExtension):
    @override
    async def get_node_list(self) -> list[type[io.ComfyNode]]:
        return [MyNode]


async def comfy_entrypoint() -> MyExtension:
    return MyExtension()

The comfy_entrypoint() function must be defined at the module level (in the file directly imported by ComfyUI).

V1 Node Structure (Legacy Reference)

V1 nodes use class attributes and NODE_CLASS_MAPPINGS:

class MyNodeV1:
    CATEGORY = "my_category"
    FUNCTION = "execute"
    RETURN_TYPES = ("IMAGE",)
    RETURN_NAMES = ("image",)

    @classmethod
    def INPUT_TYPES(s):
        return {
            "required": {
                "image": ("IMAGE",),
                "strength": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 1.0}),
            }
        }

    def execute(self, image, strength):
        return (image * strength,)

NODE_CLASS_MAPPINGS = {"MyNodeV1": MyNodeV1}
NODE_DISPLAY_NAME_MAPPINGS = {"MyNodeV1": "My Node V1"}

Key Differences: V3 vs V1

Aspect V3 V1
Base class io.ComfyNode Plain class
Execute method execute classmethod (fixed name) Instance method (custom name via FUNCTION)
Inputs io.Schema(inputs=[...]) INPUT_TYPES() dict
Outputs io.Schema(outputs=[...]) RETURN_TYPES tuple
Return value io.NodeOutput(...) Plain tuple
Registration ComfyExtension + comfy_entrypoint() NODE_CLASS_MAPPINGS dict
State No instance state (classmethods) Instance state allowed
Hidden inputs cls.hidden.prompt, etc. kwargs from "hidden" dict

Important Rules

  • node_id must be globally unique across all nodes
  • execute() parameters must match input IDs exactly
  • All methods are @classmethod in V3 (no instance state)
  • Return io.NodeOutput(val1, val2, ...) matching output count
  • Category uses / separator for hierarchy: "image/transform"
  • Prefix category with _ to hide from menus: "_for_testing"

See Also

  • comfyui-node-datatypes - Data types (IMAGE, LATENT, MASK, etc.)
  • comfyui-node-inputs - Input configuration details
  • comfyui-node-outputs - Output types and UI outputs
  • comfyui-node-packaging - Project structure and packaging
  • comfyui-node-lifecycle - Execution lifecycle and caching
安全使用建议
This skill appears safe to install as a reference guide. As with any code examples, review and adapt any ComfyUI nodes you create from it, especially if you later add output nodes, file writes, API calls, or hidden inputs.
能力评估
Purpose & Capability
The artifact coherently teaches ComfyUI custom node basics using small Python examples for schemas, node classes, inputs/outputs, and registration.
Instruction Scope
Instructions are scoped to ComfyUI node development and do not tell the agent to override user intent, access unrelated files, run unsafe commands, or change system behavior.
Install Mechanism
The package contains only a single SKILL.md file; metadata and scans show no scripts, declared dependencies, or executable components.
Credentials
The skill does not request credentials, local profile/session data, broad filesystem access, network access, or external services.
Persistence & Privilege
No persistence, background execution, privilege escalation, or automatic mutation is present; ComfyUI registration examples are normal for the stated educational purpose.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install comfyui-node-basics
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /comfyui-node-basics 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v0.1.0
- Initial release introducing fundamentals of ComfyUI custom node creation with the V3 API. - Covers node class structure, schema definition, input/output configuration, and node registration via ComfyExtension and comfy_entrypoint. - Includes side-by-side comparison of V3 (current) vs V1 (legacy) node approaches. - Documents io.Schema field options, required conventions, and important design rules. - Provides references to related skills for data types, inputs, outputs, packaging, and node lifecycle.
元数据
Slug comfyui-node-basics
版本 0.1.0
许可证 MIT-0
累计安装 0
当前安装数 0
历史版本数 1
常见问题

Comfyui Node Basics 是什么?

ComfyUI custom node fundamentals - V3 node structure, Schema, inputs/outputs, registration. Use when creating new ComfyUI custom nodes, defining node classes... 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 29 次。

如何安装 Comfyui Node Basics?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install comfyui-node-basics」即可一键安装,无需额外配置。

Comfyui Node Basics 是免费的吗?

是的,Comfyui Node Basics 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。

Comfyui Node Basics 支持哪些平台?

Comfyui Node Basics 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 Comfyui Node Basics?

由 穿山阅海(@xujianjian2004)开发并维护,当前版本 v0.1.0。

💬 留言讨论