Turns a natural-language description into a validated workflow definition via a plan → write → validate loop, then pushes to the hub when the caller asked for cloud mode. This is the default meta-workflow that drives `/meta-workflow:create-workflow`.
Purpose: Produce an approved plan the writer subagent can consume deterministically. Works for both create from scratch and edit an existing workflow — the difference is the starting point.
Output artifact: write to the absolute path provided in your I/O context
Valid results this stage writes:pending (plan drafted, awaiting user approval), approved (user has explicitly confirmed)
<HARD-GATE>
Do NOT transition out of this stage until the user explicitly confirms the plan.
Write `result: approved` only after they have said so.
</HARD-GATE>
This is an interruptible stage — the stop hook allows natural pauses for Q&A.
Read the setup_context input at the absolute path shown in your I/O context. It contains JSON with these fields:
mode: "create" or "edit"
description: the original natural-language description the user passed to /meta-workflow:create-workflow (may be empty). This is the only place the description shows up — it is NOT in state.md's topic: field.
source_dir: (edit mode only) absolute path to the existing workflow to edit
Log the parsed mode and description before proceeding:
Use the description from setup_context as the user's request. If it's empty or too vague to decompose, ask ONE clarifying question at a time (cap at 5 total). Useful axes:
What kind of work does this workflow orchestrate? (coding, writing, data analysis, review, research, etc.)
What are the rough phases? A 3-line sketch is enough — you'll refine it below.
Any phase where the user should pause for input? → interruptible inline stage.
Any phase that benefits from a stronger model? → subagent stage with model: opus (or leave model unspecified for sonnet default).
Any external validation / test run? → subagent or inline stage that runs a command.
Do NOT verify ownership by calling the cloud API, running curl, or piping bundle JSON through jq for author/user_id checks. SKILL.md has already refetched the bundle into $source_dir and the setup script has gated on ownership; the fact that source_dir is readable is sufficient proof that you're allowed to edit. Any additional probing (curl → jq chains, python3 JSON parsing, etc.) produces terminal noise and exploration latency without changing the outcome. Treat source_dir as authoritative.
Read the source directory (source_dir from setup_context). Run this so the current design flows into your context:
bash
SRC="<absolute-path-from-setup_context>"
echo "===== workflow.json ====="; cat "$SRC/workflow.json"
for f in "$SRC"/*.md; do
echo "===== $(basename "$f") ====="; cat "$f"; echo
done
Present the current design to the user as a table + transition graph (same format as Step 3 below). Call it out as "current design — propose changes against this."
Treat the description from setup_context (if non-empty) as the user's change request. If it's empty, ask: "What changes do you want to make to this workflow?"
Continue to Step 3 with the current design as the starting point.
For each stage, list required and optional inputs using from_stage <name> or from_run_file <name>. Required inputs are enforced at transition time by update-status.sh.
If the workflow needs setup-time constants (e.g. git SHA baseline, current date), list each run_files entry: name, description, and the shell init command.
Create mode: derive a short, kebab-case suffix from the description (e.g. "Python library dev with docs and publish" → python-lib). Confirm with the user. Target directory: ~/.config/meta-workflow/workflows/<suffix>/. If the directory already exists, ask whether to overwrite or pick a different name.
Edit mode: suffix = basename(source_dir); target directory = source_dir itself (writer will overwrite files in place). Do not ask — this is fixed by the setup_context.
Ask: "Does this design look right? Any changes to stages, order, inputs, or naming?" Iterate until the user explicitly approves.
If the user says "no changes" in Edit mode, write the plan anyway with the current design verbatim (writing is idempotent — same files get re-emitted).