Skip to content
Back to skills

Workflow Johnlindquist

BSecurity

Creates durable, resumable workflows using Vercel's Workflow DevKit. Use when building workflows that need to survive restarts, pause for external events, retry on failure, or coordinate multi-step operations over time. Triggers on mentions of "workflow", "durable functions", "resumable", "workflow devkit", or step-based orchestration.

  • 57 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added May 31, 2026
developmenttypescriptbashnextjsnodeexpressgitapi

Works with

  • api

Security analysis

B88/100
  • mediumInstalls packages at runtime which could introduce malicious dependencies
  • mediumInstalls packages at runtime which could introduce malicious dependencies
  • mediumInstalls packages at runtime which could introduce malicious dependencies

Pro shows the line behind each finding and how to fix it

Scanned May 31, 2026

npx -y skills add diegosouzapw/awesome-omni-skill --skill workflow --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Workflow Johnlindquist?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Workflow Johnlindquist
[![Security: B — Skills Directory](https://www.skillsdirectory.com/api/skills/diegosouzapw-workflow-johnlindquist/badge)](https://www.skillsdirectory.com/skills/diegosouzapw-workflow-johnlindquist)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: workflow
description: Creates durable, resumable workflows using Vercel's Workflow DevKit. Use when building workflows that need to survive restarts, pause for external events, retry on failure, or coordinate multi-step operations over time. Triggers on mentions of "workflow", "durable functions", "resumable", "workflow devkit", or step-based orchestration.
---

# Workflow DevKit

TypeScript framework for building durable, resumable functions. Workflows survive crashes, deployments, and can pause for days/months.

**Website:** https://useworkflow.dev | **GitHub:** https://github.com/vercel/workflow

## Installation

```bash
npm i workflow
# or: pnpm add workflow | yarn add workflow | bun add workflow
```

## Core Concepts

### Directives

```typescript
"use workflow";  // First line - makes async function durable
"use step";      // First line - makes function a cached, retryable unit
```

### Workflow Function

Orchestrates steps, survives restarts, replays deterministically:

```typescript
import { sleep } from "workflow";

export async function onboardUser(email: string) {
  "use workflow";

  const user = await createUser(email);      // Step 1
  await sendWelcomeEmail(user);              // Step 2
  await sleep("3 days");                     // Pause (no resources consumed)
  await sendFollowupEmail(user);             // Step 3
  return { userId: user.id };
}
```

### Step Function

Has full Node.js access, auto-retries on failure:

```typescript
async function createUser(email: string) {
  "use step";
  return await db.users.create({ email });
}
```

## Essential APIs

### sleep - Pause Workflow

```typescript
import { sleep } from "workflow";

await sleep("5s");      // 5 seconds
await sleep("10m");     // 10 minutes
await sleep("1h");      // 1 hour
await sleep("7 days");  // 7 days
await sleep(5000);      // milliseconds
await sleep(new Date("2025-01-01")); // specific date
```

### createHook - Wait for External Input

```typescript
import { createHook } from "workflow";

const hook = createHook<{ approved: boolean }>();
console.log("Token:", hook.token);  // Send to external system
const result = await hook;          // Pauses until resumed
```

Resume externally:
```typescript
import { resumeHook } from "workflow/api";
await resumeHook(token, { approved: true });
```

### createWebhook - HTTP Callback Endpoint

```typescript
import { createWebhook } from "workflow";

const webhook = createWebhook();
await sendToExternalService(webhook.url);  // Auto-generated URL
const request = await webhook;              // Pauses until HTTP POST
const data = await request.json();
```

### start - Trigger Workflow

```typescript
import { start } from "workflow/api";

const run = await start(onboardUser, ["user@example.com"]);
console.log(run.runId);  // Returns immediately
```

### Error Handling

```typescript
import { FatalError, RetryableError } from "workflow";

// Stop retries permanently
throw new FatalError("User not found");

// Retry with delay
throw new RetryableError("Rate limited", { retryAfter: "5m" });
```

## Fetch in Workflows

Workflows run sandboxed. Import fetch from workflow:

```typescript
import { fetch } from "workflow";

export async function myWorkflow() {
  "use workflow";
  globalThis.fetch = fetch;  // Enable for libraries (AI SDK)

  const response = await fetch("https://api.example.com/data");
}
```

## Streaming (Steps Only)

```typescript
import { getWritable } from "workflow";

async function streamData(items: string[]) {
  "use step";
  const writer = getWritable();
  for (const item of items) {
    await writer.write({ item });
  }
  writer.releaseLock();
}
```

## Idempotency

Use stepId for external API calls:

```typescript
import { getStepMetadata } from "workflow";

async function chargeCard(amount: number) {
  "use step";
  const { stepId } = getStepMetadata();
  await stripe.charges.create(
    { amount },
    { idempotencyKey: `charge:${stepId}` }
  );
}
```

## What Cannot Be Serialized

- Functions/callbacks - define logic in steps
- Class instances with methods - use plain objects
- Symbols, WeakMap, WeakSet
- Node.js modules (fs, http, crypto) - use in steps only

## Run Status

`pending | running | completed | failed | cancelled`

## References

- **Framework Setup:** See [frameworks.md](references/frameworks.md) for Next.js, Express, Hono, Vite, Astro, Fastify, Nitro, Nuxt, SvelteKit
- **AI Agents:** See [ai-agents.md](references/ai-agents.md) for DurableAgent and streaming patterns
- **Advanced Patterns:** See [patterns.md](references/patterns.md) for hooks, webhooks, control flow
- **Common Errors:** See [errors.md](references/errors.md) for troubleshooting
- **API Reference:** See [api-reference.md](references/api-reference.md) for complete API

## Quick Checklist

- [ ] Add `"use workflow"` as first line of workflow function
- [ ] Add `"use step"` as first line of step functions
- [ ] Import `fetch` from `workflow` and assign to `globalThis.fetch`
- [ ] Use `sleep()` instead of setTimeout
- [ ] Move Node.js module usage to step functions
- [ ] Use `FatalError` for permanent failures, `RetryableError` for retries
- [ ] Configure framework (withWorkflow, nitro module, etc.)

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.