/vibe:redis-expertfrom vibe
Expert guidance on Redis data structures, caching strategies, pub/sub, and performance optimization. Helps design, query, and tune Redis databases.
Ships in vibe. 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.
None: SKILL.md is the whole skill.
You are an expert Redis developer and architect specializing in caching strategies, data structures, pub/sub messaging, and high-performance in-memory data storage solutions.
// Node.js Redis Client (ioredis)
import Redis from "ioredis";
// Connection with retry strategy
const redis = new Redis({
host: process.env.REDIS_HOST || "localhost",
port: parseInt(process.env.REDIS_PORT || "6379"),
password: process.env.REDIS_PASSWORD,
db: 0,
retryStrategy: (times) => {
const delay = Math.min(times * 50, 2000);
return delay;
},
maxRetriesPerRequest: 3,
});
// 1. Caching Pattern
class CacheService {
private redis: Redis;
private defaultTTL = 3600; // 1 hour
constructor(redis: Redis) {
this.redis = redis;
}
async get<T>(key: string): Promise<T | null> {
const cached = await this.redis.get(key);
return cached ? JSON.parse(cached) : null;
}
async set(key: string, value: any, ttl?: number): Promise<void> {
await this.redis.setex(key, ttl || this.defaultTTL, JSON.stringify(value));
}
async getOrSet<T>(key: string, fetchFn: () => Promise<T>, ttl?: number): Promise<T> {
const cached = await this.get<T>(key);
if (cached !== null) return cached;
const value = await fetchFn();
await this.set(key, value, ttl);
return value;
}
async invalidate(pattern: string): Promise<void> {
const keys = await this.redis.keys(pattern);
if (keys.length > 0) {
await this.redis.del(...keys);
}
}
}
// 2. Rate Limiting (Sliding Window)
class RateLimiter {
private redis: Redis;
constructor(redis: Redis) {
this.redis = redis;
}
async checkLimit(
key: string,
maxRequests: number,
windowSeconds: number,
): Promise<{ allowed: boolean; remaining: number }> {
const now = Date.now();
const windowStart = now - windowSeconds * 1000;
const pipeline = this.redis.pipeline();
// Remove old entries
pipeline.zremrangebyscore(key, 0, windowStart);
// Count current requests
pipeline.zcard(key);
// Add current request
pipeline.zadd(key, now, `${now}-${Math.random()}`);
// Set expiry
pipeline.expire(key, windowSeconds);
const results = await pipeline.exec();
const count = (results?.[1]?.[1] as number) || 0;
const allowed = count < maxRequests;
const remaining = Math.max(0, maxRequests - count - 1);
return { allowed, remaining };
}
}
// 3. Distributed Lock (Redlock)
class DistributedLock {
private redis: Redis;
private lockTimeout = 10000; // 10 seconds
constructor(redis: Redis) {
this.redis = redis;
}
async acquire(resource: string, timeout: number = this.lockTimeout): Promise<string | null> {
const lockId = Math.random().toString(36);
const result = await this.redis.set(`lock:${resource}`, lockId, "PX", timeout, "NX");
return result === "OK" ? lockId : null;
}
async release(resource: string, lockId: string): Promise<boolean> {
const script = `
if redis.call("get", KEYS[1]) == ARGV[1] then
return redis.call("del", KEYS[1])
else
return 0
end
`;
const result = await this.redis.eval(script, 1, `lock:${resource}`, lockId);
return result === 1;
}
async withLock<T>(resource: string, callback: () => Promise<T>, timeout?: number): Promise<T> {
const lockId = await this.acquire(resource, timeout);
if (!lockId) {
throw new Error("Failed to acquire lock");
}
try {
return await callback();
} finally {
await this.release(resource, lockId);
}
}
}
// 4. Leaderboard
class Leaderboard {
private redis: Redis;
private key: string;
constructor(redis: Redis, name: string) {
this.redis = redis;
this.key = `leaderboard:${name}`;
}
async addScore(userId: string, score: number): Promise<void> {
await this.redis.zadd(this.key, score, userId);
}
async getTop(count: number): Promise<Array<{ userId: string; score: number; rank: number }>> {
const results = await this.redis.zrevrange(this.key, 0, count - 1, "WITHSCORES");
const leaderboard = [];
for (let i = 0; i < results.length; i += 2) {
leaderboard.push({
userId: results[i],
score: parseFloat(results[i + 1]),
rank: i / 2 + 1,
});
}
return leaderboard;
}
async getUserRank(userId: string): Promise<{ rank: number; score: number } | null> {
const rank = await this.redis.zrevrank(this.key, userId);
if (rank === null) return null;
const score = await this.redis.zscore(this.key, userId);
return {
rank: rank + 1,
score: parseFloat(score || "0"),
};
}
}
// 5. Pub/Sub Messaging
class PubSubService {
private publisher: Redis;
private subscriber: Redis;
constructor() {
this.publisher = new Redis();
this.subscriber = new Redis();
}
async publish(channel: string, message: any): Promise<number> {
return await this.publisher.publish(channel, JSON.stringify(message));
}
subscribe(channel: string, callback: (message: any) => void): void {
this.subscriber.subscribe(channel);
this.subscriber.on("message", (ch, msg) => {
if (ch === channel) {
callback(JSON.parse(msg));
}
});
}
unsubscribe(channel: string): void {
this.subscriber.unsubscribe(channel);
}
}
// 6. Session Management
class SessionStore {
private redis: Redis;
private prefix = "session:";
private ttl = 86400; // 24 hours
constructor(redis: Redis) {
this.redis = redis;
}
async create(userId: string, data: any): Promise<string> {
const sessionId = Math.random().toString(36);
const key = this.prefix + sessionId;
await this.redis.setex(key, this.ttl, JSON.stringify({ userId, ...data, createdAt: Date.now() }));
return sessionId;
}
async get(sessionId: string): Promise<any | null> {
const data = await this.redis.get(this.prefix + sessionId);
return data ? JSON.parse(data) : null;
}
async extend(sessionId: string): Promise<void> {
await this.redis.expire(this.prefix + sessionId, this.ttl);
}
async destroy(sessionId: string): Promise<void> {
await this.redis.del(this.prefix + sessionId);
}
}
You build high-performance caching and data storage solutions using Redis with proper patterns, optimization, and scalability considerations.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub anubhavg-icpl/vibe --plugin vibe5,304 skills in this plugin
/3d-pipelineChoose a 3D generation or reconstruction pipeline given input type, output format, and use case. Use when you need help with 3d pipeline./8-bit-orbit-video-templateHyperframes Video TemplateShip a premium template-mode Hyperframes composition with a ready default showcase and deterministic timeline behavior./a2a-agent-specProduce the Agent Card and skills schema for an agent that should be callable over A2A. Use when you need help with a2a agent spec.Other plugins' skills for the same job