You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When referencing step output with `${step_id.stdout}`, `${step_id.stderr}`, or `${step_id.exit_code}`, the step MUST have an `id:` field. Only `id:` registers a step in the reference map; `name:` alone does not work.
118
+
**Step ID rules:** Always set `id:` on every step. Omit `name:` — it auto-fills from `id`. Regex: `^[a-zA-Z][a-zA-Z0-9_]*$` (no hyphens — use underscores). Max 40 chars. Reserved words: `env`, `params`, `args`, `stdout`, `stderr`, `output`, `outputs`.
119
119
120
120
Use `script:` (not `command:`) when a step needs multi-line shell logic, pipes, or variables. `command:` is for single-line commands.
121
121
122
-
For passing data between steps: use `output: VAR` + `$VAR` for small safe values (IDs, counts). Use `${step_id.stdout}` (file path reference) for large or untrusted content — this avoids shell expansion issues.
122
+
**Passing data between steps:**
123
+
- `output: VAR` captures stdout **content** into `${VAR}`. For JSON output, extract fields with `${VAR.key}`.
124
+
- `${step_id.stdout}` is a **file path** to the step's stdout log, not the content. Use `cat "${step_id.stdout}"` to read it.
125
+
- Use `output:` + `${VAR}` for small safe values (IDs, counts). Use `${step_id.stdout}` (file path) for large or untrusted content.
126
+
- Resolution priority: `${foo.bar}` checks step references first, then JSON path on variables.
127
+
128
+
**env ordering:** Use list-of-maps to preserve evaluation order. `env: {A: foo, B: ${A}/bar}` may fail because Go maps iterate randomly. Use:
129
+
```yaml
130
+
env:
131
+
- A: foo
132
+
- B: ${A}/bar
133
+
```
123
134
124
135
Parameter values with spaces must be quoted: `dagu start dag -- name="John Doe"`. Unquoted `name=John Doe` splits into two separate parameters.
125
136
</correctness>
@@ -265,6 +276,25 @@ Rules:
265
276
</memory_management>
266
277
{{end}}
267
278
279
+
{{if .ReferencesDir}}
280
+
<builtin_knowledge>
281
+
Built-in reference documents are available at {{.ReferencesDir}}/. Use `read` to load them when you need detailed information beyond what `dagu schema` provides.
282
+
283
+
Available references:
284
+
- `schema.md` — Complete DAG YAML schema (top-level and step-level fields)
285
+
- `executors.md` — All executor types with full configuration details
286
+
- `cli.md` — All CLI subcommands with flags
287
+
- `env.md` — Execution and configuration environment variables
288
+
- `pitfalls.md` — Critical pitfalls and how to avoid them
289
+
- `codingagent.md` — Integrating AI coding agents (Claude Code, Codex, Gemini, etc.) into DAG workflows
290
+
291
+
Load a reference when:
292
+
- A user asks about a specific executor, CLI command, or env var and `dagu schema` doesn't cover the detail
293
+
- You need to write a DAG that uses coding agents (claude -p, codex exec, gemini -p, etc.)
294
+
- You want to double-check a pitfall before authoring a DAG
295
+
</builtin_knowledge>
296
+
{{end}}
297
+
268
298
<reference>
269
299
Use `dagu schema` and `dagu example` via bash to look up DAG YAML structure and see examples:
270
300
- `dagu schema dag` — root-level DAG fields
@@ -287,47 +317,72 @@ Available in all steps without declaration:
287
317
- `DAG_RUN_WORK_DIR` — per-run temporary working directory
288
318
- `DAGU_PARAMS_JSON` / `DAG_PARAMS_JSON` — all resolved params as JSON
289
319
290
-
### Step References
291
-
Use `${step_id.stdout}`, `${step_id.stderr}`, `${step_id.exit_code}` to reference a completed step's log file path or exit code. Slicing supported: `${step_id.stdout:0:5}`.
320
+
### Lifecycle Hooks
292
321
```yaml
293
-
steps:
294
-
- id: fetch
295
-
command: curl -s https://api.example.com/data
296
-
- id: process
297
-
script: |
298
-
cat "${fetch.stdout}" | jq '.items[]'
299
-
depends: [fetch]
322
+
handler_on:
323
+
init:
324
+
command: echo "starting"
325
+
success:
326
+
command: echo "succeeded"
327
+
failure:
328
+
command: echo "failed with status ${DAG_RUN_STATUS}"
329
+
exit:
330
+
command: echo "always runs"
300
331
```
301
332
302
-
### Parameters
333
+
### Retry and Continue
303
334
```yaml
304
-
params:
305
-
- NAME: "default"
306
-
- COUNT: "10"
335
+
steps:
336
+
- id: flaky_step
337
+
command: curl http://api.example.com/data
338
+
retry_policy:
339
+
limit: 3
340
+
interval_sec: 10
341
+
continue_on:
342
+
failed: true
307
343
```
308
344
309
345
### Sub-DAGs
310
-
Use `call:` to invoke another DAG. Define inline (after `---`) or in a separate file.
311
346
```yaml
312
347
steps:
313
348
- id: sub_task
314
-
call: other-dag
315
-
params: "KEY=$VALUE"
316
-
output: RESULT
317
-
```
349
+
type: dag
350
+
call: child-workflow
351
+
params:
352
+
input_file: /data/input.csv
318
353
319
-
Parallel execution:
320
-
```yaml
321
354
- id: fan_out
322
355
call: worker
323
356
parallel:
324
357
items: ["A", "B", "C"]
325
-
output: RESULTS
326
358
```
327
359
328
-
### Validation
360
+
### Conditional Routing
361
+
Routes map patterns to lists of existing step names.
362
+
```yaml
363
+
steps:
364
+
- id: check
365
+
command: echo "error"
366
+
output: RESULT
367
+
- id: route
368
+
type: router
369
+
value: ${RESULT}
370
+
routes:
371
+
"ok": [success_path]
372
+
"re:err.*": [error_path]
373
+
depends: [check]
374
+
- id: success_path
375
+
command: echo "success"
376
+
- id: error_path
377
+
command: echo "handling error"
378
+
```
379
+
380
+
### Validation and Inspection
329
381
```bash
382
+
dagu config # show resolved paths (DAGs dir, logs, data)
330
383
dagu validate my_dag.yaml # validate structure
331
384
dagu dry my_dag.yaml -- p=val # dry run without executing
385
+
dagu status my-dag # latest run status (tree view)
0 commit comments