upstash-workflow
LobeHub Upstash Workflow and QStash guide. Use for async workflows, process/paginate/execute fan-out, serve handlers, context.run/call/sleep, or workflow triggers.
Security Assessment
About upstash-workflow
This skill is an internal implementation guide for building Upstash Workflow and QStash asynchronous workflows inside the LobeHub codebase. It codifies the three constraints the platform imposes on background processing — rate limits that make blind fan-out dangerous, per-workflow step limits, and idempotency requirements so retries never double-process — into a repeatable pattern so engineers do not rediscover them for every new job.
The guide describes a consistent three-layer architecture: a Layer 1 entry point (process-*) that validates prerequisites, counts eligible items, filters already-processed ones, and supports a dry-run mode that returns statistics without side effects; a Layer 2 pagination layer (paginate-*) that walks cursor-based pages and fans oversized batches into smaller chunks by recursively re-triggering itself; and a Layer 3 executor (execute-*/generate-*) that processes exactly one item per invocation with flowControl for parallelism and rate limiting. It supplies full TypeScript templates for the Workflow class and each route, plus reference files for implementation, cloud setup, best practices, and two real end-to-end examples (welcome-placeholder, agent-welcome).
The intended users are LobeHub contributors and TypeScript/Next.js engineers implementing durable background jobs on Upstash. Typical use cases include batch content generation, backfills, and any fan-out job that must respect step limits and stay idempotent. It is codebase-specific guidance rather than a general-purpose library, so its value is highest for people working directly in or closely mirroring the LobeHub server structure.
FAQ
What problem does this skill solve?
It gives a standard, idempotent way to build async fan-out workflows on Upstash Workflow + QStash, so batch jobs respect rate limits and per-workflow step limits without double-processing on retries.
What is the three-layer architecture?
Layer 1 (process-*) validates and counts work and supports dry-run; Layer 2 (paginate-*) handles cursor pagination and fans large batches into chunks; Layer 3 (execute-*/generate-*) performs the business logic for exactly one item per invocation.
What are the prerequisites?
A Next.js/TypeScript backend using @upstash/workflow, plus the environment variables QSTASH_TOKEN and APP_URL (optionally QSTASH_URL) to trigger workflows. The templates also assume a server database accessor.
What does dry-run mode do?
It short-circuits Layer 1 before any side effects and returns statistics such as how many items would be processed, letting callers preview a run before committing.
Is this reusable outside LobeHub?
The patterns are general, but the file paths, imports, and examples are specific to the LobeHub codebase, so it is most directly useful to contributors working in that structure.
Install upstash-workflow
Quick Setup:
- Copy the skill folder to
.claude/skills/ - Claude will automatically detect and use the skill
Repository
lobehub/lobehub