upstash
Assists with building serverless applications using Upstash Redis, QStash, Workflow, and Vector. Use when adding caching, rate limiting, message queues, durable workflows, or vector search to edge and serverless applications. Trigger words: upstash, serverless redis, rate limiting, qstash, upstash workflow, upstash vector.
Usage
Getting Started
- Install the skill using the command above
- Open your AI coding agent (Claude Code, Codex, Gemini CLI, or Cursor)
- Reference the skill in your prompt
- The AI will use the skill's capabilities automatically
Example Prompts
- "Analyze the sales data in revenue.csv and identify trends"
- "Create a visualization comparing Q1 vs Q2 performance metrics"
Documentation
Overview
Upstash provides serverless Redis, message queues (QStash), durable workflows, and vector databases via HTTP-based APIs that work in edge runtimes where TCP connections are unavailable. It offers pay-per-request pricing with scale-to-zero, making it ideal for Cloudflare Workers, Vercel Edge Functions, and Deno Deploy.
Instructions
- When setting up Redis, use
Redis.fromEnv()to read connection credentials from environment variables, and usepipeline()for batching 3+ commands into a single HTTP request. - When implementing rate limiting, use
@upstash/ratelimitwith the appropriate algorithm (fixed window, sliding window, or token bucket) and custom identifiers (IP, API key, user ID). - When adding caching, use
@upstash/cachewith stale-while-revalidate patterns and set explicit TTLs on all cached data to prevent unbounded growth. - When building async task processing, use QStash (
@upstash/qstash) to publish messages to URL endpoints with automatic retries, exponential backoff, and dead letter queues. - When creating multi-step workflows, use
@upstash/workflowto break long tasks into resumable steps that can span multiple serverless invocations, withcontext.sleep()for delays. - When adding AI/RAG features, use
@upstash/vectorfor serverless vector storage with metadata filtering and namespace support for multi-tenant applications. - When configuring for global read performance, enable Redis read replicas in multiple regions; writes always go to the primary region.
Examples
Example 1: Add rate limiting to an API
User request: "Implement rate limiting for my API endpoints on Vercel Edge"
Actions:
- Install
@upstash/ratelimitand@upstash/redis - Create a rate limiter with sliding window algorithm (e.g., 10 requests per 10 seconds)
- Identify requests by IP address or API key
- Return 429 status with retry-after header when limit is exceeded
Output: Production-ready rate limiting that works across edge locations with consistent enforcement.
Example 2: Build a durable email workflow
User request: "Create a multi-step onboarding email sequence using serverless functions"
Actions:
- Define workflow steps with
@upstash/workflowfor each email in the sequence - Use
context.sleep("wait-24h", 86400)between emails without holding compute - Add conditional logic for user engagement tracking between steps
- Configure automatic retries on step failure
Output: A durable workflow that sends timed emails across days, surviving serverless timeouts and restarts.
Guidelines
- Always use
Redis.fromEnv(); never hardcode connection URLs in source code. - Use
pipeline()when executing 3+ Redis commands to reduce HTTP round trips. - Set explicit TTLs on all cached data; unbounded caches grow until they hit memory limits.
- Use
@upstash/ratelimitover hand-rolled rate limiting; it handles race conditions and multi-region consistency. - Prefer QStash over direct HTTP calls for async tasks; it handles retries, timeouts, and dead letters.
- Use
@upstash/workflowfor multi-step tasks that exceed serverless time limits. - Enable read replicas for read-heavy workloads; writes go to the primary region.
Information
- Version
- 1.0.0
- Author
- terminal-skills
- Category
- Data & AI
- License
- Apache-2.0