From upstash
Guides usage of the @upstash/redis SDK for serverless Redis: caching, session storage, rate limiting, leaderboards, full-text search, and all Redis data structures with auto-serialization.
How this skill is triggered — by the user, by Claude, or both
Slash command
/upstash:upstash-redis-jsThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
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.
advanced-features/auto-pipeline.mdadvanced-features/pipeline-and-transactions.mdadvanced-features/scripting.mddata-structures/hashes.mddata-structures/json.mddata-structures/lists.mddata-structures/sets.mddata-structures/sorted-sets.mddata-structures/streams.mddata-structures/strings.mdmigrations/from-ioredis.mdmigrations/from-redis-node.mdpatterns/caching.mdpatterns/distributed-locks.mdpatterns/leaderboard.mdpatterns/rate-limiting.mdpatterns/session-management.mdperformance/batching-operations.mdperformance/data-serialization.mdperformance/error-handling.mdThis 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.
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
No credentials yet? If you're an agent that needs scratch Redis and the user hasn't provided a database, you can mint a temporary one with a single POST to
https://upstash.com/start-redis(3-day TTL, no signup).
Redis data types with auto-serialization examples:
Complex operations and optimizations:
Common use cases and architectural patterns:
Optimization techniques and best practices:
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)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.
Guides creation, editing, and verification of skills for AI coding agents using test-driven development with subagent scenarios. Use when authoring or debugging skills.
npx claudepluginhub upstash/skills --plugin upstash