К основному содержанию
скилл CX Codex

comfyui-node-lifecycle — скилл для Claude Code: установка и функции

Скилл comfyui-node-lifecycle объясняет жизненный цикл узлов ComfyUI: порядок выполнения, проверку входов и работу кэша. Пригодится при отладке и разработке пользовательских узлов.

MIT ★ 321 обновлён 2026-10-17

Установить в Claude Code · Через маркетплейс плагинов Все способы и платформы ↓
/plugin marketplace add jtydhr88/comfyui-custom-node-skills
/plugin install comfyui-custom-nodes@comfyui-custom-node-skills
Открыть на GitHub

Что делает comfyui-node-lifecycle

Скилл разбирает путь от проверки графа до выполнения узлов. ComfyUI начинает с выходных узлов и запускает только те узлы, которые ведут к выходу; порядок строится по зависимостям. Это помогает понять, почему узел пропущен или когда вызывается его функция.

Для управления кэшем описаны fingerprint_inputs в V3 и IS_CHANGED в V1: одинаковый результат отпечатка позволяет взять сохранённый вывод, другой — запустить узел заново. Флаг not_idempotent сам по себе не заставляет узел выполняться при каждом запуске. Валидацию входов до выполнения скилл связывает с validate_inputs и VALIDATE_INPUTS; также затронуты ленивые входы и промежуточные результаты. Примеры используют Python и API ComfyUI.

Какие задачи решает

  • разобраться, почему узел не выполняется
  • настроить повторный запуск узла через отпечаток входов
  • проверить значения до выполнения узла
  • понять порядок выполнения узлов графа
  • отличить запрет совместного кэширования от отключения кэша

Примеры запросов агенту

  • Объясни, почему узел ComfyUI не запускается, если он подключён к графу.
  • Покажи, как настроить fingerprint_inputs, чтобы узел выполнялся заново при каждом запуске.
  • Как проверить динамические входы в validate_inputs?

Как установить comfyui-node-lifecycle

1Через маркетплейс плагинов

/plugin marketplace add jtydhr88/comfyui-custom-node-skills
/plugin install comfyui-custom-nodes@comfyui-custom-node-skills

Команда ставит плагин comfyui-custom-nodes целиком, со всеми его скиллами

2Через Skills CLI (Vercel)

npx skills add jtydhr88/comfyui-custom-node-skills --skill comfyui-node-lifecycle -a claude-code

3Вручную: положить файлы

~/.claude/skills/comfyui-node-lifecycle/SKILL.md

Папка скилла целиком; для одного проекта — .claude/skills/comfyui-node-lifecycle/

По шагам, с командами для каждой платформы: Как установить скилл в Claude Code: пять способов

Вопросы о comfyui-node-lifecycle

Как установить comfyui-node-lifecycle в Claude Code?

Установите маркетплейс командой /plugin marketplace add jtydhr88/comfyui-custom-node-skills, затем выполните /plugin install comfyui-custom-nodes@comfyui-custom-node-skills.

Что делает comfyui-node-lifecycle?

Объясняет порядок выполнения узлов ComfyUI, проверку входов и управление кэшированием. Скилл помогает разбирать поведение графа и писать пользовательские узлы.

Отключает ли not_idempotent повторное использование кэша?

Нет. Флаг запрещает делиться кэшем между одинаковыми экземплярами узла, но сам узел может использовать собственный сохранённый вывод. Для принудительного повторного выполнения нужен меняющийся результат fingerprint_inputs или IS_CHANGED.

Исходный текст

SKILL.md · MIT
---
name: comfyui-node-lifecycle
description: ComfyUI node execution lifecycle - caching, fingerprint_inputs/IS_CHANGED, validate_inputs/VALIDATE_INPUTS, check_lazy_status, execution order. Use when debugging execution, implementing caching control, input validation, or understanding execution flow.
---

# ComfyUI Node Execution Lifecycle

Understanding the execution lifecycle helps build efficient, correct nodes.

## Execution Flow Overview

