ComfyUI Workflow Builder
Translates natural language requests into executable ComfyUI workflow JSON. Always validates against inventory before generating.
Workflow Generation Process
Step 1: Understand the Request
Parse the user's intent into:
- Output type: Image, video, or audio
- Source material: Text-only, reference image(s), existing video
- Identity method: None, zero-shot (InstantID/PuLID), LoRA, Kontext
- Quality level: Draft (fast iteration) vs production (maximum quality)
- Special requirements: ControlNet, inpainting, upscaling, lip-sync
Step 2: Check Inventory
Read state/inventory.json to determine:
- Available checkpoints → select best match for task
- Available identity models → determine which methods are possible
- Available ControlNet models → enable pose/depth control if available
- Custom nodes installed → verify all required nodes exist
- VRAM available → optimize settings accordingly
Step 3: Select Pipeline Pattern
Based on request + inventory, choose from:
| Pattern |
When |
Key Nodes |
| Text-to-Image |
Simple generation |
Checkpoint → CLIP → KSampler → VAE |
| Identity-Preserved Image |
Character consistency |
+ InstantID/PuLID/IP-Adapter |
| LoRA Character |
Trained character |
+ LoRA Loader |
| Image-to-Video (Wan) |
High-quality video |
Diffusion Model → Wan I2V → Video Combine |
| Image-to-Video (AnimateDiff) |
Fast video, motion control |
+ AnimateDiff Loader + Motion LoRAs |
| Talking Head |
Character speaks |
Image → Video → Voice → Lip-Sync |
| Upscale |
Enhance resolution |
Image → UltimateSDUpscale → Save |
| Inpainting |
Edit regions |
Image + Mask → Inpaint Model → KSampler |
Step 4: Generate Workflow JSON
ComfyUI workflow format:
{
"{node_id}": {
"class_type": "{NodeClassName}",
"inputs": {
"{param_name}": "{value}",
"{connected_param}": ["{source_node_id}", {output_index}]
}
}
}
Rules:
- Node IDs are strings (typically "1", "2", "3"...)
- Connected inputs use array format:
["source_node_id", output_index]
- Output index is 0-based integer
- Filenames must match exactly what's in inventory
- Seed values: use random large integer or fixed for reproducibility
Step 5: Validate
Before presenting to user:
- Every
class_type exists in inventory's node list
- Every model filename exists in inventory's model list
- All required connections are present (no dangling inputs)
- VRAM estimate doesn't exceed available VRAM
- Resolution is compatible with chosen model (512 for SD1.5, 1024 for SDXL/FLUX)
Step 6: Output
If online mode: Queue via comfyui-api skill
If offline mode: Save JSON to projects/{project}/workflows/ with descriptive name
Workflow Templates
Basic Text-to-Image (FLUX)
{
"1": {
"class_type": "LoadCheckpoint",
"inputs": {"ckpt_name": "flux1-dev.safetensors"}
},
"2": {
"class_type": "CLIPTextEncode",
"inputs": {"text": "{positive_prompt}", "clip": ["1", 1]}
},
"3": {
"class_type": "CLIPTextEncode",
"inputs": {"text": "{negative_prompt}", "clip": ["1", 1]}
},
"4": {
"class_type": "EmptyLatentImage",
"inputs": {"width": 1024, "height": 1024, "batch_size": 1}
},
"5": {
"class_type": "KSampler",
"inputs": {
"seed": 42,
"steps": 25,
"cfg": 3.5,
"sampler_name": "euler",
"scheduler": "normal",
"denoise": 1.0,
"model": ["1", 0],
"positive": ["2", 0],
"negative": ["3", 0],
"latent_image": ["4", 0]
}
},
"6": {
"class_type": "VAEDecode",
"inputs": {"samples": ["5", 0], "vae": ["1", 2]}
},
"7": {
"class_type": "SaveImage",
"inputs": {"filename_prefix": "output", "images": ["6", 0]}
}
}
With Identity Preservation (InstantID + IP-Adapter)
Extends basic template by adding:
- Load reference image node
- InstantID Model Loader + Apply InstantID
- IPAdapter Unified Loader + Apply IPAdapter
- FaceDetailer post-processing
See references/workflows.md for complete node settings.
Video Generation (Wan I2V)
Uses different loader chain:
- Load Diffusion Model (not LoadCheckpoint)
- Wan I2V Conditioning
- EmptySD3LatentImage (with frame count)
- Video Combine (VHS)
See references/workflows.md Workflow 4 for complete settings.
VRAM Estimation
| Component |
Approximate VRAM |
| FLUX FP16 |
16GB |
| FLUX FP8 |
8GB |
| SDXL |
6GB |
| SD1.5 |
4GB |
| InstantID |
+4GB |
| IP-Adapter |
+2GB |
| ControlNet (each) |
+1.5GB |
| Wan 14B |
20GB |
| Wan 1.3B |
5GB |
| AnimateDiff |
+3GB |
| FaceDetailer |
+2GB |
Common Mistakes to Avoid
- Wrong output index: CheckpointLoader outputs
[model, clip, vae] at indices [0, 1, 2]
- CFG too high for InstantID: Use 4-5, not default 7-8
- Wrong resolution for model: FLUX/SDXL=1024, SD1.5=512
- Missing VAE: FLUX needs explicit VAE (
ae.safetensors)
- Wrong model in wrong loader: Diffusion models need
LoadDiffusionModel, not LoadCheckpoint
Reference Files
references/workflows.md - Detailed node-by-node templates
references/models.md - Model files and paths
references/prompt-templates.md - Model-specific prompts
state/inventory.json - Current inventory cache
1---2name: comfyui-workflow-builder3description: Generate, build, create, or design ComfyUI workflow JSON from natural language descriptions. Produces valid node graphs with correct class_types, connections, output indices, and model-appropriate settings. Handles txt2img, img2img, inpainting, ControlNet, LoRA stacking, upscaling, and face detailing pipelines. Does NOT cover ComfyUI installation, custom node development, Python scripting, model training, hardware advice, or architectural explanations.4---5
6# ComfyUI Workflow Builder
7
8Translates natural language requests into executable ComfyUI workflow JSON. Always validates against inventory before generating.
9
10## Workflow Generation Process
11
12### Step 1: Understand the Request
13
14Parse the user's intent into:
15- **Output type**: Image, video, or audio
16- **Source material**: Text-only, reference image(s), existing video
17- **Identity method**: None, zero-shot (InstantID/PuLID), LoRA, Kontext
18- **Quality level**: Draft (fast iteration) vs production (maximum quality)
19- **Special requirements**: ControlNet, inpainting, upscaling, lip-sync
20
21### Step 2: Check Inventory
22
23Read `state/inventory.json` to determine:
24- Available checkpoints → select best match for task
25- Available identity models → determine which methods are possible
26- Available ControlNet models → enable pose/depth control if available
27- Custom nodes installed → verify all required nodes exist
28- VRAM available → optimize settings accordingly
29
30### Step 3: Select Pipeline Pattern
31
32Based on request + inventory, choose from:
33
34| Pattern | When | Key Nodes |
35|---------|------|-----------|
36| Text-to-Image | Simple generation | Checkpoint → CLIP → KSampler → VAE |
37| Identity-Preserved Image | Character consistency | + InstantID/PuLID/IP-Adapter |
38| LoRA Character | Trained character | + LoRA Loader |
39| Image-to-Video (Wan) | High-quality video | Diffusion Model → Wan I2V → Video Combine |
40| Image-to-Video (AnimateDiff) | Fast video, motion control | + AnimateDiff Loader + Motion LoRAs |
41| Talking Head | Character speaks | Image → Video → Voice → Lip-Sync |
42| Upscale | Enhance resolution | Image → UltimateSDUpscale → Save |
43| Inpainting | Edit regions | Image + Mask → Inpaint Model → KSampler |
44
45### Step 4: Generate Workflow JSON
46
47**ComfyUI workflow format:**
48
49```json
50{
51 "{node_id}": {
52 "class_type": "{NodeClassName}",
53 "inputs": {
54 "{param_name}": "{value}",
55 "{connected_param}": ["{source_node_id}", {output_index}]
56 }
57 }
58}
59```
60
61**Rules:**
62- Node IDs are strings (typically "1", "2", "3"...)
63- Connected inputs use array format: `["source_node_id", output_index]`
64- Output index is 0-based integer
65- Filenames must match exactly what's in inventory
66- Seed values: use random large integer or fixed for reproducibility
67
68### Step 5: Validate
69
70Before presenting to user:
71
721. Every `class_type` exists in inventory's node list
732. Every model filename exists in inventory's model list
743. All required connections are present (no dangling inputs)
754. VRAM estimate doesn't exceed available VRAM
765. Resolution is compatible with chosen model (512 for SD1.5, 1024 for SDXL/FLUX)
77
78### Step 6: Output
79
80**If online mode**: Queue via `comfyui-api` skill
81**If offline mode**: Save JSON to `projects/{project}/workflows/` with descriptive name
82
83## Workflow Templates
84
85### Basic Text-to-Image (FLUX)
86
87```json
88{
89 "1": {
90 "class_type": "LoadCheckpoint",
91 "inputs": {"ckpt_name": "flux1-dev.safetensors"}
92 },
93 "2": {
94 "class_type": "CLIPTextEncode",
95 "inputs": {"text": "{positive_prompt}", "clip": ["1", 1]}
96 },
97 "3": {
98 "class_type": "CLIPTextEncode",
99 "inputs": {"text": "{negative_prompt}", "clip": ["1", 1]}
100 },
101 "4": {
102 "class_type": "EmptyLatentImage",
103 "inputs": {"width": 1024, "height": 1024, "batch_size": 1}
104 },
105 "5": {
106 "class_type": "KSampler",
107 "inputs": {
108 "seed": 42,
109 "steps": 25,
110 "cfg": 3.5,
111 "sampler_name": "euler",
112 "scheduler": "normal",
113 "denoise": 1.0,
114 "model": ["1", 0],
115 "positive": ["2", 0],
116 "negative": ["3", 0],
117 "latent_image": ["4", 0]
118 }
119 },
120 "6": {
121 "class_type": "VAEDecode",
122 "inputs": {"samples": ["5", 0], "vae": ["1", 2]}
123 },
124 "7": {
125 "class_type": "SaveImage",
126 "inputs": {"filename_prefix": "output", "images": ["6", 0]}
127 }
128}
129```
130
131### With Identity Preservation (InstantID + IP-Adapter)
132
133Extends basic template by adding:
134- Load reference image node
135- InstantID Model Loader + Apply InstantID
136- IPAdapter Unified Loader + Apply IPAdapter
137- FaceDetailer post-processing
138
139See `references/workflows.md` for complete node settings.
140
141### Video Generation (Wan I2V)
142
143Uses different loader chain:
144- Load Diffusion Model (not LoadCheckpoint)
145- Wan I2V Conditioning
146- EmptySD3LatentImage (with frame count)
147- Video Combine (VHS)
148
149See `references/workflows.md` Workflow 4 for complete settings.
150
151## VRAM Estimation
152
153| Component | Approximate VRAM |
154|-----------|-----------------|
155| FLUX FP16 | 16GB |
156| FLUX FP8 | 8GB |
157| SDXL | 6GB |
158| SD1.5 | 4GB |
159| InstantID | +4GB |
160| IP-Adapter | +2GB |
161| ControlNet (each) | +1.5GB |
162| Wan 14B | 20GB |
163| Wan 1.3B | 5GB |
164| AnimateDiff | +3GB |
165| FaceDetailer | +2GB |
166
167## Common Mistakes to Avoid
168
1691. **Wrong output index**: CheckpointLoader outputs `[model, clip, vae]` at indices `[0, 1, 2]`
1702. **CFG too high for InstantID**: Use 4-5, not default 7-8
1713. **Wrong resolution for model**: FLUX/SDXL=1024, SD1.5=512
1724. **Missing VAE**: FLUX needs explicit VAE (`ae.safetensors`)
1735. **Wrong model in wrong loader**: Diffusion models need `LoadDiffusionModel`, not `LoadCheckpoint`
174
175## Reference Files
176
177- `references/workflows.md` - Detailed node-by-node templates
178- `references/models.md` - Model files and paths
179- `references/prompt-templates.md` - Model-specific prompts
180- `state/inventory.json` - Current inventory cache