Writing Workflows
A workflow, or DAG, is a YAML file with a steps list. Each step runs a shell command or a built-in action, and depends sets the order. Start with one command, then add a schedule, parameters, retries, and handlers when the workflow needs them.
Start With One Command
Save this as hello.yaml:
steps:
- run: echo "Hello from Dagu"Run it:
dagu start hello.yamlThat is a complete workflow. Workflow Basics grows it into a graph with parallel branches and explains what happens when a step fails.
How a Workflow Runs
Every trigger creates a DAG run: one execution of the file with its own run ID, step statuses, logs, and outputs.
The scheduler, Web UI, and REST API run inside the server (dagu start-all). dagu start runs a workflow directly from the command line.
Anatomy of a Workflow
Most workflows use a few top-level fields around steps:
description: Load yesterday's orders into the warehouse
labels: [etl, team=data]
schedule: "0 2 * * *"
working_dir: .
params:
- name: date
type: string
default: "2026-12-01"
steps:
- id: extract
run: ./extract.sh "${params.date}"
retry_policy:
limit: 3
interval_sec: 30
- id: load
depends: extract
run: ./load.sh
handler_on:
failure:
run: ./notify-oncall.sh| Part | Fields | Read |
|---|---|---|
| What runs and in which order | steps, depends, type | Workflow Basics |
| When it runs | schedule, watch, calendar | Scheduling, Watched Folders |
| Inputs | params, env, dotenv, secrets | Parameters, Environment Variables, Secrets |
| Failure behavior | retry_policy, continue_on, timeout_sec, handler_on | Durable Execution, Lifecycle Handlers |
| Where steps run | working_dir, container, tools, queue | Container, Tools, Queue Assignment |
| Organization | description, group, labels | Labels |
The YAML Specification lists every field.
Develop and Run
| Command | What it does |
|---|---|
dagu validate etl.yaml | Check fields, types, and step references without running anything. |
dagu dry etl.yaml | Simulate a run without executing commands. |
dagu test etl.test.yaml | Run workflow tests with step actions mocked. |
dagu start etl.yaml -- date=2026-12-02 | Run now, with parameter overrides after --. |
dagu start --only load etl.yaml | Run selected steps and record the rest as skipped. |
dagu history etl | List recent runs of a workflow. |
To use the Web UI, start the server with your workflow folder and open http://localhost:8080:
dagu start-all --dags .Each workflow page shows the graph, live step status, logs, run history, and buttons to start, stop, and retry runs.
Commands and Actions
run executes shell text. For work with structured inputs, set action and pass its inputs under with. Actions use the same depends, retries, conditions, statuses, and logs as commands.
steps:
- id: fetch_rates
action: http.request
with:
method: GET
url: https://api.example.com/rates
- id: report
depends: fetch_rates
action: docker.run
with:
image: python:3.13-slim
command: python -c "print('rates fetched')"Built-in Actions
| Need | Action | Page |
|---|---|---|
| Run a container or a Kubernetes job | docker.run, kubernetes.run | Docker, Kubernetes |
| Run commands or copy files over SSH | ssh.run, sftp.upload | SSH, SFTP |
| Call an API | http.request | HTTP |
| Query a database | postgres.query, sqlite.query | SQL |
| Transform JSON or data | jq.filter, js.run, data.convert | jq, JavaScript, Data |
| Move files | s3.upload, file.copy, archive.extract | S3, File, Archive |
| Branch to selected steps | router.route | Router |
| Call another workflow | dag.run | Sub-DAGs |
| Wait for a person | human.task | Human Tasks |
| Run a coding agent or an LLM | harness.run, chat.completion | Harness, LLM |
The Actions section of the sidebar covers every action.
Container runtime access
Container actions need a Docker-compatible daemon. If Dagu itself runs in Docker, mount the host socket.
Find the Next Topic
| When you want to | Read |
|---|---|
| Pass parameters, outputs, and files between steps | Data & Variables |
| Add conditions, loops, parallel iteration, or routing | Control Flow |
| Split a workflow into reusable parts | Sub-DAGs |
| Skip holidays or run on business days | Business Calendars |
| Keep a workflow running like a service | Services |
| Reuse unchanged file-producing steps | Build Workflows |
| Send local scripts to distributed workers | File Dependencies |
| Test failure paths without running real commands | Workflow Tests |
| Start from a copyable workflow | Examples |