```
1. Prompt received from frontend
2. Validation phase
   ├── Look up each node class
   ├── Call INPUT_TYPES() / define_schema() for input specs
   ├── Validate connections and types
   ├── Call validate_inputs() for each node
   └── Validate loop boundaries (StartLoop/EndLoop pairing, v0.36+)
3. Build execution order (topological sort from output nodes)
4. For each node in order:
   ├── Cache check (fingerprint_inputs)
   ├── Input resolution (get upstream values)
   ├── Lazy evaluation (check_lazy_status)
   ├── Execute function
   └── Store outputs in cache
5. Return results to frontend
```

## Execution Order

ComfyUI executes from **output nodes backward**:
1. Identifies output nodes (`is_output_node=True`)
2. Builds dependency graph
3. Topological sort determines execution order
4. Only nodes connected to output nodes execute

## Cache Control: fingerprint_inputs (V3) / IS_CHANGED (V1)

Controls when a node re-executes vs uses cached results.

```python
class RandomNode(io.ComfyNode):
    @classmethod
    def define_schema(cls):
        return io.Schema(
            node_id="RandomNode",
            display_name="Random Value",
            category="utils",
            inputs=[
                io.Float.Input("min_val", default=0.0),
                io.Float.Input("max_val", default=1.0),
            ],
            outputs=[io.Float.Output("FLOAT")],
        )

    @classmethod
    def fingerprint_inputs(cls, min_val, max_val):
        """Return value compared to last run. Different value = re-execute."""
        # Return unique value each time to always re-execute
        import time
        return time.time()

    @classmethod
    def execute(cls, min_val, max_val):
        import random
        return io.NodeOutput(random.uniform(min_val, max_val))
```

**How caching works**:
- Before execution, `fingerprint_inputs()` is called with the same args as `execute()`
- Return value is compared to the previous run's return value
- If **same** → skip execution, use cached output
- If **different** → re-execute the node
- If `fingerprint_inputs` is not defined → cache based on input values

**V1 equivalent** (`IS_CHANGED`):
```python
@classmethod
def IS_CHANGED(s, min_val, max_val):
    return time.time()  # always re-execute
```

### not_idempotent Flag

For nodes that should never be cached:

```python
io.Schema(
    node_id="AlwaysRunNode",
    not_idempotent=True,  # prevents cache sharing between instances of the same node
    # ...
)
```

> **Important:** `not_idempotent=True` does **not** prevent a node from reusing its own cached output on subsequent runs. It only prevents cache sharing between different instances of the same node type that have identical inputs. To force re-execution every run (e.g., for file-writing nodes), you must also implement `fingerprint_inputs` (V3) or `IS_CHANGED` (V1) returning a unique value each time.

### has_intermediate_output Flag

For nodes with interactive UI that produce intermediate outputs (e.g., Image Crop, Painter). These behave like output nodes (UI results are cached and resent to the frontend on page refresh) but do NOT automatically get added to the execution list — they only execute if on the dependency path of a real output node.

```python
io.Schema(
    node_id="InteractiveCropNode",
    has_intermediate_output=True,
    # ...
)
```

### External Cache Providers

Share cached node outputs across ComfyUI instances (e.g. a shared network cache) by registering a `CacheProvider`:

```python
from comfy_api.latest import Caching

class MyCacheProvider(Caching.CacheProvider):
    async def on_lookup(self, context):   # context: node_id, class_type, cache_key_hash
        ...  # return Caching.CacheValue(outputs=[...], ui={...}) or None on miss

    async def on_store(self, context, value):
        ...  # store to external storage (dispatched as a background task)

    def should_cache(self, context, value=None) -> bool:
        return True  # return False to skip external caching for a node

    def on_prompt_start(self, prompt_id): ...
    def on_prompt_end(self, prompt_id): ...

# Register in ComfyExtension.on_load():
api = ComfyAPI()
await api.caching.register_provider(MyCacheProvider())
```

Providers are consulted on local cache miss, in registration order. Exceptions from providers never break execution.

