# Mastra Workflows

> Mastra Workflow development guide - DAG composition, control flow, suspend/resume, HITL, time travel, state management, and streaming. Covers createWorkflow()/createStep(), .then/.parallel/.branch/.foreach/.map, dountil/dowhile loops, sleep/sleepUntil, restarting a run from a failed step, and restructuring bottlenecked batch steps into per-item execution.

- Skill: `artsmc-claude-dev-agents/mastra-workflows` (Agent Skill, multi-file: 4 files)
- Install (CLI): `npx skillmds@latest add artsmc-claude-dev-agents/mastra-workflows`
- Raw SKILL.md: https://api.skillmd.com/api/skills/artsmc-claude-dev-agents/mastra-workflows/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Productivity
- Author: artsmc (https://skillmd.com/u/artsmc-claude-dev-agents)
- Updated: 2026-09-10
- Page: https://skillmd.com/skills/artsmc-claude-dev-agents/mastra-workflows

---


# Mastra Workflow Development

Comprehensive guide for building DAG-based workflows with Mastra. Covers step creation, control flow patterns (.then, .parallel, .branch, .foreach, .map, loops, sleep), suspend/resume, human-in-the-loop, time travel debugging, workflow state, and streaming.

## Usage

```bash
/mastra-workflows
```

Provides context for:
- `createWorkflow()` and `createStep()` APIs
- DAG composition with `.commit()`
- Run management (`createRun()`, `start()`, `cancel()`, `restart()`)
- Suspend/resume with `resumeSchema`
- Human-in-the-loop approval patterns
- Workflow state (`stateSchema`, `setState`)
- Data mapping between steps
- Error handling strategies

