dify-workflow-builder
npx skills add https://github.com/r3flector/dify-workflow-builder --skill dify-workflow-builder
Agent 安装分布
Skill 文档
Dify Workflow Builder
Expert skill for generating production-quality Dify DSL workflow files. Generates valid YAML configurations for Dify v1.12+ with precise node schemas derived from Pydantic source models.
Reading Strategy
Always read:
- This file (SKILL.md) â process, patterns, quality standards
- Node Index â base fields + pick which node files to load
- Entry nodes + Output nodes â every workflow needs these
Read on demand (only the files relevant to your task):
- Node type files from
references/nodes/â only for node types used in the workflow - Edge Types â when connecting nodes (sourceHandle rules)
- Variables â when using system/env/conversation variables
- Workflow Structure â for features, conversation_variables, environment_variables
- Node Positioning â for layout constants
- Enums â for exact enum values
- API Reference â for import/export API calls
Example workflows in assets/ â read the most relevant one as a template before generating.
Mode Selection
| Choose | When |
|---|---|
workflow |
One-shot execution, batch processing, API-triggered tasks. Uses start â … â end. |
advanced-chat |
Conversational UI, multi-turn dialogue, memory needed. Uses start â … â answer. |
Key differences:
workflowmode: Nosys.query, no conversation memory, usesendnode with explicit outputsadvanced-chatmode: Hassys.query,sys.conversation_id,sys.dialogue_count, usesanswernode for streaming response- Only
advanced-chatsupportsconversation_variablesfor session-persistent state
Workflow Generation Process (5 Steps)
Step 1: Define Type and Inputs
app:
mode: workflow | advanced-chat
name: "Workflow Name"
description: "What this workflow does"
icon: "ð¤"
icon_background: "#FFEAD5"
kind: app
version: "0.5.0"
Define start node variables based on user requirements:
- data:
type: start
title: Start
variables:
- type: text-input | paragraph | select | number | file | file-list
variable: input_name
label: "Human-readable label"
required: true
Step 2: Design the Node Graph
Map the business logic to node types. Read the relevant files from references/nodes/:
- AI processing: ai.md â llm, agent, question-classifier, parameter-extractor
- Data: data.md â knowledge-retrieval, datasource, document-extractor
- Logic: logic.md â if-else, code, template-transform, http-request, tool, list-operator
- Flow control: flow.md â iteration, loop, human-input
- Variables: variables_nodes.md â variable-aggregator, assigner
Step 3: Generate Unique IDs
Every node needs a unique ID. Use the timestamp-based format:
node_id = str(int(time.time() * 1000))[-10:] # e.g. "1732456789"
Step 4: Configure Edges
Connect nodes with edges. Read Edge Types for full sourceHandle rules.
- data:
sourceType: llm
targetType: end
isInIteration: false
isInLoop: false
id: "source_id-target_id-sourceHandle-targetHandle"
source: "source_node_id"
sourceHandle: source # "source" | "{case_id}" | "false" | "success-branch" | "fail-branch"
target: "target_node_id"
targetHandle: target # always "target"
type: custom
Step 5: Add Positioning
See Node Positioning for full layout constants.
Linear chain: each node at x += 300 (NODE_WIDTH_X_OFFSET), starting at {x: 80, y: 282}.
position:
x: 80
y: 282
width: 244
height: 98 # varies by node type
Common Workflow Patterns
Pattern 1: Simple LLM Chain
start â llm â end/answer
See assets/simple_llm_workflow.yml or assets/simple_llm_chatflow.yml.
Pattern 2: RAG (Retrieval-Augmented Generation)
start â knowledge-retrieval â llm â answer
See assets/knowledge_rag_chatflow.yml.
Pattern 3: Conditional Branching
start â if-else â [branch A: llm-1] â variable-aggregator â end
â [branch B: llm-2] â
See assets/conditional_workflow.yml.
Pattern 4: Error Handling
start â llm (error_strategy: fail-branch)
â [success-branch] â end
â [fail-branch] â variable-aggregator â end
See assets/error_handling_workflow.yml.
Pattern 5: Iteration
start â iteration [llm â code] â end
See assets/iteration_workflow.yml.
Pattern 6: Loop with Break
start â loop [code â if-else â loop-end] â end
See assets/loop_workflow.yml.
Pattern 7: Agent with Tools
start â agent(tools: [web-search, calculator]) â answer
See assets/agent_chatflow.yml.
Pattern 8: Human-in-the-Loop
start â llm â human-input â code â end
See assets/human_approval_workflow.yml.
Quality Standards
Required (MUST)
version: "0.5.0"â current DSL versionmode: workflow | advanced-chatâ notagent-chat- Every node has unique
id(string, timestamp-based) - Every edge references existing source and target node IDs
workflowmode usesendnode,advanced-chatusesanswernode- All
variable_selectorpaths resolve to existing node outputs or system variables sourceHandlematches node type pattern (see Edge Types)error_strategyonly uses"fail-branch"or"default-value"(NOT “abort” or “retry”)- Container nodes (
iteration,loop) havestart_node_idpointing to internal start node assigner(v2) hasversion: "2"field
Recommended (SHOULD)
- Use descriptive
titlefor each node - Enable
retry_configfor unreliable external calls (http-request, tool) - Use
error_strategy: "fail-branch"for non-critical paths - Set
is_parallel: truefor iteration when items are independent - Keep
parallel_nums⤠10 to avoid rate limits - Validate with
scripts/validate_workflow.pybefore import