On a cache hit the cached UI is resent (with `id`/`preview_id` stripped from UI entries — see `comfyui-node-outputs`). For RAM-cache sizing of custom output objects see `_comfy_cache_tensors` in `comfyui-node-datatypes`.

## Input Validation: validate_inputs (V3) / VALIDATE_INPUTS (V1)

Validates inputs before execution. Runs during the validation phase.

```python
class ValidatedNode(io.ComfyNode):
    @classmethod
    def define_schema(cls):
        return io.Schema(
            node_id="ValidatedNode",
            display_name="Validated Node",
            category="utils",
            inputs=[
                io.Int.Input("width", default=512, min=1, max=8192),
                io.Int.Input("height", default=512, min=1, max=8192),
            ],
            outputs=[io.Image.Output("IMAGE")],
        )

    @classmethod
    def validate_inputs(cls, width, height):
        """Return True if valid, or error string if invalid."""
        if width % 8 != 0 or height % 8 != 0:
            return "Width and height must be multiples of 8"
        if width * height > 4096 * 4096:
            return "Total pixels exceed maximum (4096x4096)"
        return True

    @classmethod
    def execute(cls, width, height):
        import torch
        return io.NodeOutput(torch.zeros(1, height, width, 3))
```

**V1 equivalent**:
```python
@classmethod
def VALIDATE_INPUTS(s, width, height):
    if width % 8 != 0:
        return "Width must be a multiple of 8"
    return True
```

### Dynamic Inputs in validate_inputs (v0.40+)

Name the **root** id of an Autogrow / DynamicCombo input to receive its rebuilt nested value; dynamic roots you don't name are not passed. `**kwargs` receives everything, nested.

```python
@classmethod
def validate_inputs(cls, rows):          # rows = {"item0": 0.5, ...} (Autogrow)
    return True if rows else "Connect at least one row"
```

- Returning `False`/a string is reported even when no inputs were passed.
- Malformed dynamic keys fail validation with error type `invalid_dynamic_input`.

### Skipping Type Validation

To accept any type (wildcard inputs), include `input_types` parameter:

```python
@classmethod
def validate_inputs(cls, input_types: dict = None, **kwargs):
    # input_types contains the actual types of connected inputs
    # Returning True skips the default type checking
    return True
```

## Lazy Evaluation: check_lazy_status

Controls which lazy inputs actually need evaluation. See `comfyui-node-inputs` for full details.

```python
@classmethod
def check_lazy_status(cls, condition, value_a=None, value_b=None):
    """Called before execute. Return names of inputs that need evaluation."""
    if condition and value_a is None:
        return ["value_a"]
    if not condition and value_b is None:
        return ["value_b"]
    return []
```

**Key behaviors**:
- Only called if the node has lazy inputs
- May be called **multiple times** as inputs become available
- Unevaluated lazy inputs are `None`
- Return empty list (or `None`) when ready to execute
- Evaluated inputs retain their value across calls

## Output Nodes

Nodes with `is_output_node=True` are execution roots — ComfyUI traces backward from these:

```python
class SaveMyData(io.ComfyNode):
    @classmethod
    def define_schema(cls):
        return io.Schema(
            node_id="SaveMyData",
            display_name="Save Data",
            category="output",
            is_output_node=True,  # marks as output node
            inputs=[
                io.String.Input("data"),
                io.String.Input("filename", default="output.txt"),
            ],
            outputs=[],  # output nodes may have no outputs
            hidden=[io.Hidden.prompt, io.Hidden.extra_pnginfo],
        )

    @classmethod
    def execute(cls, data, filename):
        import folder_paths, os
        output_dir = folder_paths.get_output_directory()
        with open(os.path.join(output_dir, filename), 'w') as f:
            f.write(data)
        return io.NodeOutput()
```

## List Processing

### Receiving Lists

