Comfyui media workflows

From calesthio/generative-media-skills · View interactive version

Comfyui media workflows is an AI agent skill from the GitHub repository calesthio/generative-media-skills. Provider-independent production workflow for agents assembling, auditing, executing, and handing off ComfyUI node-graph workflows for image, video, upscale, inpaint, conditioning, and batch media generation; use when a task involves ComfyUI workflow JSON/API graphs, model and custom-node inventories

How to use this skill

Skill file

ComfyUI media workflow production

Use this skill to turn a creative or technical brief into a production-ready ComfyUI workflow package. Treat ComfyUI as a graph-based media production runtime, not as a prompt box. Your output should make the graph reproducible, reviewable, safe to run, and easy for another operator or system to execute.

This is provider-independent. Do not assume a specific checkpoint, hosted Comfy service, custom node set, or cloud vendor unless the user or the existing project explicitly names one. Re-check ComfyUI, custom-node, model, license, and cloud API facts at production time because they change frequently.

Operating principles

Required first pass

Produce a short production brief before building or modifying a graph:

  1. Deliverable: media type, count, dimensions/aspect ratio, duration/fps if video, file formats, naming, platform or downstream editor.
  2. Creative intent: subject, style, constraints, references, negative constraints, must-preserve elements, brand rules.
  3. Inputs: text prompts, images, masks, video, audio, depth/pose/control maps, brand assets, identity/likeness permissions, source ownership.
  4. Runtime: local ComfyUI, Comfy Cloud, another hosted Comfy-compatible service, or handoff-only; available GPU/VRAM, concurrency, storage, network and privacy constraints.
  5. Model inventory: intended checkpoint/diffusion model, VAE, text encoders, LoRAs, ControlNets, adapters, upscalers, video models, audio/3D models if any.
  6. Custom-node inventory: every non-core node package, install source, version/commit, license, dependency impact, trust level, and replacement plan.
  7. Rights and safety: commercial status, client/counsel approval needs, likeness/voice consent, minors, regulated domains, impersonation/deception, prohibited content, platform restrictions.
  8. Reproducibility target: exact rerun, near-match, or exploratory batch. Exact rerun requires stricter seeds, versions, hashes, and deterministic caveats.
  9. Handoff target: another artist, an API service, a cloud deployment, a batch render queue, or an archive.

If any of these are missing, make a bounded assumption only when it does not change the workflow design materially. Otherwise ask.

Workflow formats and API boundaries

ComfyUI workflows are JSON graphs. The frontend save format and API format are not equivalent:

When you need a static preflight of an API-format workflow, use the bundled Python 3.11+ stdlib helper before runtime validation:

python scripts/inspect_workflow.py workflow_api.json --approved-classes approved_classes.txt --unknown-class warning --pretty

The helper inspects only local JSON. It validates the API-format shape, node IDs, class_type, inputs, optional _meta, link inputs shaped as [node_id, output_index], dangling links, nonnegative integer output indexes, graph cycles, and warnings for secret-like keys/values or absolute/private-looking path strings. It emits a stable normalized JSON inventory with node, edge, class, and finding counts. Exit codes are 0 for no validation errors, 2 for validation errors, and 3 for parse or operational failures. If you provide a newline-delimited approved class list, class types absent from that list can be reported as warnings, errors, or ignored with --unknown-class.

This helper is not a substitute for ComfyUI runtime validation. It never executes the graph, submits to /prompt, installs missing custom nodes, loads models, verifies input names against /object_info, or proves that a workflow will fit VRAM or run on a target server.

For local ComfyUI server execution, the core pattern is:

  1. Upload needed inputs through the runtime's upload route or place them in the expected input directory.
  2. Submit the API-format graph to the prompt queue.
  3. Monitor status through WebSocket messages or polling.
  4. Retrieve outputs from the run history or view/download route.
  5. Archive run metadata and outputs outside transient runtime directories.

For cloud execution, do not assume local-route semantics. Confirm authentication, endpoint prefixes, concurrency limits, storage behavior, signed URL behavior, timeouts, and partner-node key handling in the current cloud documentation.

The production workflow card

For every non-trivial workflow, maintain a workflow card in the project notes or handoff message. It should be concise but complete:

workflow_name: product-hero-sdxl-controlnet-v003
purpose: "Generate 6 square product hero image candidates with locked silhouette and color palette."
formats:
  save_graph: workflow.json
  api_graph: workflow_api.json
runtime_verified:
  comfyui_version: "record exact version/commit"
  execution_target: "local RTX 4090 / Comfy Cloud / other"
  verified_at: "YYYY-MM-DD"
