$npx -y skills add Akabane71/dify-workflow-cli --skill dify-workflowBuild, edit, validate, and export Dify AI workflow DSL files using the dify-workflow CLI. Use when: creating Dify workflows/chatflows/chat/agent/completion apps; adding nodes and edges to workflows; configuring LLM/tool/code/if-else/question-classifier nodes; validating DSL befor
| 1 | # Dify Workflow CLI Skill |
| 2 | |
| 3 | Build, edit, validate, layout, and export Dify DSL files entirely from the command line. |
| 4 | The CLI is installed as `dify-workflow` (or `dify-workflow.exe` on Windows). |
| 5 | |
| 6 | If the CLI is not yet installed in the current environment, use [PowerShell install script](./scripts/install.ps1) on Windows or [shell install script](./scripts/install.sh) on macOS/Linux. |
| 7 | |
| 8 | ## When to Use |
| 9 | |
| 10 | - User asks to create a Dify workflow, chatflow, chat app, agent, or completion app |
| 11 | - User asks to add/remove/update nodes or edges in a Dify YAML |
| 12 | - User asks to validate a Dify DSL file before import |
| 13 | - User asks to auto-layout node positions |
| 14 | - User asks to generate a Mermaid diagram of a workflow |
| 15 | - User asks to troubleshoot why a Dify import shows disconnected nodes or errors |
| 16 | |
| 17 | ## Key Constraints |
| 18 | |
| 19 | - **DAG only**: Dify workflows must be directed acyclic graphs. No cycles allowed — Dify's frontend runs `getCycleEdges()` and silently removes all edges between cycle nodes, causing disconnections. |
| 20 | - **Variable references**: Use `{{#node_id.variable#}}` syntax. Tool nodes output `text`/`files`/`json` (NOT `result`). LLM nodes output `text`. |
| 21 | - **Node positioning**: Dify uses screen coordinates (origin top-left, X→right, Y→down). Use `layout` command to auto-arrange. |
| 22 | - **PowerShell JSON**: On Windows PowerShell, avoid inline JSON with `--data`. Use `--data-file` with UTF-8 (no BOM) files instead. |
| 23 | |
| 24 | ## Dify App Modes |
| 25 | |
| 26 | Dify supports 5 app modes, split into two architectures: |
| 27 | |
| 28 | ### Graph-based modes (use `workflow.nodes` + `workflow.edges`) |
| 29 | | Mode | DSL `app.mode` | Description | |
| 30 | |------|----------------|-------------| |
| 31 | | **Workflow** | `workflow` | Single-run DAG execution, no conversation. Start → nodes → End. | |
| 32 | | **Chatflow** | `advanced-chat` | Multi-turn conversation with graph canvas. Uses Answer nodes instead of End. | |
| 33 | |
| 34 | ### Config-based modes (use `model_config` section) |
| 35 | | Mode | DSL `app.mode` | Description | |
| 36 | |------|----------------|-------------| |
| 37 | | **Chat** | `chat` | Simple LLM chat with optional knowledge retrieval. No graph. | |
| 38 | | **Agent** | `agent-chat` | Chat + tool calling. `agent_mode.enabled=true` with strategy (function_call/react). | |
| 39 | | **Completion** | `completion` | Single-turn text generation. Supports `more_like_this`, requires `dataset_query_variable` for knowledge retrieval. | |
| 40 | |
| 41 | ### Validation coverage by mode |
| 42 | - **workflow / chatflow**: Full graph validation (node data, edges, cycles, connectivity, frontend crash prevention, publish checklist) |
| 43 | - **chat / agent-chat / completion**: `model_config` validation (model, prompt, variables, dataset, agent_mode, features) via `model_config_validators/` package |
| 44 | |
| 45 | ## Procedure: Create a Workflow from Scratch |
| 46 | |
| 47 | Before editing a workflow, prefer this execution order: |
| 48 | |
| 49 | 1. Ensure the CLI is installed |
| 50 | 2. Create or open a DSL file |
| 51 | 3. Add/update nodes and edges |
| 52 | 4. Run `validate` |
| 53 | 5. Run `checklist` |
| 54 | 6. Run `layout` |
| 55 | 7. Export or inspect with Mermaid |
| 56 | |
| 57 | If the user asks for a complex node payload, prefer using templates in [assets](./assets/). |
| 58 | |
| 59 | ### Step 1: Create base file |
| 60 | |
| 61 | ```bash |
| 62 | dify-workflow create --mode workflow --name "My Workflow" -o workflow.yaml |
| 63 | # Templates: minimal (default), llm, if-else |
| 64 | # Modes: workflow, chatflow, chat, agent, completion |
| 65 | ``` |
| 66 | |
| 67 | ### Step 2: Add nodes |
| 68 | |
| 69 | ```bash |
| 70 | # Add nodes one at a time |
| 71 | dify-workflow edit add-node -f workflow.yaml --type llm --title "GPT Node" --id my_llm |
| 72 | |
| 73 | # With data (prefer --data-file on Windows to avoid escaping issues) |
| 74 | dify-workflow edit add-node -f workflow.yaml --type code --title "Process" --id processor |
| 75 | dify-workflow edit update-node -f workflow.yaml --id my_llm --data-file ./assets/llm-node-config.json |
| 76 | ``` |
| 77 | |
| 78 | ### Step 3: Add edges |
| 79 | |
| 80 | ```bash |
| 81 | dify-workflow edit add-edge -f workflow.yaml --source start_node --target my_llm |
| 82 | dify-workflow edit add-edge -f workflow.yaml --source my_llm --target end_node |
| 83 | |
| 84 | # For branching nodes (if-else, question-classifier), specify --source-handle |
| 85 | dify-workflow edit add-edge -f workflow.yaml -s ifelse_node -t happy_path --source-handle true |
| 86 | dify-workflow edit add-edge -f workflow.yaml -s ifelse_node -t sad_path --source-handle false |
| 87 | ``` |
| 88 | |
| 89 | ### Step 4: Update node data |
| 90 | |
| 91 | ```bash |
| 92 | dify-workflow edit update-node -f workflow.yaml --id my_llm \ |
| 93 | -d '{"model": {"provider": "openai", "name": "gpt-4o-mini", "mode": "chat", "completion_params": {"temperature": 0.7}}}' |
| 94 | |
| 95 | # Or from file (recommended on Windows) |
| 96 | dify-workflow edit update-node -f workfl |