skills/redis-caching/SKILL.md
Redis caching, rate limiting, session storage, pub/sub, and production integration patterns for TypeScript, Next.js, NestJS, and Prisma applications. Use when adding cache-aside or write-through caching, rate limiting, session or lock storage, pub/sub fanout, or reviewing Redis key design and TTLs.
npx skillsauth add shipshitdev/library redis-cachingInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Implement Redis as a production support layer, not as a second database.
For BullMQ job queue architecture, use nestjs-queue-architect instead of duplicating queue patterns here.
ioredis.nestjs-queue-architect.app:env:entity:id:variant.bun add ioredis
# Optional serverless Redis
bun add @upstash/redis @upstash/ratelimit
Use one Redis client per process (a module-level singleton guarded against
hot-reload duplication). Do not create a new TCP client per request. Wire
error, connect, and reconnecting events into the app logger or APM. Avoid
logging credentials from connection URLs.
See references/examples.md (§ Redis Client Singleton) for the full setup.
Use cache-aside for reads where brief staleness is acceptable: check the
cache, on miss call the loader, write back with a jittered TTL (baseTtl + random(0, jitter)) so hot keys don't all expire in the same instant.
See references/examples.md (§ Cache-Aside With Prisma) for the getCached
helper and a Prisma-backed usage example.
Protect hot keys with a short SET key val EX 10 NX lock. Only the holder
(matched by a random token) releases it; losers wait briefly and re-check the
cache before falling through to a direct load.
See references/examples.md (§ Stampede Protection) for the full
lock-and-release implementation.
Prefer direct invalidation for known keys. Use tag sets (a Redis set per tag,
mapping to the keys written under it) when one mutation affects many keys —
write through a pipeline, invalidate by reading the tag's key set and
UNLINK-ing them. Use SCAN instead of KEYS for emergency pattern cleanup.
Do not put pattern invalidation on hot request paths.
See references/examples.md (§ Tag-Based Invalidation) for the
cacheSetWithTags / invalidateTag implementation.
Use sorted sets for sliding-window limits when exactness matters: trim
expired entries, add the current request, count members, and set the key's
expiry — all in one MULTI. For public traffic, set response headers:
X-RateLimit-Limit, X-RateLimit-Remaining, and Retry-After.
See references/examples.md (§ Sliding-Window Rate Limiting) for the full
slidingWindowRateLimit implementation.
See references/examples.md (§ Session Storage) for a createSession example.
KEYS, unbounded SMEMBERS, or large HGETALL.development
TypeScript refactoring and modernization guidelines from a principal specialist perspective. This skill should be used when refactoring, reviewing, or modernizing TypeScript code to ensure type safety, compiler performance, and idiomatic patterns. Triggers on tasks involving TypeScript type architecture, narrowing, generics, error handling, or migration to modern TypeScript features.
tools
Resolves TypeScript and JavaScript problems across type-level programming, performance, monorepo management, migration, and modern tooling. Invoke when diagnosing "type instantiation excessively deep" errors, migrating JS to TS, configuring strict tsconfig, debugging module resolution, or choosing between Biome/ESLint/Turborepo/Nx.
tools
Turborepo monorepo build system guidance. Triggers on: `turbo.json`, task pipelines, `dependsOn`, caching, remote cache, the `turbo` CLI, `--filter`, `--affected`, CI optimization, environment variables, internal packages, monorepo structure, and package boundaries. Use when the user configures tasks or workflows, creates packages, sets up a monorepo, shares code between apps, runs changed packages, debugs cache behavior, or works in an `apps/` plus `packages/` workspace.
tools
Provides Tailwind CSS v4 performance optimization and best practices guidelines. Triggers when writing, reviewing, or refactoring Tailwind CSS v4 code; when working with Tailwind configuration, @theme directive, utility classes, responsive design, dark mode, container queries, or CSS generation optimization.