models:
  - role: checkpoint
    id: "repository-or-file-name"
    file: "model.safetensors"
    sha256: "..."
    source_url: "..."
    license: "..."
    license_verified_at: "YYYY-MM-DD"
    approval: "approved / needs counsel / noncommercial only / unknown"
custom_nodes:
  - package: "repo-or-registry-id"
    version_or_commit: "..."
    source_url: "..."
    license: "..."
    risk: "low / medium / high"
    reason: "why needed"
exposed_inputs:
  positive_prompt_node: "6.inputs.text"
  negative_prompt_node: "7.inputs.text"
  seed_node: "3.inputs.seed"
  width_height_node: "5.inputs.width|height"
seed_policy: "fixed seeds for rerun; randomized only in variants manifest"
input_custody:
  source_assets: "paths, hashes, consent notes"
output_custody:
  destination: "..."
  metadata_policy: "embed workflow / strip workflow / add C2PA externally"
qa_status: "not run / smoke passed / approved / blocked"
known_limits:
  - "..."

Do not invent hashes, versions, license status, or approvals. Mark unknowns plainly.

Model and license inventory

Inventory every model-like artifact, not only the main checkpoint:

For each, record:

Use model-card metadata as a starting point, not as the full clearance. Hugging Face supports license metadata and model cards, but missing or ambiguous metadata is common enough that you must inspect the linked license or repository files for consequential work. If the model is a derivative or merge, verify upstream license compatibility when the project is commercial, public, client-facing, or redistributed.

Escalate to the client, rights owner, platform owner, or counsel when:

Do not provide legal advice. State the risk and the decision needed.

Custom-node risk handling

Custom nodes are extensions that execute code inside the ComfyUI environment. Treat them as supply-chain dependencies.

Risk-rank each custom node:

Required handling:

If a required custom node is high-risk and no safe replacement exists, stop and ask for approval with options: accept risk in a sandbox, replace the creative approach, use a hosted provider, or pause.

Graph design patterns

Use these as production patterns, not rigid templates. Node names vary by ComfyUI version, model family, and custom-node package.

Text-to-image stills

Common structure:

  1. Load checkpoint or model family-specific model and required text encoders/VAE.
  2. Encode positive and negative prompts.
  3. Create latent at target dimensions or model-native dimensions.
  4. Sample with a documented sampler/scheduler/steps/CFG/seed.
  5. Decode.
  6. Optional: upscale, color pass, face/detail pass, metadata/provenance pass.
  7. Save with deterministic filename prefix.

Production notes:

Image-to-image and stylization

Common structure:

  1. Load source image.
  2. Preprocess if needed: resize/crop/pad, color normalize, segment, depth, edges, pose, or reference embedding.
  3. Encode image to latent or feed it to the relevant conditioning node.
  4. Sample with denoise strength chosen for the preservation target.
  5. Composite or restore details.
  6. Save output and comparison contact sheet.

Heuristic denoise ranges:

Document the actual denoise value and expected preservation level. For client assets, preserve composition with explicit control inputs rather than hoping a prompt will retain it.

Inpaint and outpaint

Common structure:

  1. Load source image and mask.
  2. Verify mask polarity and edge softness.
  3. Crop to masked region if using a detail/inpaint crop path, or run full-frame if global consistency matters.
  4. Encode image/mask to the inpaint model or conditioning path.
  5. Sample with a preservation-appropriate denoise.
  6. Composite back into original image.
  7. QA seam quality, geometry, shadows, texture, and brand/product fidelity.

Production notes:

Control and conditioning

Conditioning turns ambiguous prompt intent into controllable structure. Use it when layout, pose, depth, product silhouette, edge fidelity, camera angle, or identity-adjacent consistency matters.

Common controls:

Production notes:

Upscale and finishing

Common structure:

  1. Generate at model-appropriate base size.
  2. Choose latent upscale or pixel upscale based on artifact type.
  3. Apply detail pass only when it improves the image rather than hallucinating new detail.
  4. Save original, upscaled, and final files with linked metadata.

Production notes:

Video and motion workflows

Video workflows multiply every risk: VRAM, time, temporal artifacts, rights, and file custody.

Common structure:

  1. Define motion spec: duration, fps, aspect ratio, camera/subject motion, source image or text prompt, loop/continuity needs.
  2. Load video model and required encoders/VAE/motion modules.
  3. Provide source image/video/control frames as needed.
  4. Generate short clips before long clips.
  5. Optional: interpolate, upscale, stabilize, restore, caption, or composite externally.
  6. Save frames and final video with run metadata.

Production notes:

Batch variants

Batching is for controlled exploration, not chaos.

Use a variants manifest:

