artokun/comfyui-mcp/prompt-engineering
Claude Code and agent skill by artokun/comfyui-mcp
- community
Checking that the SKILL.md file is still in the repository.
ComfyUI prompt engineering knowledge covering CLIP text encoding syntax, weight modifiers, model-specific prompting strategies, and best practices
Install
npx vskill@latest install artokun/comfyui-mcp/prompt-engineeringSKILL.md
The same SKILL.md was published earlier as artokun/comfyui-mcp/prompt-engineering.
ComfyUI Prompt Engineering
CLIP Text Encoding Fundamentals
ComfyUI uses CLIP (Contrastive Language-Image Pre-training) text encoders to convert text prompts into conditioning tensors. The CLIPTextEncode node takes a text string and a CLIP model, producing a CONDITIONING output for the KSampler.
Token Limit
CLIP processes text in 77-token chunks. Each word is typically 1-3 tokens. Prompts exceeding 77 tokens are silently truncated unless you use the BREAK token or a multi-clip encoding node.
Weight Syntax
Emphasis (Attention Weights)
Adjust how strongly the model attends to specific words or phrases:
| Syntax | Effect | Equivalent Weight | |
|---|---|---|---|
(word:1.3) | Increase emphasis by 30% | Explicit weight 1.3 | |
(word:0.7) | Decrease emphasis by 30% | Explicit weight 0.7 | |
(word) | Slight increase | (word:1.1) | |
((word)) | Moderate increase | (word:1.21) — 1.1^2 | |
(((word))) | Strong increase | (word:1.331) — 1.1^3 | |
[word] | Slight decrease | (word:0.9091) — 1/1.1 | |
[[word]] | Moderate decrease | (word:0.8264) — 1/1.1^2 |
Weight Rules
- Valid range: 0.0 to 2.0 (going beyond 1.5 often causes artifacts)
- Default weight: 1.0 for unmodified tokens
- Nesting stacks multiplicatively:
((word))= 1.1 * 1.1 =(word:1.21) - Phrases:
(red sports car:1.3)applies weight to the entire phrase - Mixing:
(detailed face:1.4), (blurry background:0.6), combined in one prompt
Examples
BREAK Token
The BREAK keyword forces CLIP to end the current 77-token chunk and start processing subsequent text in a new chunk. This is critical for long prompts.
When to Use BREAK
- Prompt exceeds ~60 words (approaching the 77-token limit)
- You want to separate conceptually distinct parts of the prompt
- Certain details are being ignored (they may be past the 77-token cutoff)
BREAK Example
Each chunk is encoded independently and then concatenated as conditioning, so all tokens are processed.
Embeddings / Textual Inversions
Embeddings (textual inversions) are pre-trained token sets that encode complex concepts into a single trigger word.
Syntax
Usage in Prompts
- Place embedding triggers directly in the prompt text
- Most commonly used in negative prompts to improve quality
- The embedding
.safetensorsor.ptfile must be inmodels/embeddings/
Common Negative Embeddings
| Embedding | Best For | Description | |
|---|---|---|---|
easynegative | SD 1.5 | General quality improvement | |
badhandv4 | SD 1.5 | Fixes hand deformities | |
bad-image-v2-39000 | SD 1.5 | Reduces artifacts | |
negativeXL_D | SDXL | SDXL-specific negative embedding | |
ac_neg1 | SDXL | Alternative SDXL negative |
Example with Embeddings
Positive: a portrait of a woman, masterpiece, best quality Negative: embedding:easynegative, embedding:badhandv4, worst quality, low quality
Model-Specific Prompting
SD 1.5
Negative prompt: IMPORTANT. SD 1.5 is sensitive to negatives.
Positive prompt structure:
Recommended negative prompt:
Key notes:
- Quality tags like
masterpiece, best qualitymake a large difference to output - Responds well to danbooru-style tags:
1girl, long hair, blue eyes, school uniform - Embedding-based negatives (
easynegative) work well - Keep prompts concise, since each chunk is limited to 77 tokens
SDXL (1.0 / Turbo / Lightning)
Negative prompt: Moderate importance. SDXL is less sensitive to negatives than SD 1.5.
Positive prompt structure:
Recommended negative prompt:
Key notes:
- SDXL understands natural language better than tag-based prompts
- Dual CLIP encoders (CLIP-L + CLIP-G). Use
CLIPTextEncodeSDXLfor separate control CLIPTextEncodeSDXLhas separatetext_g(global description) andtext_l(local details) fields- Supports longer prompts natively (two 77-token chunks via dual CLIP)
- Quality tags are less critical but still helpful
- SDXL Turbo: 1-4 steps, CFG 1.0-2.0, minimal negative prompt needed
- SDXL Lightning: 4-8 steps, CFG 1.0-2.0, often works with empty negative
Flux (Flux.1 schnell / dev)
Negative prompt: NOT USED. Flux operates at CFG=1.0 with no negative conditioning.
Positive prompt structure:
Key notes:
- CFG must be 1.0. Higher values cause artifacts
- No negative prompt. Connect nothing or empty string to negative conditioning
- T5-XXL encoder understands complex sentences and spatial relationships
- Flux handles compositional prompts better than SD models
- Longer prompts (200+ tokens) work well thanks to T5 encoder
- Prompt structure: describe the scene naturally, like a caption
- Schnell: 4 steps, simple scheduler
- Dev: 20-50 steps, sgm_uniform scheduler
Flux Prompt Example
SD3 / SD3.5
Negative prompt: Minimal. SD3 needs little negative guidance.
Positive prompt structure:
Key notes:
- Triple CLIP architecture: CLIP-L + CLIP-G + T5-XXL
- Supports much longer prompts than SD 1.5 or SDXL
- Natural language works better than tag-based prompting
- CFG 4-7 (lower than SD 1.5)
- Minimal negatives needed.
low quality, blurryis usually sufficient - Use
CLIPTextEncodeSD3node for model-specific encoding if available
Prompt Structure Best Practices
Recommended Order
- Quality modifiers (if SD 1.5/SDXL):
masterpiece, best quality, highly detailed - Subject:
a young woman, a cyberpunk cityscape, a golden retriever - Subject details:
with long flowing red hair, wearing a white dress - Action/pose:
standing in a field, looking at the camera, running - Environment:
in a sunlit meadow, at night in a neon-lit street - Composition:
close-up portrait, full body shot, wide angle - Lighting:
dramatic lighting, soft natural light, studio lighting, golden hour - Style/medium:
oil painting, photograph, digital art, watercolor, anime - Technical quality:
8k, uhd, photorealistic, sharp focus, depth of field
Quality Boosters
These tokens generally improve output quality across SD 1.5 and SDXL:
For photorealism specifically:
For anime/illustration:
LoRA Trigger Words
LoRA (Low-Rank Adaptation) models are fine-tuned on specific concepts and require their trigger words to activate the learned concept.
Rules
- Trigger words are specific to each LoRA. Check the LoRA's model page for its triggers
- Place trigger words in the prompt naturally:
a photo of ohwx woman in a garden(whereohwxis the trigger) - Some LoRAs use style triggers:
in the style of pixar3d - Multiple LoRAs can be stacked, but each needs its own trigger word in the prompt
- LoRA strength (in the
LoraLoadernode) interacts with prompt weight. Usually keep one at default
Common Patterns
Wildcards and Dynamic Prompts
If ComfyUI-Impact-Pack or a wildcard node pack is installed, you can use dynamic prompt syntax:
Wildcard Syntax
Each {option1|option2|option3} randomly selects one option per generation.
Wildcard Files
Wildcard .txt files (one option per line) can be referenced:
Where haircolor.txt, clothing.txt, and location.txt are in the wildcards directory.
CLIPTextEncode Variants
| Node | Use Case | Notes | |
|---|---|---|---|
CLIPTextEncode | Standard single-CLIP encoding | Works with all models | |
CLIPTextEncodeSDXL | SDXL dual-CLIP with separate G/L fields | Better SDXL control | |
CLIPTextEncodeSD3 | SD3 triple-CLIP encoding | For SD3/SD3.5 models | |
CLIPTextEncodeFlux | Flux T5-based encoding | For Flux models | |
ConditioningCombine | Merge two conditionings | Stack different prompt aspects | |
ConditioningSetArea | Regional prompting | Apply conditioning to specific image areas | |
ConditioningSetMask | Mask-based conditioning | Apply prompt only where mask is active |
Common Prompting Mistakes
- Using negative prompts with Flux: Flux ignores negatives and CFG > 1 causes artifacts
- Tag-based prompts for Flux/SD3: These models prefer natural language descriptions
- Exceeding 77 tokens without BREAK: Tokens past the limit are silently dropped
- Weight > 1.5: Causes color bleeding, artifacts, and distortion
- Conflicting terms:
(bright:1.3) (dark:1.3)confuses the model - Embedding without file: Using
embedding:namewithout the.safetensorsfile installed causes errors - Wrong LoRA trigger words: The prompt must contain the exact trigger word(s) for the LoRA to activate
- Quality tags in Flux prompts:
masterpiece, best qualityare meaningless for Flux. Describe quality naturally
Sources
- Official: none found as a dedicated vendor prompting guide. CLIP
(word:1.2)attention is community convention (A1111/ComfyUI), not a model-vendor spec. - Empirical: model-specific notes (Flux CFG=1, SD 1.5 quality tags, BREAK token) from observed ComfyUI behaviour.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingplugin/skills/prompt-engineering/SKILL.md
Popularity
- Repository stars
- 651
- Repository forks
- 101
- 7-day trend score
- 32
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/artokun/comfyui-mcp/prompt-engineering)