redis-safety

Enforces Redis safety rules covering SCAN usage, TTL requirements, and pipeline batching.

1.0k|109|Updated Jan 4, 2026
One-click install
npx skills add https://github.com/doccker/cc-use-exp --skill redis-safety
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: redis-safety
Source: https://github.com/doccker/cc-use-exp/tree/main/.cursor/skills/redis-safety
Command: npx skills add https://github.com/doccker/cc-use-exp --skill redis-safety

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Redis misuse such as blocking KEYS commands, missing TTLs, oversized values, and unbatched calls causes production outages and memory leaks. This Skill gives AI coding assistants concrete rules to prevent these failures when writing or reviewing Redis code.

Core Features & Use Cases

  • Blocking Command Prevention: Bans KEYS, FLUSHDB, and FLUSHALL, replacing them with cursor-based SCAN iteration in Go, Java, and Python.
  • Memory and Size Controls: Enforces mandatory TTL on every key and caps values at 10KB or 5000 collection elements.
  • Batch Operation Optimization: Converts loops of single Redis calls into Pipeline executions to reduce network round trips.
  • Use Case: When asking an AI assistant to write a token caching layer with go-redis, the generated code automatically uses SCAN instead of KEYS, sets a 24-hour TTL, and batches reads through a Pipeline.

Quick Start

Review my Redis code and rewrite any KEYS calls, missing TTLs, or unbatched loops according to the redis-safety rules.

Frequently Asked Questions about redis-safety

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I replace Redis KEYS with SCAN in production code?

Replace KEYS with cursor-based SCAN iteration that processes keys in batches of 100. In go-redis loop rdb.Scan until the cursor returns 0, in Jedis use ScanParams with match and count, and in redis-py use scan_iter with a match pattern.

Why is the Redis KEYS command dangerous in production?

KEYS is an O(N) blocking operation that scans the entire keyspace, freezing Redis on large databases and causing timeouts. SCAN iterates incrementally with a cursor, spreading the work across many small non-blocking calls.

How do I batch multiple Redis GET calls efficiently?

Use a Pipeline to send multiple commands in one network round trip instead of calling GET in a loop. In go-redis, create rdb.Pipeline(), queue each Get call, then execute them together with pipe.Exec(ctx).

Does this Redis guidance work with Jedis and redis-py?

Yes, the rules apply across go-redis, Jedis, redis-py, and ioredis with language-specific examples provided. SCAN usage, TTL enforcement, and pipeline batching are supported by all four clients.

What are the size limits for Redis keys and collections?

A single key value should stay under 10KB, and collection types like List, Set, Hash, and ZSet should hold no more than 5000 elements. Larger data should be split across multiple keys to avoid slow operations and memory pressure.