base_workflow: workflow_api.json
locked:
  checkpoint: "..."
  dimensions: "1024x1024"
  negative_prompt: "..."
  control_image_sha256: "..."
variants:
  - id: A01
    seed: 101
    prompt_delta: "warmer backlight, softer shadows"
  - id: A02
    seed: 102
    prompt_delta: "cooler palette, sharper product edge"

Change one or two variables per batch unless the purpose is broad exploration. Name outputs with variant IDs and seed. Generate contact sheets or review grids for human selection.

Prompt, seed, and parameter control

Expose prompts as inputs, but do not leave them as the only control surface.

Prompt handling:

Seed handling:

Parameter handling:

VRAM, performance, and reliability

Do not promise a graph will run just because it is valid JSON.

Performance checklist:

Use /system_stats or the target runtime's equivalent when available; use /free or the UI equivalent to unload models only when it is safe for other running jobs.

Input and output custody

Treat every input and generated output as an asset with custody.

Inputs:

Outputs:

Provenance and metadata

ComfyUI's SaveImage node can save images to the output directory and may embed workflow metadata such as the prompt. The core workflow docs describe generated-image metadata as a way to reopen the graph, and standalone JSON as useful when the media format does not support metadata.

Production decision:

If using C2PA or similar provenance:

Local and cloud execution hygiene

Local execution:

Cloud execution:

QA before handoff

Minimum QA:

Visual QA for stills:

Visual QA for video:

Technical QA:

Handoff package

Hand off:

If redistribution is intended, include only assets and model links that can legally and practically be redistributed. Otherwise provide installation instructions and source URLs rather than bundling restricted model files.

Example: controlled product hero stills

Example intent: Generate square ecommerce hero images for a new bottle while preserving silhouette and label placement. The user provides an approved product render and brand palette. Commercial release is planned.

Approach:

Example workflow card excerpt:

workflow_name: bottle-hero-control-v001
purpose: "Generate six 1:1 product hero candidates preserving bottle geometry."
exposed_inputs:
  prompt: "CLIPTextEncode positive text"
  negative_prompt: "CLIPTextEncode negative text"
  seed: "KSampler seed"
  control_strength: "ControlNet strength"
locked:
  dimensions: "1024x1024"
  source_product_sha256: "record actual hash"
  mask_sha256: "record actual hash"
  model_license_status: "approved for commercial use by client on YYYY-MM-DD"
variant_policy:
  seeds: [50101, 50102, 50103, 50104, 50105, 50106]
  changed_fields: ["seed", "lighting phrase only"]
qa_focus:
  - "label text/logo not reconstructed incorrectly"
  - "bottle silhouette matches reference"
  - "no invented claims on packaging"
metadata_policy: "strip from delivered finals; archive workflow internally"

Why this works: the graph protects hard product constraints with control inputs and uses prompts for mood rather than asking the model to invent the product shape.

Likely failures: label distortion, extra cap seams, unrealistic reflections, control overfitting, insufficient commercial clearance for a downloaded LoRA.

Example: inpainted campaign image repair

Example intent: Remove a distracting object from an approved campaign image without changing the model's face, clothing, or background identity.

Approach:

Example agent plan:

I will build an inpaint-only workflow, not a full img2img restyle. Fixed inputs are the original campaign image and mask. The only creative prompt will describe the missing background texture. I will preserve the person, wardrobe, and lighting, and I will stop if the mask overlaps face, body, logo, or other protected areas.

Expected handoff notes:

Example: short image-to-video batch

Example intent: Create three 4-second vertical animated loops from an approved poster frame for a social teaser.

Approach:

Example manifest excerpt:

workflow_name: poster-loop-i2v-v002
delivery:
  aspect_ratio: "9:16"
  fps: 24
  frames: 96
  duration_seconds: 4
smoke_test:
  frames: 24
  resolution: "reduced"
  status: "passed/failed"
variants:
  - id: loop-a
    seed: 7201
    motion: "subtle parallax push-in, fabric barely moving, no face morph"
  - id: loop-b
    seed: 7202
    motion: "slow lateral camera drift, particles in background only"
  - id: loop-c
    seed: 7203
    motion: "gentle light sweep, subject locked"
qa_focus:
  - "identity consistency"
  - "no text/logo warping"
  - "loop seam if looped"
  - "no unauthorized transformation of protected artwork"

Likely failures: face drift, text/logo warping, high VRAM use at final frame count, model license unclear for commercial social use, temporal artifacts hidden by small previews.

Source notes and verification

Facts in this skill were grounded in these sources, verified on 2026-07-11:

Volatile facts to re-check at production time:

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.