DAGCLI Docs

dag from-mermaid

Convert a Mermaid flowchart diagram to a .dag.json workflow file. Useful for designing pipelines visually in Mermaid Live Editor and then running them directly.

Synopsis

bash
dag from-mermaid "<mermaid string>" [--output <path>] [--run] [--input key=value] [--dagId <id>]
dag from-mermaid <file.dag.md>  [--output <path>] [--run] [--input key=value] [--dagId <id>]

Diagram Syntax

Use standard Mermaid flowchart syntax. Node labels in square brackets map to DAG node types. A node written as id[node-type] sets both the node ID and the node type. A node written as just id uses the ID as the type as well.

text
flowchart LR
  input-->llm[llm-text-anthropic]
  llm-->output[text-output]

Both LR (left-right) and TD (top-down) directions are accepted. Edge labels are ignored.

Inline String

Pass the Mermaid diagram as a quoted string. Use --run to execute immediately after conversion.

bash
dag from-mermaid "flowchart LR
  input-->llm[llm-text-anthropic]
  llm-->output[text-output]" \
  --run \
  --input text="Hello, what is the meaning of life?"

.dag.md File

For longer diagrams, save the Mermaid block inside a .dag.md file and pass the file path as the first argument.

markdown
# pipeline.dag.md
```mermaid
flowchart LR
  input-->llm[llm-text-anthropic]
  llm-->output[text-output]
```
bash
dag from-mermaid pipeline.dag.md --output pipeline.dag.json

Generated Output

The command writes a standard DAG workflow JSON file that can be run with dag run, inspected with dag explain, or repaired with dag fix.

json
{
  "dagId": "generated-dag",
  "nodes": [
    { "id": "input",  "type": "input" },
    { "id": "llm",    "type": "llm-text-anthropic" },
    { "id": "output", "type": "text-output" }
  ],
  "edges": [
    { "source": "input", "target": "llm"    },
    { "source": "llm",   "target": "output" }
  ]
}

Flags

FlagDescription
--output <path>Write the generated .dag.json file to this path. Defaults to stdout if omitted.
--runExecute the generated DAG immediately after conversion.
--input <key=value>Input values passed to the pipeline when --run is set.
--dagId <id>Assign a custom identifier to the generated DAG.