upstash-workflow

Implements Upstash Workflow and QStash handlers with three-layer fan-out architecture for async batch processing.

Updated Jan 27, 2026
One-click install
npx skills add https://github.com/SmallAi-API/smaihub --skill upstash-workflow-smallai-api
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: upstash-workflow
Source: https://github.com/SmallAi-API/smaihub/tree/main/.agents/skills/upstash-workflow
Command: npx skills add https://github.com/SmallAi-API/smaihub --skill upstash-workflow-smallai-api

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires @upstash/workflow, and includes references (resource) components.

What problem does it solve? Building durable async workflows with Upstash Workflow and QStash requires handling rate limits, step limits, and idempotent retries, and ad-hoc implementations often duplicate work or lose data when fanning out large batches. ## Core Features & Use Cases - Three-Layer Architecture: Standardizes workflows into an entry point (process-), pagination layer (paginate-), and single-item execution layer (execute-/generate-). - Dry-Run Mode: Preview statistics on how many items would be processed before triggering any side effects. - Fan-Out Pattern: Splits oversized batches into chunks (CHUNK_SIZE=20) and recursively re-triggers pagination to stay within workflow step limits. - Use Case: Generate AI welcome placeholders for thousands of users by paginating through the database, filtering already-cached users in Redis, and executing one user per workflow invocation with tuned flowControl parallelism. ## Quick Start Use the upstash-workflow skill to scaffold a new three-layer Upstash Workflow that processes agents with dry-run support and fan-out pagination.

Frequently Asked Questions about upstash-workflow

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I structure an Upstash Workflow for batch processing?

Use a three-layer architecture: a process-* entry point that validates and filters items, a paginate-* layer that handles cursor pagination and fan-out, and an execute-* layer that processes exactly one item per invocation. Each layer is a separate Next.js route using serve() from @upstash/workflow/nextjs.

How to avoid hitting Upstash Workflow step limits with large batches?

Use the fan-out pattern in the pagination layer: when a page exceeds CHUNK_SIZE (default 20), split it into chunks and recursively re-trigger the paginate route with each chunk's itemIds. This distributes work across multiple workflow invocations instead of one oversized run.

Why does context.run lose data when processing multiple items in parallel?

Upstash deduplicates steps by name, so reusing the same step name inside Promise.all causes data loss. Give each step a unique name like `workflow:execute:${item.id}` so every item's result is recorded separately.

What flowControl settings should each workflow layer use?

Set the entry point to parallelism 1 and ratePerSecond 1 to prevent duplicate batch triggers, pagination to parallelism 10-20, and execution to parallelism 5-10 depending on downstream API rate limits. Each layer uses a distinct flowControl key.

Can I reuse open-source workflows in a cloud Next.js deployment?

Yes, create re-export route files in the cloud project that export POST from the lobehub/src path rather than the @/ alias. Using the @/ alias causes circular import errors, while the direct package path resolves correctly.

How do I test an Upstash Workflow before full rollout?

Trigger the entry point with dryRun: true to get statistics on eligible and already-processed items without side effects. Then run a small batch, verify idempotent filtering skips processed items, and write integration tests covering both the dry-run and full execution paths.