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:

CommandWhat it builds
/workflow-approvalApproval with expiry, escalation, and deterministic hooks
/workflow-webhookExternal webhook ingestion with duplicate handling and compensation
/workflow-sagaPartial-success side effects and compensation
/workflow-timeoutCorrectness depends on sleep/wake-up behavior
/workflow-idempotencyRetries and replay can duplicate effects
/workflow-observeOperators 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 status

Review Existing Workflows

When you already have workflow code and need to assess correctness before changing it, run:

/workflow-audit

For 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

StageCommandPurposeOutput
1/workflow-teachCapture project context.workflow.md
2/workflow-buildBuild workflow code interactivelyTypeScript 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), and workflow-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), and workflow-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 before workflow is installed as a dependency)

Teach Your Project Context

Run /workflow-teach to start an interactive interview that captures your project's domain knowledge:

/workflow-teach

The 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-build

For 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:

  1. Propose step boundaries — which functions need "use workflow" vs "use step", suspension points, stream requirements
  2. Flag relevant traps — run a 12-point stress checklist against the design
  3. Decide failure modesFatalError vs RetryableError, idempotency strategies, compensation plans
  4. Write code + tests — produce the workflow file and integration tests
  5. Self-review — run the stress checklist again against the generated code
  6. Verification summary — emit a structured verification artifact and a single-line verification_plan_ready event for machine consumption

Each phase waits for your confirmation before proceeding.

Persisted Artifacts

The skill loop produces two categories of artifacts:

CategoryArtifactPathOwner
Skill-managedProject context.workflow.mdworkflow-teach
Host-managedProject context (JSON).workflow-skills/context.jsonHost runtime
Host-managedWorkflow blueprint.workflow-skills/blueprints/<name>.jsonHost runtime
Host-managedVerification plan.workflow-skills/verification/<name>.jsonHost 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 from workflow-teach
  • blueprints/<name>.json — workflow blueprint with step boundaries, suspension points, and trap analysis
  • verification/<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:

SectionContents
Project ContextWhat the project does and why it needs durable workflows
Business RulesInvariants, idempotency requirements, domain constraints
External SystemsThird-party services, trigger surfaces, rate limits
Failure ExpectationsPermanent vs retryable failures, timeouts, compensation rules
Observability NeedsWhat operators and UIs need to see
Approved PatternsAnti-patterns relevant to this project's workflow surfaces
Open QuestionsGaps 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:

PatternHow It Appears
Human-in-the-loop approvalManager and director hooks
Timeout handling48h and 24h sleep suspensions
Escalation logicPromise.race between hook and sleep
IdempotencyEvery side-effecting step has an idempotency key
Deterministic tokensHook tokens derived from the PO number
ObservabilityOperator 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:

  1. Determinism boundary
  2. Step granularity
  3. Pass-by-value / serialization
  4. Hook token strategy
  5. Webhook response mode
  6. start() placement
  7. Stream I/O placement
  8. Idempotency keys
  9. Retry semantics
  10. Rollback / compensation
  11. Observability streams
  12. 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 | jq

Expected 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.ts

Expected 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 | jq

Next Steps