Skip to content

Skill for sharding databases across servers by range, hash, or directory lookup, with shard key guidance.

CCM score
38 of 100
skills.sh installs
449
GitHub stars
396
last updated
Aug 21, 2026
View on GitHub

Own this skill? Claim it

What it does

  • Covers horizontal data partitioning across multiple database servers, including consistent hashing, shard key selection, and cross-shard querying
  • Includes reference guides for range-based, hash-based, and directory-based sharding, each with detailed implementations
  • Provides a SQL quick start that defines shard ranges such as user_id 0-999999 with CHECK constraints and a get_shard_id routing function
  • Designed for large databases that exceed single-server capacity, need multi-tenant isolation, or require geographic data distribution

Install

$ npx -y skills add aj-geddes/useful-ai-prompts --skill database-sharding -y

Installs into .agents/skills for every agent it finds here, and .claude/skills for Claude Code.

Files

Database Sharding

Table of Contents

Overview

Implement horizontal data partitioning across multiple database servers. Covers sharding strategies, consistent hashing, shard key selection, and cross-shard querying patterns.

When to Use

  • Database size exceeds single server capacity
  • Read/write throughput needs horizontal scaling
  • Geographic data distribution requirements
  • Multi-tenant data isolation
  • Cost optimization through distributed architecture
  • Load balancing across database instances

Quick Start

Minimal working example:

-- Define shard ranges
-- Shard 0: user_id 0-999999
-- Shard 1: user_id 1000000-1999999
-- Shard 2: user_id 2000000-2999999

CREATE TABLE users_shard_0 (
  id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
  user_id BIGINT NOT NULL,
  email VARCHAR(255) NOT NULL,
  created_at TIMESTAMP DEFAULT NOW(),
  CONSTRAINT shard_0_range CHECK (user_id BETWEEN 0 AND 999999)
);

Details

Repository
github.com/aj-geddes/useful-ai-prompts
Categories
Databases, Backend & APIs
First seen
Jun 3, 2026

Questions

What does the database-sharding skill do?

The database-sharding skill implements horizontal data partitioning across multiple database servers. It covers sharding strategies, consistent hashing, shard key selection, and cross-shard querying patterns.

When should I use the database-sharding skill?

Use the database-sharding skill when a database outgrows a single server, when read and write throughput needs horizontal scaling, or when data must be distributed geographically. It also fits multi-tenant data isolation and load balancing across database instances.

How do I install the database-sharding skill?

Run npx -y skills add aj-geddes/useful-ai-prompts --skill database-sharding -y in a project to install it. Once installed, the database-sharding skill guides the agent through range-based, hash-based and directory-based sharding.

Which sharding strategies does the database-sharding skill cover?

The database-sharding skill includes reference guides for range-based sharding, hash-based sharding and directory-based sharding. Each guide gives implementation detail for its strategy.

More from aj-geddes/useful-ai-prompts

All 258

Similar to Database Sharding

More Databases