Skip to content
Back to skills

Rate Limit

ASecurity

Add rate limiting to an API with correct keys, headers, and 429 responses

  • 3 stars
  • 0 votes
  • 0 copies
  • 4 views
  • Added September 3, 2026
ai-agentsrustgoapi

Works with

  • cli
  • api

Security analysis

A100/100

Scanned September 3, 2026

npx -y skills add black141312/ada --skill rate-limit --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Rate Limit?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Rate Limit
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/black141312-rate-limit/badge)](https://www.skillsdirectory.com/skills/black141312-rate-limit)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: rate-limit
description: Add rate limiting to an API with correct keys, headers, and 429 responses
category: api
---

# Rate Limit

Use when an endpoint or whole API needs throttling to protect against abuse, runaway clients, or cost blowups.

1. Decide the limit key — per API key, per user, or per IP — and pick the scope (global vs per-route); document the chosen limit and window.
2. Choose an algorithm (token bucket or sliding window) and a store: in-memory only for single-instance, Redis/shared store for multi-instance.
3. Add the limiter as middleware or a decorator at the boundary, before expensive work runs.
4. On rejection return `429 Too Many Requests` with a `Retry-After` header and a clear error body.
5. Emit `RateLimit-Limit`, `RateLimit-Remaining`, and `RateLimit-Reset` headers on responses so clients can self-throttle.
6. Test the boundary: requests under the limit pass, the request over it returns 429, and the counter resets after the window.

## Rules
- Use a shared store (Redis) when more than one instance serves traffic — in-memory counters under-count behind a load balancer.
- Rate-limit on a trustworthy key; raw client IP is spoofable and breaks behind proxies unless you read the right forwarded header.
- Fail open or closed deliberately — if the limiter store is down, decide whether to allow or block, don't crash the request.
- Always include `Retry-After` so well-behaved clients back off instead of hammering.
- Keep the limiter cheap; a slow check on every request defeats the purpose.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.