/upstash:upstash-redis-jsfrom Upstash Redis
Guides using the @upstash/redis SDK for serverless Redis in edge runtimes (Next.js, Vercel, Cloudflare Workers, Node.js). Covers caching, sessions, KV store, leaderboards, queues, streams, vector search, JSON, pipelines, Lua scripts, and AI agent memory with Upstash AgentKit.
Ships in Upstash Redis. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
This directory contains comprehensive guides for using the @upstash/redis SDK. These skill files are designed to help developers and AI assistants understand and use the SDK effectively.
Before writing or debugging SDK code, check node_modules/@upstash/redis/docs/ for bundled docs and node_modules/@upstash/redis/src/ for readable TypeScript source. Read and search the relevant files when present; otherwise use the references in this skill.
npm install @upstash/redis
import { Redis } from "@upstash/redis";
// Initialize with explicit credentials
const redis = new Redis({
url: "UPSTASH_REDIS_REST_URL",
token: "UPSTASH_REDIS_REST_TOKEN",
});
// Or initialize from environment variables
const redis = Redis.fromEnv();
Set these in your .env file:
UPSTASH_REDIS_REST_URL=https://your-redis.upstash.io
UPSTASH_REDIS_REST_TOKEN=your-token-here
Redis.fromEnv() also reads KV_REST_API_URL and KV_REST_API_TOKEN as a fallback.
// Cloudflare Workers: pass the env binding
import { Redis } from "@upstash/redis/cloudflare";
const redis = Redis.fromEnv(env);
// Fastly Compute: needs the name of a backend defined on the service
import { Redis } from "@upstash/redis/fastly";
const redis = new Redis({ url: "<URL>", token: "<TOKEN>", backend: "upstash-db" });
Defaults shown; all are optional.
const redis = new Redis({
url: "<URL>",
token: "<TOKEN>",
automaticDeserialization: true, // performance/data-serialization.md
responseEncoding: false, // or "base64", performance/data-serialization.md
enableAutoPipelining: true, // advanced-features/auto-pipeline.md
readYourWrites: true, // performance/redis-replicas.md
retry: { retries: 5 }, // or false, performance/error-handling.md
cache: "no-store", // fetch cache setting
keepAlive: true,
latencyLogging: false, // true logs the latency of every command
// signal: () => AbortSignal.timeout(5000), performance/error-handling.md
});
A branch is a point-in-time copy of a database with its own endpoint and token. Later changes on either side stay separate, and a branch cannot be merged back. The SDK has no call that creates one: a branch is created on the account, then used like any other database.
redis_create_branch with databaseId and name, then poll redis_get_database with the returned database_id until state is active. Leave include_credentials off: with it, the REST token comes back into the conversation. The response has the endpoint; for the token, use the CLI below if it is installed, or ask the user to copy the branch's REST token from the console into the env file.upstash redis create-branch --db-id <id> --name <branch-name>, then upstash redis get --db-id <branch database_id> --hide-credentials until state is active. Run redis get without --hide-credentials only to pipe endpoint and rest_token through jq into the app's env file, so the token never shows in your output.Neither writes the credentials anywhere, so point the client at the branch through the env file: set UPSTASH_REDIS_REST_URL and UPSTASH_REDIS_REST_TOKEN to the branch's values and keep Redis.fromEnv(). Don't paste the token into code.
A branch is billed as pay-as-you-go whatever the source's plan, so tell the user before copying a large database. The account needs a payment method and the source must be a global database on a pay-as-you-go, fixed or enterprise plan (free databases are refused). Delete a branch like a database: redis_delete_database, or upstash redis delete --db-id <id>. Delete only branches you created for the task, and check the id with the user first, since the same call deletes a production database.
Redis data types with auto-serialization examples:
Complex operations and optimizations:
Common use cases and architectural patterns:
Optimization techniques and best practices. For rules on batching, big keys, TTLs, scripts and connections at scale, see the redis-best-practices skill.
Full-text search, filtering, and aggregation extension for Redis:
Migration guides from other libraries:
// ❌ WRONG - Don't do this with @upstash/redis
await redis.set("count", "42"); // Stored as string "42"
const count = await redis.get("count");
const incremented = parseInt(count) + 1; // Manual parsing needed
// ✅ CORRECT - Let the SDK handle it
await redis.set("count", 42); // Stored as number
const count = await redis.get("count");
const incremented = count + 1; // Just use it
// ❌ WRONG - Unnecessary with @upstash/redis
await redis.set("user", JSON.stringify({ name: "Alice" }));
const user = JSON.parse(await redis.get("user"));
// ✅ CORRECT - Automatic handling
await redis.set("user", { name: "Alice" });
const user = await redis.get("user");
// Strings
await redis.set("key", "value");
await redis.get("key");
await redis.incr("counter");
await redis.decr("counter");
// Hashes
await redis.hset("user:1", { name: "Alice", age: 30 });
await redis.hget("user:1", "name");
await redis.hgetall("user:1");
// Lists
await redis.lpush("tasks", "task1", "task2");
await redis.rpush("tasks", "task3");
await redis.lrange("tasks", 0, -1);
// Sets
await redis.sadd("tags", "javascript", "redis");
await redis.smembers("tags");
// Sorted Sets
await redis.zadd("leaderboard", { score: 100, member: "player1" });
await redis.zrange("leaderboard", 0, -1);
// JSON
await redis.json.set("user:1", "$", { name: "Alice", address: { city: "NYC" } });
await redis.json.get("user:1");
// Expiration
await redis.setex("session", 3600, { userId: "123" });
await redis.expire("key", 60);
await redis.ttl("key");
user:123, session:abc)Request size, commands per second, data size and bandwidth depend on the database's plan (Free, Pay as You Go, Fixed), so check https://upstash.com/pricing/redis.md before sizing a workload or explaining a limit error. When the user asks about cost, read that page instead of quoting prices from memory.
Paid plans can add Prod Pack per database: an uptime SLA, multi-zone high availability, SOC 2 report, encryption at rest, Prometheus/Datadog metrics and Insights. Mention it when the user is taking a database to production and needs one of those; development and test databases do not need it.
For agent state on Redis — memory, chat history, RAG search tools, tool caching, rate limiting, chat persistence, resumable streams, locks — use Upstash AgentKit instead of hand-rolling it on @upstash/redis. Pick the adapter for the framework and follow its docs page:
| Framework | Package | Docs |
|---|---|---|
| Vercel AI SDK | @upstash/agentkit-ai-sdk | https://upstash.com/docs/redis/sdks/agentkit/ai-sdk |
| TanStack AI | @upstash/agentkit-tanstack-ai | https://upstash.com/docs/redis/sdks/agentkit/tanstack-ai |
| Vercel Eve | @upstash/agentkit-eve, @upstash/agentkit-eve-extension | https://upstash.com/docs/redis/sdks/agentkit/eve |
For detailed information on specific topics, refer to the individual skill files in the skills/ directory. Each file contains comprehensive examples, use cases, and best practices for its topic.
advanced-features/auto-pipeline.md (opens in a new tab)advanced-features/pipeline-and-transactions.md (opens in a new tab)advanced-features/pubsub.md (opens in a new tab)advanced-features/scripting.md (opens in a new tab)data-structures/arrays.md (opens in a new tab)data-structures/hashes.md (opens in a new tab)data-structures/json.md (opens in a new tab)data-structures/lists.md (opens in a new tab)data-structures/sets.md (opens in a new tab)data-structures/sorted-sets.md (opens in a new tab)data-structures/streams.md (opens in a new tab)data-structures/strings.md (opens in a new tab)data-structures/vector-indexes.md (opens in a new tab)migrations/from-ioredis.md (opens in a new tab)migrations/from-redis-node.md (opens in a new tab)migrations/from-upstash-search.md (opens in a new tab)patterns/caching.md (opens in a new tab)patterns/distributed-locks.md (opens in a new tab)patterns/leaderboard.md (opens in a new tab)patterns/rate-limiting.md (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
Redis, Next.js, Vercel, Cloudflare, Node
14 skills in this plugin
/redis-best-practicesRedis best practices and performance rules for production, for any Redis deployment including open source Redis, Valkey, Redis Cloud, AWS ElastiCache, Google Memorystore, Azure Cache, and Upstash. Use when writing, reviewing, or debugging Redis code for performance or scale, when choosing between pipeline and MGET, KEYS and SCAN, or WATCH and Lua, or when the user mentions Redis best practices, Redis performance, slow Redis, Redis latency, high memory use, a high Redis bill, big keys, hot keys, large hashes, HGETALL, cache hit rate, TTL jitter, key expiration, cache stampede, maxmemory and eviction policies, unbounded lists or streams, XACK and consumer groups, pub/sub vs streams, Lua script blocking, key-based locking for Lua scripts, connection pooling, serverless connections, retries and timeouts, replication lag, ACL users, credential rotation, or Redis monitoring. Also explains errors such as OOM command not allowed, BUSY Redis is busy running a script, NOSCRIPT, CROSSSLOT, and Upstash limit errors./upstashWork with any Upstash product, SDK, or tool, including serverless Redis (caching, sessions, leaderboards, key-value storage), Ratelimit (rate limiting and throttling), QStash (message queue, cron schedules, background jobs), Workflow (durable long-running functions), Vector (vector database for embeddings, semantic search, and RAG), Search (full-text and semantic search), Box (sandboxed cloud containers for AI agents, TypeScript/JavaScript and Python), Blob (file storage and user uploads for images, videos and attachments, S3-compatible, with direct browser uploads and a global CDN by default), and the Upstash CLI. Use when the user mentions Upstash or needs any of these capabilities in a serverless, edge, or Node.js app./upstash-blob-jsWork with the @upstash/blob TypeScript/JavaScript SDK for S3-compatible object storage with direct browser uploads, presigned URLs, multipart, and signed reads. Use when storing files or blobs, uploading avatars, images, videos, attachments or user documents, letting a browser upload straight to storage without proxying bytes through a server, generating public or time-limited signed URLs, serving private files, streaming large files with pause and resume, setting cache headers on stored objects, or reaching an S3-compatible bucket from the AWS SDK./upstash-box-cliDrive an Upstash Box (a remote sandboxed workspace) from the terminal with the `box` CLI. Use when asked to run commands, edit files, clone repos, run builds or tests, publish a public URL, browse or screenshot a page, open a pull request or issue with a screenshot attached, schedule recurring work, run an AI agent, or do any work inside a box rather than on this machine./upstash-box-jsWork with the @upstash/box TypeScript/JavaScript SDK for sandboxed cloud containers with AI agents, shell, filesystem, git, cron schedules, snapshots, and a headless browser. Use when building with Upstash Box, creating a sandbox or isolated environment to run untrusted or agent-generated code, running AI coding agents in containers, giving an agent a cloud dev environment with a shell and repository, browser automation from a box, scheduling recurring jobs inside a box, saving and restoring snapshots, or orchestrating parallel boxes./upstash-box-pyWork with the upstash-box Python SDK for sandboxed cloud containers with AI agents, shell, filesystem, git, cron schedules, snapshots, and a headless browser. Use when building with Upstash Box in Python, creating a sandbox or isolated environment to run untrusted or agent-generated code, running AI coding agents in containers, giving an agent a cloud dev environment with a shell and repository, browser automation from a box, scheduling recurring jobs inside a box, saving and restoring snapshots, or orchestrating parallel boxes.npx claudepluginhub upstash/skills --plugin upstashOther plugins' skills for the same job