.mg Format Reference
The Migraine DSL (.mg) for defining workflows in a native, concise syntax
The .mg format is Migraine's native DSL — a concise, structured alternative to YAML for defining workflows. It provides syntax highlighting, editor integration, and a more ergonomic way to write workflows.
Overview
While Migraine supports YAML workflows (.yaml / .yml), the .mg format offers:
- Concise syntax — less boilerplate than YAML
- Comments —
#line comments for documentation - Native hooks —
on_failandon_successon every step and pre-check - Rich strings — double-quoted
"..."and backtick`...`strings for shell commands - Editor support — syntax highlighting, diagnostics, completions, and hover docs via LSP
File Extension
Save workflow files with the .mg extension (e.g., deploy.mg). Migraine discovers .mg files alongside .yaml/.yml files in the ./workflows/ directory.
Format Reference
Blocks
A .mg file consists of four top-level blocks:
| Block | Required | Description |
|---|---|---|
metadata {} | Yes | Workflow name and description |
variables {} | No | Variable definitions with resolution prefixes |
workflow {} | Yes | Execution definition (pre-checks, steps, actions) |
config {} | No | Configuration options |
Metadata Block
name— workflow identifier (required)descordescription— human-readable description
Variables Block
Variable resolution prefixes:
| Prefix | Resolution | Example |
|---|---|---|
args: | CLI flag argument | "args:APP_NAME" → resolved from -v APP_NAME=value |
env: | Environment variable | "env:HOME" → $HOME |
vault: | Migraine vault | "vault:SECRET_KEY" → stored vault value |
| (none) | Static string | "production" → literal value |
Variables support string, boolean (true/false), and number values. All variables are available in commands via {{variable_name}} template syntax.
Workflow Block
The workflow block contains three sections:
Pre-Checks
cmd(required) — shell command to executedesc— human-readable descriptionon_fail— hook to run when the check fails (action:nameorrun:command)on_success— hook to run when the check passes
If any pre-check fails, the workflow stops. Hooks are optional.
Steps
cmd(required) — shell command, supports{{variable}}substitutiondesc— description shown during executionon_fail— hook on step failureon_success— hook on step success
Actions
Actions are named, reusable commands triggered by hooks. They themselves support on_fail and on_success for chaining.
Hook References
Hooks reference actions or inline commands:
| Hook format | Behavior |
|---|---|
"action:name" | Runs the named action defined in actions {} |
"run:echo done" | Runs the inline command after run: |
Config Block
| Option | Type | Default | Description |
|---|---|---|---|
store_variables | bool | false | Persist resolved variables between runs |
store_logs | bool | false | Store execution logs |
background | bool | false | Run workflow in background |
global | bool | false | Make workflow available globally |
Full Example
Syntax Reference
Comments
Lines starting with # are comments:
Strings
Two string types are supported:
"double quoted"— standard strings with\"escape support`backtick quoted`— raw strings, ideal for shell commands containing quotes and special characters
Template Variables
Use {{variable_name}} inside any command string:
Punctuation
| Symbol | Meaning |
|---|---|
= | Key-value assignment |
{ } | Block or atom delimiter |
[ ] | List delimiter (for pre_checks and steps) |
, | Optional separator between list items and action blocks |
YAML vs .mg Comparison
| Feature | YAML | .mg |
|---|---|---|
| Syntax | Indentation-based | Brace-delimited |
| Comments | # | # |
| Hook support | Limited | on_fail / on_success on every atom |
| Shell commands | Must quote carefully | Backtick raw strings |
| Editor support | Generic YAML | Dedicated LSP |
| File discovery | *.yaml, *.yml | *.mg |
Running .mg Workflows
.mg files are discovered automatically alongside YAML workflows:
Migraine