Workflow Recipes Specification v0.1
DraftThe authoring format for workflows: diagnostic decision trees that live under workflows/<category>/<slug>.yaml and are validated by packages/workflow-schema (pnpm workflows:validate runs in CI). It is a companion to the recipe spec, which remains the normative spec for single-command recipes; workflows reference recipes, never the other way around.
Status
Why workflow recipes are a different shape
A recipe in recipes/answers one question with one linear sequence of platform commands: inspect, act, verify. That model is a poor fit for diagnostics like "I can't push my branch," where the right next step depends on what actually happened. A workflow recipe is a decision tree whose nodes are either a reference to an existing single-command recipe by id, or an ad hoc diagnostic step — a read-only command used only to decide which branch to take next.
A separate workflows/ source tree
Workflows live in their own workflows/ directory with their own schema package (packages/workflow-schema, mirroring packages/recipe-schema's shape) rather than a new type field inside the existing recipe schema — the two have different blast radius, different validation rules, and independent lifecycles. The two trees share one lookup contract: a workflow node that references a recipe id must resolve against the compiled recipes/ index, and the validator rejects any workflow whose recipe_iddoesn't.
Schema shape
File location: workflows/<category>/<slug>.yaml, mirroring recipes' naming convention. The excerpt below is an abridged version of the authored workflows/git/cant-push-branch.yaml.
id: git.cant_push_branch # required, unique among workflows
version: 1 # required, integer
title: I can't push my branch # required, imperative/plain, <= 60 chars
category: git # required, same category list as recipes
tags: [git, push, diagnostics] # required
entry: check_push_error # required, id of the first node in `nodes`
nodes:
check_push_error:
kind: diagnostic # diagnostic | recipe_ref | outcome
run: git push
purpose: Attempt the push and capture how it fails
risk: read_only # diagnostic steps are read_only or low only
branches:
- when: { match: "has no upstream branch" }
goto: set_upstream
- when: { match: "\\[rejected\\].*non-fast-forward" }
goto: diverged_history
- when: { default: true } # exactly one default branch per node
goto: unknown_failure
set_upstream:
kind: recipe_ref
recipe_id: git.set_upstream_and_push # references recipes/git/*.yaml by id
branches:
- when: { outcome: success }
goto: resolved
- when: { default: true }
goto: unknown_failure
resolved:
kind: outcome
outcome: success
summary: The branch now has an upstream and the push succeeded.
Node kinds
diagnostic— an ad hoc read-only (orlow-risk at most) command run purely to decide which branch to take. Anything that changes state belongs in a referenced recipe instead.recipe_ref— points at an existing recipe by id; the workflow never duplicates that recipe's steps. Branching keys offoutcome: successoroutcome: failure.outcome— a terminal node:success,needs_human, orneeds_human_choice.
Branch rules
- Every non-terminal node declares at least one branch and exactly one
default: truebranch, evaluated last. - Every
gotomust reference a node id that exists in the same workflow. matchconditions are anchored regular expressions evaluated against combined stdout+stderr, first match wins.- Every path from
entrymust reach anoutcomenode — unreachable or non-terminating nodes are rejected by the validator.
What exists today
- Schema + validator —
packages/workflow-schemavalidates every workflow (schema conformance, unique ids, branch-graph reachability and termination, recipe-id resolution) viapnpm workflows:validate, which runs in CI. - Authored workflows — the
workflows/tree ships diagnostic workflows across git, docker, network, and node, browsable on this site at /workflows. - Public API —
GET /api/v1/workflows,/workflows/search, and/workflows/{id}, documented in the API reference. - MCP tools —
search_workflowsandget_workflowexpose the library to MCP-compatible agents; see the MCP server docs. - CLI interpreter —
codewright diagnose <workflow_id>drives a workflow from its entry node to a terminal outcome, runningrecipe_refnodes through the same confirm/execute/verify path ascodewright run; see the CLI docs.