rate-limiting-patterns
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.
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.
| name | rate-limiting-patterns |
|---|---|
| description | 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. |
| allowed-tools | Read, 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 configurationscripts/validate-config.sh- Validate Redis configurationscripts/test-connection.sh- Test Redis connectivity
Templates
templates/basic-config.ts.template- TypeScript rate limiting configtemplates/basic-config.py.template- Python rate limiting configtemplates/redis-config.env.template- Environment variables templatetemplates/docker-compose.yml.template- Docker Compose setup
Examples
examples/basic-usage.md- Basic rate limiting patternsexamples/fastapi-example.md- FastAPI integration exampleexamples/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
.gitignoreprotection documented