Workflow — Multi-Step Pipeline Orchestration
Goal
Define, persist, and execute multi-step pipelines that survive context compaction and session restarts. Success = workflow runs to completion with each step's output saved to a file, checkpoints honored, and a final log written.
Dependencies
- Tools: Read, Write, Edit, Glob, Grep, Bash
- No external services required; sub-skills and agents are invoked by name
Context
Workflow definitions and state live in .claude/workflows/. Each run reads the definition file and an optional state file to enable resumption.
Define, run, and resume multi-step workflows that chain skills and agents together.
Commands
/workflow define <name>
- Ask the user to describe the workflow in plain English
- Break into numbered steps — each step is one of:
- Skill:
/research, /wizard, /tdd, etc.
- Agent:
@code-reviewer, @debugger, etc.
- Instruction: plain text task for Claude
- Command: bash command to execute
- For each step, define: input source, output file, and whether it's a checkpoint
- Save to
.claude/workflows/<name>.md
/workflow run <name> [VAR=value ...]
- Read
.claude/workflows/<name>.md
- If
.claude/workflows/<name>-state.md exists, ask: resume or start fresh?
- For each step:
- Announce: "Step N: [name] — [description]"
- Execute with appropriate context (pass prior step output as file reference)
- At checkpoint steps: present output, ask "Proceed, modify, or abort?"
- On failure: save state, report clearly, stop
- On success: mark step done in state file
- On completion: write summary to
.claude/workflows/<name>-log.md
/workflow list
Show all workflows in .claude/workflows/ with step count and last run date.
/workflow status <name>
Show current state: which steps completed, which failed, what output was produced.
/workflow resume <name>
Read state file, pick up from last incomplete step.
Workflow Definition Format
# Workflow: content-pipeline
## Description
Research a topic, plan content, write it, review, optimize for SEO.
## Steps
1. **research** — /research $TOPIC
- Output: RESEARCH-$TOPIC.md
- Checkpoint: false
2. **plan** — /plan-and-spec based on research
- Input: RESEARCH-$TOPIC.md
- Output: PLAN.md
- Checkpoint: true
3. **write** — Write the article following PLAN.md
- Input: PLAN.md, RESEARCH-$TOPIC.md
- Output: drafts/$TOPIC.md
- Checkpoint: true
4. **review** — @code-reviewer on the draft
- Input: drafts/$TOPIC.md
- Output: REVIEW.md
- Checkpoint: false
5. **finalize** — Apply review feedback and optimize
- Input: drafts/$TOPIC.md, REVIEW.md
- Output: final/$TOPIC.md
- Checkpoint: true
## Variables
- $TOPIC: Subject of the article
## On Failure
Pause and report: step name, input used, error. Do not skip.
State File Format
# State: content-pipeline (run 2026-03-23)
## Variables
TOPIC=Claude Code best practices
## Steps
- Step 1 research: COMPLETED — output: RESEARCH-claude-code.md
- Step 2 plan: COMPLETED — output: PLAN.md
- Step 3 write: IN_PROGRESS
- Step 4 review: PENDING
- Step 5 finalize: PENDING
Design Principles
- State in files: Workflow state survives compaction and session restarts
- Output as files: Each step writes to a file path, not inline content (protects context)
- Checkpoints are sacred: Never skip a checkpoint without explicit user approval
- Heavy steps fork: For steps that produce large output, delegate to a subagent to protect main context
1---2name: workflow3description: Define and run multi-step workflows that chain skills, agents, and tasks together with state tracking. Use when the user says "workflow", "pipeline", "chain these steps", "run my pipeline", "define a workflow", "automate these steps", or has a task with more than 3 sequential steps.4---56# Workflow — Multi-Step Pipeline Orchestration78## Goal9Define, persist, and execute multi-step pipelines that survive context compaction and session restarts. Success = workflow runs to completion with each step's output saved to a file, checkpoints honored, and a final log written.1011## Dependencies12- Tools: Read, Write, Edit, Glob, Grep, Bash13- No external services required; sub-skills and agents are invoked by name1415## Context16Workflow definitions and state live in `.claude/workflows/`. Each run reads the definition file and an optional state file to enable resumption.1718Define, run, and resume multi-step workflows that chain skills and agents together.1920## Commands2122### `/workflow define <name>`231. Ask the user to describe the workflow in plain English242. Break into numbered steps — each step is one of:25 - **Skill**: `/research`, `/wizard`, `/tdd`, etc.26 - **Agent**: `@code-reviewer`, `@debugger`, etc.27 - **Instruction**: plain text task for Claude28 - **Command**: bash command to execute293. For each step, define: input source, output file, and whether it's a checkpoint304. Save to `.claude/workflows/<name>.md`3132### `/workflow run <name> [VAR=value ...]`331. Read `.claude/workflows/<name>.md`342. If `.claude/workflows/<name>-state.md` exists, ask: resume or start fresh?353. For each step:36 - Announce: "**Step N: [name]** — [description]"37 - Execute with appropriate context (pass prior step output as file reference)38 - At **checkpoint** steps: present output, ask "Proceed, modify, or abort?"39 - On failure: save state, report clearly, stop40 - On success: mark step done in state file414. On completion: write summary to `.claude/workflows/<name>-log.md`4243### `/workflow list`44Show all workflows in `.claude/workflows/` with step count and last run date.4546### `/workflow status <name>`47Show current state: which steps completed, which failed, what output was produced.4849### `/workflow resume <name>`50Read state file, pick up from last incomplete step.5152## Workflow Definition Format53```markdown54# Workflow: content-pipeline5556## Description57Research a topic, plan content, write it, review, optimize for SEO.5859## Steps601. **research** — /research $TOPIC61 - Output: RESEARCH-$TOPIC.md62 - Checkpoint: false63642. **plan** — /plan-and-spec based on research65 - Input: RESEARCH-$TOPIC.md66 - Output: PLAN.md67 - Checkpoint: true68693. **write** — Write the article following PLAN.md70 - Input: PLAN.md, RESEARCH-$TOPIC.md71 - Output: drafts/$TOPIC.md72 - Checkpoint: true73744. **review** — @code-reviewer on the draft75 - Input: drafts/$TOPIC.md76 - Output: REVIEW.md77 - Checkpoint: false78795. **finalize** — Apply review feedback and optimize80 - Input: drafts/$TOPIC.md, REVIEW.md81 - Output: final/$TOPIC.md82 - Checkpoint: true8384## Variables85- $TOPIC: Subject of the article8687## On Failure88Pause and report: step name, input used, error. Do not skip.89```9091## State File Format92```markdown93# State: content-pipeline (run 2026-03-23)94## Variables95TOPIC=Claude Code best practices9697## Steps98- Step 1 research: COMPLETED — output: RESEARCH-claude-code.md99- Step 2 plan: COMPLETED — output: PLAN.md100- Step 3 write: IN_PROGRESS101- Step 4 review: PENDING102- Step 5 finalize: PENDING103```104105## Design Principles106- **State in files**: Workflow state survives compaction and session restarts107- **Output as files**: Each step writes to a file path, not inline content (protects context)108- **Checkpoints are sacred**: Never skip a checkpoint without explicit user approval109- **Heavy steps fork**: For steps that produce large output, delegate to a subagent to protect main context