```python
# V3: is_input_list=True in Schema (same as V1 INPUT_IS_LIST)
# All inputs arrive as lists — including widget values like batch_size
# Widget values: use widget_value[0] to get the scalar
# Shorter lists are padded by repeating the last value

# V1: INPUT_IS_LIST = True to receive full lists
class ListNode:
    INPUT_IS_LIST = True
    # Now execute() receives lists instead of individual items
```

### Outputting Lists

```python
# V3
io.Image.Output("IMAGE", is_output_list=True)

# V1
OUTPUT_IS_LIST = (True,)  # tuple matching RETURN_TYPES
```

## Error Handling

```python
@classmethod
def execute(cls, image, model):
    try:
        result = model.process(image)
    except RuntimeError as e:
        if "out of memory" in str(e):
            import torch
            torch.cuda.empty_cache()
            # Try with smaller batch
            result = process_in_chunks(image, model)
        else:
            raise
    return io.NodeOutput(result)
```

## Server Communication

Send messages to the frontend during execution:

```python
from server import PromptServer

@classmethod
def execute(cls, data):
    PromptServer.instance.send_sync(
        "my_extension.status",
        {"message": "Processing complete", "progress": 100}
    )
    # Status text shown on the node (binary TEXT event; sid=None broadcasts)
    PromptServer.instance.send_progress_text("Step 3 / 10", cls.hidden.unique_id)
    return io.NodeOutput(data)
```

- Dict payloads that contain `"prompt_id"` get the prompt's `workflow_metadata` (e.g. `workflow_id`) merged in (v0.40+) — include `prompt_id` so clients can route the message to its workflow.

## Logging

Use `logging`. For verbose diagnostics below INFO use the DETAIL level (v0.30+): `from comfy.internal_logging import detail; detail("msg %s", x)`, shown with `--verbose DETAIL` or written with `--verbose DETAIL path.log`. (The module is `comfy.internal_logging`, not `comfy.logging`.)

## Complete Lifecycle Example

```python
import time
import torch
from comfy_api.latest import ComfyExtension, io, ComfyAPISync

class FullLifecycleNode(io.ComfyNode):
    @classmethod
    def define_schema(cls):
        return io.Schema(
            node_id="FullLifecycleNode",
            display_name="Full Lifecycle Demo",
            category="example",
            inputs=[
                io.Image.Input("image"),
                io.Float.Input("threshold", default=0.5, min=0.0, max=1.0),
                io.Image.Input("optional_ref", optional=True, lazy=True),
            ],
            outputs=[
                io.Image.Output("IMAGE"),
                io.Mask.Output("MASK"),
            ],
            hidden=[io.Hidden.unique_id],
        )

    @classmethod
    def validate_inputs(cls, image, threshold, optional_ref=None):
        if threshold == 0.0:
            return "Threshold cannot be exactly 0"
        return True

    @classmethod
    def fingerprint_inputs(cls, image, threshold, optional_ref=None):
        # Re-execute if threshold changed; cache otherwise
        return threshold

    @classmethod
    def check_lazy_status(cls, image, threshold, optional_ref=None):
        # Only request optional_ref if threshold is high
        if threshold > 0.8 and optional_ref is None:
            return ["optional_ref"]
        return []

    @classmethod
    def execute(cls, image, threshold, optional_ref=None):
        node_id = cls.hidden.unique_id

        api = ComfyAPISync()  # use ComfyAPISync in sync execute; ComfyAPI in async
        api.execution.set_progress(0, 2)

        # Generate mask from threshold
        gray = image[:, :, :, 0] * 0.299 + image[:, :, :, 1] * 0.587 + image[:, :, :, 2] * 0.114
        mask = (gray > threshold).float()

        api.execution.set_progress(1, 2)

        # Apply mask
        result = image * mask.unsqueeze(-1)
        if optional_ref is not None:
            result = result + optional_ref * (1 - mask.unsqueeze(-1))

        api.execution.set_progress(2, 2)
        return io.NodeOutput(result, mask)
```

## See Also

- `comfyui-node-basics` - Node structure fundamentals
- `comfyui-node-inputs` - Input types and lazy evaluation
- `comfyui-node-advanced` - Expansion, MatchType, DynamicCombo
- `comfyui-node-outputs` - UI outputs and previews

