Workflow Skills
Use AI skills to design and build durable workflows through a two-stage teach-then-build loop.
Workflow skills are AI-assisted commands that guide you through creating durable workflows. Start from a specific problem with a scenario command, or use the two-stage loop to capture your project context once and build correct workflows interactively.
Scenario Commands: Start from What You're Building
If you know what kind of workflow you need, start here:
| Command | What it builds |
|---|---|
/workflow-approval | Approval with expiry, escalation, and deterministic hooks |
/workflow-webhook | External webhook ingestion with duplicate handling and compensation |
/workflow-saga | Partial-success side effects and compensation |
/workflow-timeout | Correctness depends on sleep/wake-up behavior |
/workflow-idempotency | Retries and replay can duplicate effects |
/workflow-observe | Operators need progress streams and terminal signals |
Scenario commands reuse .workflow.md when present and fall back to a focused
context capture when not. They apply domain-specific guardrails and terminate
with the same verification_plan_ready contract as /workflow-build.
Example Prompts
/workflow-saga reserve inventory, charge payment, compensate on shipping failure/workflow-timeout wait 24h for approval, then expire/workflow-idempotency make duplicate webhook delivery safe/workflow-observe stream operator progress and final statusReview Existing Workflows
When you already have workflow code and need to assess correctness before changing it, run:
/workflow-auditFor example:
Audit our purchase approval workflow for timeout holes, replay safety, and missing suspension tests.
The audit skill reads .workflow.md when present, inspects the workflow code and tests,
scores 12 durable-workflow checks, tags issues P0-P3, and recommends the single best next skill.
The Manual Path: Teach, Then Build
For workflows that don't fit a scenario command, use the two-stage loop:
Workflow skills require an AI coding assistant that supports user-invocable skills, such as Claude Code or Cursor.
Two-Stage Loop: Teach, Then Build
| Stage | Command | Purpose | Output |
|---|---|---|---|
| 1 | /workflow-teach | Capture project context | .workflow.md |
| 2 | /workflow-build | Build workflow code interactively | TypeScript code + tests |
The workflow skill is an always-on API reference available at any point.
Install the Skills Bundle
Copy the skills into your project. Choose the bundle that matches your AI tool:
Claude Code:
cp -r node_modules/workflow/dist/workflow-skills/claude-code/.claude/skills/* .claude/skills/Cursor:
cp -r node_modules/workflow/dist/workflow-skills/cursor/.cursor/skills/* .cursor/skills/After copying, you should see 11 skill directories:
- Core skills:
workflow(always-on reference),workflow-teach(stage 1), andworkflow-build(stage 2) - Scenario skills:
workflow-approval(approval with expiry and escalation),workflow-webhook(webhook ingestion with duplicate handling),workflow-saga(multi-step compensation),workflow-timeout(expiry and wake-up correctness),workflow-idempotency(replay-safe side effects), andworkflow-observe(operator streams and terminal signals) - Review skill:
workflow-audit(score an existing workflow or design before touching code) - Optional helper:
workflow-init(first-time project setup beforeworkflowis installed as a dependency)
Teach Your Project Context
Run /workflow-teach to start an interactive interview that captures your
project's domain knowledge:
/workflow-teachThe skill scans your repository and asks about:
- Trigger surfaces — API routes, webhooks, queues, cron jobs
- External systems — databases, payment providers, notification services
- Business invariants — rules that must never be violated
- Idempotency requirements — which operations must be safe to retry
- Timeout and approval rules — human-in-the-loop constraints
- Compensation rules — what to undo when later steps fail
- Observability needs — what operators need to see in logs and streams
The output is saved to .workflow.md in the project root — a plain-English
markdown file containing project context, business rules, failure expectations,
and approved patterns. This file is git-ignored and stays local to your checkout.
Build a Workflow
Run /workflow-build and describe the workflow you want to create:
/workflow-buildFor example:
Build a workflow that routes purchase orders for manager approval, escalates to a director after 48 hours, and auto-rejects after a further 24 hours.
The build skill reads .workflow.md and walks through six interactive phases:
- Propose step boundaries — which functions need
"use workflow"vs"use step", suspension points, stream requirements - Flag relevant traps — run a 12-point stress checklist against the design
- Decide failure modes —
FatalErrorvsRetryableError, idempotency strategies, compensation plans - Write code + tests — produce the workflow file and integration tests
- Self-review — run the stress checklist again against the generated code
- Verification summary — emit a structured verification artifact and a single-line
verification_plan_readyevent for machine consumption
Each phase waits for your confirmation before proceeding.
Persisted Artifacts
The skill loop produces two categories of artifacts:
| Category | Artifact | Path | Owner |
|---|---|---|---|
| Skill-managed | Project context | .workflow.md | workflow-teach |
| Host-managed | Project context (JSON) | .workflow-skills/context.json | Host runtime |
| Host-managed | Workflow blueprint | .workflow-skills/blueprints/<name>.json | Host runtime |
| Host-managed | Verification plan | .workflow-skills/verification/<name>.json | Host runtime |
Skill-managed: .workflow.md
Written directly by workflow-teach. A plain-English markdown file containing
project context, business rules, failure expectations, and approved patterns.
This is the primary bridge between teach and build — workflow-build reads
this file to inform step boundaries, failure modes, and test coverage.
Host-managed: .workflow-skills/*.json
The .workflow-skills/ directory contains machine-readable companion artifacts
managed by the host runtime or persistence layer — not by the skill prompts
themselves. The skill text never references these JSON paths directly; instead,
the host extracts structured data from the skill conversation and persists it
for agent consumption. This separation keeps the skill prompts focused on
human-readable guidance while enabling programmatic queries against the JSON
artifacts.
context.json— structured project context derived fromworkflow-teachblueprints/<name>.json— workflow blueprint with step boundaries, suspension points, and trap analysisverification/<name>.json— verification plan with files, test matrix, runtime commands, and implementation notes
The files array must list only files that are actually produced. Add the route entry only when a route file is generated.
Example verification plan:
{
"contractVersion": "1",
"blueprintName": "approval-expiry-escalation",
"files": [
{ "kind": "workflow", "path": "workflows/approval-expiry-escalation.ts" },
{ "kind": "test", "path": "workflows/approval-expiry-escalation.integration.test.ts" }
],
"testMatrix": [
{
"name": "happy-path",
"helpers": [],
"expects": "Workflow completes successfully"
},
{
"name": "hook-suspension",
"helpers": ["waitForHook", "resumeHook"],
"expects": "Workflow resumes from hook"
},
{
"name": "sleep-suspension",
"helpers": ["waitForSleep", "wakeUp"],
"expects": "Workflow resumes after sleep"
}
],
"runtimeCommands": [
{
"name": "typecheck",
"command": "pnpm typecheck",
"expects": "No TypeScript errors"
},
{
"name": "test",
"command": "pnpm test",
"expects": "All repository tests pass"
},
{
"name": "focused-workflow-test",
"command": "pnpm vitest run workflows/approval-expiry-escalation.integration.test.ts",
"expects": "approval-expiry-escalation integration tests pass"
}
],
"implementationNotes": [
"Invariant: A purchase order must receive exactly one final decision: approved, rejected, or auto-rejected",
"Invariant: Escalation must only trigger after the primary approval window expires",
"Operator signal: Log approval.requested with PO number and assigned manager",
"Operator signal: Log approval.escalated with PO number and director"
]
}The .workflow.md Bridge
Written by workflow-teach, read by workflow-build, .workflow.md contains:
| Section | Contents |
|---|---|
| Project Context | What the project does and why it needs durable workflows |
| Business Rules | Invariants, idempotency requirements, domain constraints |
| External Systems | Third-party services, trigger surfaces, rate limits |
| Failure Expectations | Permanent vs retryable failures, timeouts, compensation rules |
| Observability Needs | What operators and UIs need to see |
| Approved Patterns | Anti-patterns relevant to this project's workflow surfaces |
| Open Questions | Gaps that workflow-build will surface again |
Hero Scenario: Approval Expiry Escalation
The approval-expiry-escalation scenario is the recommended first workflow to build with the skill loop. It exercises the hardest patterns in a single flow:
| Pattern | How It Appears |
|---|---|
| Human-in-the-loop approval | Manager and director hooks |
| Timeout handling | 48h and 24h sleep suspensions |
| Escalation logic | Promise.race between hook and sleep |
| Idempotency | Every side-effecting step has an idempotency key |
| Deterministic tokens | Hook tokens derived from the PO number |
| Observability | Operator signals cover the full approval lifecycle |
Run /workflow-teach first, then /workflow-build with the approval scenario
prompt to walk through the full loop.
Stress Checklist
The build skill runs this 12-point checklist twice — once against your proposed design and once against the generated code:
- Determinism boundary
- Step granularity
- Pass-by-value / serialization
- Hook token strategy
- Webhook response mode
start()placement- Stream I/O placement
- Idempotency keys
- Retry semantics
- Rollback / compensation
- Observability streams
- Integration test coverage
Inspect Build Output
The workflow-skills builder emits structured JSON logs on stderr and a JSON manifest on stdout. Redirect them to inspect build state programmatically:
pnpm build:workflow-skills > /tmp/workflow-skills-manifest.json 2> /tmp/workflow-skills-build.log
echo 'manifest summary'
cat /tmp/workflow-skills-manifest.json | jq '{providers, totalOutputs}'
echo 'first 3 structured log events'
head -n 3 /tmp/workflow-skills-build.log | jqExpected output shape:
{ "providers": ["claude-code", "cursor"], "totalOutputs": 52 }{"event":"start","ts":"2026-03-27T16:41:23.035Z","mode":"build"}
{"event":"skills_discovered","ts":"2026-03-27T16:41:23.120Z","count":11,"scenarioCount":6}
{"event":"plan_computed","ts":"2026-03-27T16:41:23.240Z","totalOutputs":52,"providerCount":2,"skillCount":11,"scenarioCount":6,"goldensPerProvider":15,"outputsPerProvider":26}Verification commands
node scripts/build-workflow-skills.mjs --check | jq '{skillSurface, totalOutputs}'
pnpm vitest run workbench/vitest/test/workflow-skill-bundle-parity.test.ts
pnpm vitest run workbench/vitest/test/workflow-skills-docs-contract.test.tsExpected summary
{
"skillSurface": {
"counts": {
"skills": 11,
"scenarios": 6,
"goldensPerProvider": 15,
"providers": 2,
"outputsPerProvider": 26,
"totalOutputs": 52
}
},
"totalOutputs": 52
}Inspect Validation Output
The validator emits structured JSON logs on stderr and a machine-readable result on stdout, even when validation fails.
node scripts/validate-workflow-skill-files.mjs > /tmp/workflow-skills-validate.json 2> /tmp/workflow-skills-validate.log || true
echo 'validation summary'
cat /tmp/workflow-skills-validate.json | jq '{ok, checked, summary}'
echo 'last 3 validator events'
tail -n 3 /tmp/workflow-skills-validate.log | jqNext Steps
- Read the Workflows and Steps guide to understand the runtime model
- See the Testing guide for writing workflow tests by hand
- Check the
@workflow/vitestAPI reference for the full list of test helpers