rate-limiting-patterns

vanman2024's avatarfrom vanman2024

Redis-based rate limiting implementations with token bucket, leaky bucket, and sliding window algorithms. Use when implementing API rate limiting, throttling, or request quota management.

⭐0stars🔀0forks📁View on GitHub🕐Updated Dec 29, 2025

When & Why to Use This Skill

This Claude skill provides robust Redis-based rate limiting implementations using industry-standard algorithms like token bucket, leaky bucket, and sliding window. It enables developers to efficiently manage API traffic, prevent service abuse, and implement request quotas with ready-to-use templates for TypeScript, Python, FastAPI, and Next.js, ensuring high performance and scalability for backend architectures.

Use Cases

  • API Protection: Prevent brute-force attacks and API abuse by implementing sliding window rate limiting for public-facing endpoints.
  • Subscription Management: Enforce tiered usage quotas and request limits for different user subscription levels using the token bucket algorithm.
  • Traffic Shaping: Use leaky bucket implementations to smooth out traffic spikes and prevent downstream microservices from being overwhelmed during peak loads.
  • Rapid Development: Quickly integrate production-ready rate limiting into modern frameworks like FastAPI or Next.js using pre-configured Redis templates and setup scripts.
namerate-limiting-patterns
descriptionRedis-based rate limiting implementations with token bucket, leaky bucket, and sliding window algorithms. Use when implementing API rate limiting, throttling, or request quota management.
allowed-toolsRead, Bash, Grep, Glob

rate-limiting-patterns

Purpose: Redis-based rate limiting implementations with various algorithms.

Activation Triggers:

  • When implementing rate limiting
  • When user mentions API throttling, request quotas
  • When designing rate-limited endpoints

Quick Reference

This skill provides templates, scripts, and examples for Redis rate limiting.

Scripts

  • scripts/setup-redis.sh - Initial Redis setup and configuration
  • scripts/validate-config.sh - Validate Redis configuration
  • scripts/test-connection.sh - Test Redis connectivity

Templates

  • templates/basic-config.ts.template - TypeScript rate limiting config
  • templates/basic-config.py.template - Python rate limiting config
  • templates/redis-config.env.template - Environment variables template
  • templates/docker-compose.yml.template - Docker Compose setup

Examples

  • examples/basic-usage.md - Basic rate limiting patterns
  • examples/fastapi-example.md - FastAPI integration example
  • examples/nextjs-example.md - Next.js integration example

Security Compliance

This skill follows strict security rules:

  • All code examples use placeholder values only
  • No real API keys, passwords, or secrets
  • Environment variable references in all code
  • .gitignore protection documented