© Terry Jia · MIT · jtydhr88/comfyui-custom-node-skills

Похожие скиллы

Все скиллы по теме «ИИ и ML» →
cli-anything-comfyui HKUDS Скилл cli-anything-comfyui даёт агенту консольный доступ к ComfyUI: ставить workflow в очередь, искать модели и скачивать готовые картинки без графического интерфейса. CX Codex +1 615установок comfyui NousResearch Подключает ComfyUI через REST/WebSocket API и comfy-cli. Запускает диффузионные пайплайны — от txt2img на Flux и SDXL до видео через AnimateDiff и Wan. CX Codex +1 405установок comfyui-lowvram-setup 0xheycat Скилл comfyui-lowvram-setup для Claude Code задаёт низкопамятную конфигурацию ComfyUI для генерации изометрических ассетов SDXL. Настраивает RTX 3060 с 12 ГБ видеопамяти и подготовку набора тайлов. CX Codex +1 ★ 51звёзд репо comfyui-mcp artokun MCP-сервер, который даёт агенту доступ к вашему ComfyUI: генерация картинок, видео и звука, правка графа и работа с моделями. CX Codex +1 ★ 946звёзд репо comfyui-mcp-server MetaBrain-Labs Подключает ComfyUI и превращает workflow в вызываемые инструменты. Запускает генерацию изображений и видео через MCP. CX Codex +1 ★ 10звёзд репо ComfyUI Builder MIt9 ComfyUI Builder — MCP-сервер для Claude Code, который собирает и запускает графы ComfyUI по запросу. Он передаёт статус генерации через WebSocket без ручной правки JSON. CX Codex +1 ★ 5звёзд репо

Из того же набора10

Весь набор →
comfyui-node-basics Скилл comfyui-node-basics помогает описать структуру пользовательского узла ComfyUI на V3 API, задать его схему и подключить регистрацию. Пригодится при создании узла с нуля или настройке проекта. CX Codex +1 ★ 321звёзд репо comfyui-node-packaging Скилл comfyui-node-packaging для упаковки и публикации кастомных нод ComfyUI: структура проекта, регистрация в __init__.py, requirements.txt, WEB_DIRECTORY. CX Codex +1 ★ 321звёзд репо comfyui-node-outputs Скилл comfyui-node-outputs для Claude Code описывает возврат данных из нод ComfyUI V3: io.NodeOutput, превью изображений, масок, аудио, видео и 3D-моделей. CX Codex +1 ★ 321звёзд репо comfyui-node-migration Скилл comfyui-node-migration переводит старые кастомные ноды ComfyUI с API V1 на V3: чек-лист по шагам, таблицы соответствия свойств и типов входов, пример до и после. CX Codex +1 ★ 321звёзд репо comfyui-node-inputs Скилл comfyui-node-inputs помогает настраивать типы входов и виджеты кастомных узлов ComfyUI. Пригодится при создании числовых полей, выпадающих списков, кривых и видеоредакторов. CX Codex +1 ★ 321звёзд репо comfyui-node-advanced Скилл comfyui-node-advanced для Claude Code помогает проектировать сложные узлы ComfyUI с динамическими входами и сопоставлением типов. Решает задачу узлов, которым недостаточно фиксированной схемы входов. CX Codex +1 ★ 321звёзд репо comfyui-node-datatypes Скилл comfyui-node-datatypes для Claude Code описывает типы входов и выходов нод ComfyUI. Включается при работе с форматами тензоров, моделей, аудио, видео, 3D и виджетов. CX Codex +1 ★ 321звёзд репо comfyui-node-frontend Скилл comfyui-node-frontend помогает создавать JavaScript-расширения для кастомных нод ComfyUI: настраивать хуки жизненного цикла, добавлять DOM-виджеты и менять поведение интерфейса. CX Codex +1 ★ 321звёзд репо

Спонсоры проекта

Компании, которые помогают держать аналитику открытой