Redis
Use when the project uses Redis/Valkey/Upstash — caching, sessions, rate limiting, queues (BullMQ, Sidekiq, Celery), pub/sub, leaderboards, locks — or diagnosing stampedes and eviction.From its SKILL.md
npx -y skills add muxammadmamajonov/dot-claude --skill redisAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
SKILL.md
5.7 KB, ~1.4k tokens by cl100k_base, as published. Nobody here has run it
Redis Skill
When to use
- Adding a caching layer in front of a database, API, or expensive computation
- Implementing distributed rate limiting, session storage, or idempotency keys
- Designing a job queue with BullMQ (Node), Celery (Python), Sidekiq (Ruby), or Resque
- Setting up Redis pub/sub or Redis Streams for event fan-out
- Diagnosing high memory usage, eviction storms, or hot-key contention
- Building leaderboards, counters, or sliding-window analytics with sorted sets
Workflow
- Choose the right data structure first — string for simple cache values, hash for objects with partial updates, sorted set for leaderboards/rate-limit windows, list for FIFO queues, stream for event logs with consumer groups.
- Define a key naming convention before writing any code:
<app>:<entity>:<id>:<field>e.g.api:user:abc123:session. Document it in aredis-keys.mdor inline comment. - Set TTL on every cache key — call
SET key value EX <seconds>orEXPIRE key <seconds>. Never store a key without a TTL unless it is a permanent registry (leaderboard, session index). - Implement cache-aside pattern:
a. Try
GET key. b. On miss: fetch from source,SET key value EX <ttl>, return value. c. On hit: return cached value. Use a short jitter on TTL (±10%) to prevent stampedes on mass-expiry. - For queues: use BullMQ (Node), Celery + Redis broker (Python), or Sidekiq (Ruby). Define job retry count, backoff strategy, and dead-letter queue before deploying workers.
- For distributed locks: use the Redlock algorithm (
ioredis-lock,redlocknpm,potteryPython) — not rawSETNX. Always set a lock expiry shorter than the expected operation duration + safety margin. - Monitor: check
INFO memory,INFO stats,SLOWLOG GET 25, andMONITOR(briefly, in dev only). Setmaxmemoryandmaxmemory-policyinredis.conf;allkeys-lruis the safest default for pure cache deployments. - Connection pooling: use a shared client instance (singleton) per process; never create a new connection per request. Configure
maxRetriesPerRequestand connection timeouts.
Standards
Do
- Use pipelining (
MULTI/EXECor client pipeline API) when issuing 3+ sequential commands in one logical operation. - Prefix all keys with an environment namespace (
prod:,staging:) when sharing a Redis instance across environments. - Use
SCANinstead ofKEYS *in production —KEYSblocks the event loop. - Store large values as compressed JSON (zstd or gzip) to reduce memory and network overhead.
- Set
requirepassand TLS in production; use ACL rules to limit each service to only the key prefixes it owns. - Use Redis Streams (not pub/sub) when message delivery durability is required — pub/sub drops messages when there are no subscribers.
Do not
- Do not use Redis as a primary database for business-critical data — treat it as an ephemeral store.
- Do not store secrets, PII, or payment card data in Redis unless the instance is encrypted at rest and access is tightly ACL-controlled.
- Do not use blocking commands (
BLPOP,BRPOP) in the same connection used for non-blocking operations — they can starve other requests. - Do not store values larger than 10 MB in a single key; this causes latency spikes for all clients sharing the instance.
- Do not use
FLUSHDB/FLUSHALLin any automated script without an explicit human approval gate. - Do not issue
MONITORin production beyond short diagnostic windows — it can double Redis CPU load.
Common mistakes to avoid
| Mistake | Consequence | Fix |
|---|---|---|
| No TTL on cache keys | Memory fills up; old data served forever | Always pass EX or PX in SET; audit with TTL <key> |
| Cache stampede on popular key expiry | Hundreds of DB queries simultaneously | Add random jitter to TTL; use a probabilistic early refresh (XFetch pattern) |
Using KEYS * in production | Blocks Redis for seconds on large keyspaces | Replace with SCAN 0 MATCH prefix:* COUNT 100 with a cursor loop |
| One Redis connection per HTTP request | Connection exhaustion | Use a singleton client with a connection pool |
| Storing entire ORM objects in cache | Stale nested objects; large serialization overhead | Cache only IDs or slim DTOs; rebuild the full object from DB on cache miss |
| Pub/sub for reliable task delivery | Worker restart drops in-flight messages | Use Redis Streams with XREADGROUP and XACK for at-least-once delivery |
Not setting maxmemory-policy | Redis fills RAM, crashes, or starts refusing writes | Set maxmemory 512mb + maxmemory-policy allkeys-lru in config |
Output format
Client setup (Node / ioredis):
// lib/redis.ts — singleton pattern
import Redis from "ioredis";
const redis = new Redis(process.env.REDIS_URL!, {
maxRetriesPerRequest: 3,
enableReadyCheck: true,
lazyConnect: false,
});
export default redis;
Cache-aside helper:
async function cached<T>(key: string, ttlSeconds: number, fetch: () => Promise<T>): Promise<T> {
const hit = await redis.get(key);
if (hit) return JSON.parse(hit) as T;
const value = await fetch();
await redis.set(key, JSON.stringify(value), "EX", ttlSeconds + Math.floor(Math.random() * 30));
return value;
}
Related checklists
.claude/checklists/performance.md.claude/checklists/security.md.claude/checklists/devops.md
Related agents
.claude/agents/engineering/backend-engineer.md.claude/agents/quality/performance-engineer.md.claude/agents/engineering/infrastructure-engineer.md
What ships with it
Read from the repository
Just SKILL.md. No reference files, no scripts.