From aj-geddes-useful-ai-prompts-4
Implements API rate limiting strategies (token bucket, sliding window, fixed window) to protect APIs from abuse, manage traffic, and enforce tiered limits.
How this skill is triggered — by the user, by Claude, or both
Slash command
/aj-geddes-useful-ai-prompts-4:api-rate-limitingThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
- [Overview](#overview)
Protect APIs from abuse and manage traffic using various rate limiting algorithms with per-user, per-IP, and per-endpoint strategies.
Minimal working example:
// Token Bucket Rate Limiter
class TokenBucket {
constructor(capacity, refillRate) {
this.capacity = capacity;
this.tokens = capacity;
this.refillRate = refillRate; // tokens per second
this.lastRefillTime = Date.now();
}
refill() {
const now = Date.now();
const timePassed = (now - this.lastRefillTime) / 1000;
const tokensToAdd = timePassed * this.refillRate;
this.tokens = Math.min(this.capacity, this.tokens + tokensToAdd);
this.lastRefillTime = now;
}
consume(tokens = 1) {
this.refill();
if (this.tokens >= tokens) {
this.tokens -= tokens;
return true;
}
// ... (see reference guides for full implementation)
Detailed implementations in the references/ directory:
| Guide | Contents |
|---|---|
| Token Bucket Algorithm | Token Bucket Algorithm |
| Sliding Window Algorithm | Sliding Window Algorithm |
| Redis-Based Rate Limiting | Redis-Based Rate Limiting |
| Tiered Rate Limiting | Tiered Rate Limiting |
| Python Rate Limiting (Flask) | Python Rate Limiting (Flask) |
| Response Headers | Response Headers |
npx claudepluginhub joshuarweaver/cascade-code-languages-misc-1 --plugin aj-geddes-useful-ai-prompts-4Implements API rate limiting with sliding windows, token buckets, quotas using Redis and libraries for Node.js, Python/FastAPI, Java. Protects endpoints from excessive requests with headers and 429 responses.
Implements API rate limiting using token bucket, sliding window, Redis algorithms, and Express middleware. Use for securing public APIs, tiered access, and DoS protection.
Implements rate limiting, throttling, API quotas, and backpressure mechanisms using token bucket, sliding window, Redis-based distributed, and adaptive algorithms. Useful for protecting APIs, preventing DOS attacks, and managing system load.