
Redis Clustering
Design and run Redis Cluster safely with hash tags, slot-aware multi-key ops, and replica reads.
Overview
redis-clustering is an agent skill most often used in Operate (also Build backend, Build integrations) that teaches hash tags, slot-safe multi-key operations, and replica-aware Redis Cluster usage.
Install
npx skills add https://github.com/redis/agent-skills --skill redis-clusteringWhat is this skill?
- Hash tag pattern ({user:1001}) to co-locate keys on one slot for pipelines and transactions
- Multi-key command guidance to avoid CROSSSLOT errors in Redis Cluster
- Python redis-py and Java Jedis examples for pipelines and LMOVE-style operations
- Replication notes for reading from replicas where appropriate
- Aligned with official Redis clustering and multi-key operation documentation
- Includes Python redis-py and Java Jedis code paths for clustered multi-key operations
Adoption & trust: 1 installs on skills.sh; 70 GitHub stars; trending (+100% hot-view momentum).
What problem does it solve?
Your Redis Cluster rejects pipelines and multi-key commands with CROSSSLOT because keys landed on different hash slots.
Who is it for?
Indie builders running Redis Cluster or Redis Enterprise with multi-key workflows, carts, or per-user key bundles.
Skip if: Single-node Redis with no cluster mode where hash tags add no benefit.
When should I use this skill?
When implementing or operating Redis Cluster and you need slot-safe key design, hash tags, or replica read patterns.
What do I get? / Deliverables
You name and tag keys so transactions, pipelines, and multi-key commands run on a single slot and your agent stops proposing cluster-unsafe patterns.
- Slot-safe key naming scheme
- Pipeline/multi-key patterns that avoid CROSSSLOT
Recommended Skills
Journey fit
Spans multiple journey phases - primary shelf plus alternate fits below.
Canonical shelf is Operate because clustering mistakes (CROSSSLOT, wrong slots) surface in production Redis deployments. Infra subphase covers sharding, replication, and cluster topology decisions for live data stores.
Where it fits
Diagnose CROSSSLOT failures after enabling cluster mode in staging.
Design per-user key namespaces before implementing cart and profile pipelines.
Wire LMOVE or transaction blocks between related queues on the same slot.
How it compares
Operational Redis Cluster playbook in skill form—not a generic Redis CRUD cheat sheet or an MCP server.
Common Questions / FAQ
Who is redis-clustering for?
Backend-focused solo builders and small teams using Redis Cluster in production who want agents to follow slot and hash-tag rules.
When should I use redis-clustering?
In Operate infra when debugging CROSSSLOT errors, and during Build backend or integrations when designing key layouts, pipelines, and replica reads.
Is redis-clustering safe to install?
It is documentation-oriented procedural knowledge; review the Security Audits panel on this page and restrict live Redis credentials in agent environments.
SKILL.md
READMESKILL.md - Redis Clustering
{ "name": "redis-clustering", "version": "1.0.0", "description": "Redis Cluster and replication — hash tags for multi-key operations, avoiding CROSSSLOT, reading from replicas.", "author": { "name": "Redis", "email": "support@redis.com" }, "homepage": "https://redis.io", "repository": "https://github.com/redis/agent-skills", "license": "MIT", "keywords": ["redis", "cluster", "replication", "hash-tags", "sharding"] } # Use Hash Tags for Multi-Key Operations In Redis Cluster, keys are distributed across slots based on their hash. Use hash tags to ensure keys that must be used together in [multi-key operations](https://redis.io/docs/latest/operate/rs/databases/durability-ha/clustering/#multikey-operations) are on the same slot. **Correct:** Use hash tags for keys used in multi-key operations. **Python** (redis-py): ```python # These keys go to the same slot because {user:1001} is the hash tag redis.set("{user:1001}:profile", "...") redis.set("{user:1001}:settings", "...") redis.set("{user:1001}:cart", "...") # Now you can use transactions and pipelines pipe = redis.pipeline() pipe.get("{user:1001}:profile") pipe.get("{user:1001}:settings") pipe.execute() # Multi-key commands also work redis.lmove("{user:1001}:pending", "{user:1001}:processed", "LEFT", "RIGHT") ``` **Java** (Jedis): ```java import redis.clients.jedis.UnifiedJedis; import java.util.Set; try (UnifiedJedis jedis = new UnifiedJedis("redis://localhost:6379")) { // Hash tags ensure keys go to the same slot jedis.sadd("{bikes:racing}:france", "bike:1", "bike:2", "bike:3"); jedis.sadd("{bikes:racing}:usa", "bike:1", "bike:4"); // Multi-key operation works because of matching hash tags Set<String> result = jedis.sdiff("{bikes:racing}:france", "{bikes:racing}:usa"); } ``` **Incorrect:** Keys without hash tags that need multi-key operations. **Python** (redis-py): ```python # Bad: These may be on different slots redis.set("user:1001:profile", "...") # No hash tag redis.set("user:1001:settings", "...") # This will fail in cluster mode pipe = redis.pipeline() pipe.get("user:1001:profile") pipe.get("user:1001:settings") pipe.execute() # CROSSSLOT error ``` **Java** (Jedis): ```java // Bad: No hash tags - keys may be on different slots jedis.sadd("bikes:racing:france", "bike:1", "bike:2", "bike:3"); jedis.sadd("bikes:racing:usa", "bike:1", "bike:4"); // This will fail in cluster mode with CROSSSLOT error Set<String> result = jedis.sdiff("bikes:racing:france", "bikes:racing:usa"); ``` **Hash tag rules:** - Only the part between `{` and `}` is hashed for slot assignment - Use meaningful identifiers like `{user:1001}` not just `{1001}` to avoid unrelated keys (e.g., `purchase:{1001}`, `employee:{1001}`) saturating the same slot - Use hash tags only where multi-key operations are needed, not as a general habit Reference: [Redis Cluster Key Distribution](https://redis.io/docs/latest/operate/oss_and_stack/reference/cluster-spec/#hash-tags) # Use Read Replicas for Read-Heavy Workloads For read-heavy workloads, distribute reads across replicas to reduce load on primaries. **Correct:** Configure replica reads in Redis Cluster. ```python from redis.cluster import RedisCluster rc = RedisCluster( host='localhost', port=6379, read_from_replicas=True # Distribute reads to replicas ) # Writes go to primary rc.set("key", "value") # Reads can be served by replicas (eventually consistent) value = rc.get("key") ``` **Correct:** Use replica reads in standalone replication setup. ```python from redis import Redis # Connect to primary for writes primary = Redis(host='primary-host', port=6379) # Connect to replica for reads replica = Redis(host='replica-host', port=6379) # Write to primary primary.set("key", "value") # Read from replica (eventually consistent) value = replica.get("key") ``` **Considerations:** - Replica reads are eventually consistent - Don't read from replicas for data that was just written -