Skip to main content
command

setup-rate-limiting — Claude Code command: API rate limits

A slash command that inspects your project and builds a rate limiting setup: algorithms, per-user quotas, counter storage.

Install into Claude Code · claude-code-templates All methods and platforms ↓
npx claude-code-templates@latest --command setup/setup-rate-limiting
Open on GitHub

What setup-rate-limiting does

The command first reads the current API state. It detects the framework from package.json or requirements.txt, greps src/ for existing rate.limit, throttle and rateLimit mentions, pings Redis with redis-cli ping, and counts the endpoints it can find. Everything it generates is based on that scan.

An argument narrows the scope: --api, --authentication, --file-upload or --database. Under the hood it covers token bucket, sliding window, fixed window and leaky bucket algorithms, tier-based and per-user quotas, separate rules for authenticated and anonymous traffic, and IP controls. Counters live in Redis, which is also where distributed limiting and failover come from.

If Redis is not running, the availability check reports it, and you will need another storage backend before the generated limits can hold state across instances. The command has Read, Write, Edit and Bash at its disposal.

What it helps with

  • add limits to public Express or FastAPI endpoints
  • stop brute-force attempts on a login form
  • cap how often a user can upload files
  • set different quotas for paid and free accounts
  • move request counters into Redis across several instances

Example prompts for the agent

  • /setup-rate-limiting --api
  • /setup-rate-limiting --authentication
  • /setup-rate-limiting --file-upload

How to install setup-rate-limiting

1claude-code-templates

npx claude-code-templates@latest --command setup/setup-rate-limiting

2Manually: put the files in place

.claude/commands/setup-rate-limiting.md

Call it with /setup-rate-limiting. For all projects use ~/.claude/commands/

Questions about setup-rate-limiting

How do I install setup-rate-limiting in Claude?

Run npx claude-code-templates@latest --command setup/setup-rate-limiting. The command file lands at .claude/commands/setup-rate-limiting.md.

What does setup-rate-limiting do?

It checks your framework, existing limits and Redis availability, then builds a rate limiting system with algorithms such as token bucket and per-user policies.

What arguments does the command take?

A rate limit type: --api, --authentication, --file-upload or --database. Without one, it works from the general task description.

Source text

setup-rate-limiting.md · MIT
---
allowed-tools: Read, Write, Edit, Bash
argument-hint: "[rate-limit-type] | --api | --authentication | --file-upload | --database"
description: Implement comprehensive API rate limiting with advanced algorithms and user-specific policies
---

# Setup Rate Limiting

Implement comprehensive API rate limiting with advanced control mechanisms: **$ARGUMENTS**

## Current API State

- Framework detection: @package.json or @requirements.txt (Express, FastAPI, Spring Boot, etc.)
- Existing rate limiting: !`grep -r "rate.limit\|throttle\|rateLimit" src/ 2>/dev/null | wc -l`
- Redis availability: !`redis-cli ping 2>/dev/null || echo "Redis not available"`
- API endpoints: !`grep -r "route\|endpoint\|@app\\.route" src/ 2>/dev/null | wc -l`

## Task

Implement production-ready rate limiting system with sophisticated algorithms and user policies:

**Rate Limit Type**: Use $ARGUMENTS to focus on API rate limiting, authentication limiting, file upload controls, or database access limiting

**Rate Limiting Architecture**:
1. **Algorithm Implementation** - Token bucket, sliding window, fixed window, leaky bucket algorithms
2. **User Policies** - Tier-based limits, authenticated vs anonymous, user-specific quotas, IP-based controls
3. **Storage Backend** - Redis integration, distributed rate limiting, persistence strategies, failover mechanisms
4. **Endpoint Configuration** - Per-route limits, method-specific rules, dynamic configuration, A/B testing
5. **Monitoring & Analytics** - Usage tracking, abuse detection, performance metrics, alerting systems
6. **Bypass Mechanisms** - Whitelist management, internal request handling, emergency overrides

**Advanced Features**: Adaptive rate limiting, geo-based controls, API key management, quota systems, abuse prevention.

**Production Readiness**: High availability, performance optimization, security controls, comprehensive monitoring.

**Output**: Complete rate limiting system with intelligent policies, comprehensive monitoring, and advanced abuse prevention capabilities.

© davila7 · MIT · davila7/claude-code-templates

Similar slash commands

All slash commands for Backend and APIs →

From the same set205

The whole set →

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor