/be:rate-limitingfrom Backend Skills
Rate limits for a Next.js API on Upstash — an edge layer, a per-IP flood layer, and per-account, per-key and per-organisation budgets; named tiers by what a route does, sliding window or token bucket, cost and concurrency limits, rate limit versus quota, the trusted client IP (IPv6 by /64), fail-open versus fail-closed tiers, lockouts, bot and sign-up abuse, 429 with Retry-After and the IETF RateLimit fields, limits on calls to providers, alerts, and sizing from real traffic. Use when adding a route, a budget, a lockout, or debugging a 429.
Ships in Backend Skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Every route draws on a named budget, counted in Redis, so no caller — a script, a stolen session, a busy office — can take more than its share or guess its way in. OWASP's API4 asks for limits fitted to what each operation costs and risks, not one blanket number; the budgets here are chosen per route for that reason.
Before applying this skill, read the project's root AGENTS.md, the AGENTS.md closest to the files in question, and any doc they link for this skill's topic. Names, values and choices — budgets, tiers, tokens, voice, paths — come from those files, never from this skill.
applyRateLimit(request, tier, "domain:action"), before validation or auth, so a flood costs one Redis call, not a token verification. It's the flood shield, and always the looser layer: an office, a campus, a venue or a mobile carrier puts many people behind one address.access-control).A per-IP limit alone locks out strangers who share an address; a per-account limit alone can't run before the caller is known. Every route has both, with the IP budget above the account budget on the same route.
WRITE, so other writes keep their budget.domain:action name (auth:sign-in, admin:users:suspend); a shared name merges two routes into one counter.rate on the limit call), a read one.redis); a request rate alone lets a caller start many slow jobs at once.plan-entitlements).AGENTS.md); don't publish them.GET ping — take a generous public tier of their own. Only routes with their own gate skip the user layers: a scheduler's tick behind its token, a webhook POST behind its signature (api-architecture).x-forwarded-for from the right, skipping the known proxies; everything to the left is whatever the client sent. Confirm the service is reachable only through that balancer, or a direct caller can forge the header.::ffff:203.0.113.7) to its IPv4 form first, so one caller has one key.unknown bucket and logs a warning, rather than skipping the limit.| Tier | On a Redis error or timeout |
|---|---|
| Guards a credential or a guessable secret | Fails closed — the request is refused; no store, no guesses |
| Everything else | Fails open — logged, and the request goes through |
An outage should cost the limit, not the product — except where an open window is unlimited guessing. @upstash/ratelimit resolves a timed-out call as a success with reason: "timeout"; a closed tier reads that as a denial. Its own timeout defaults to 5 seconds, which stalls the request path during an outage, so set it to a few hundred milliseconds. The client and its settings are redis's; the SDK's options are the official upstash-ratelimit-js skill's.
A lockout counts failures of a check, on top of the request budget, and fails closed:
auth, access-control).auth).Retry-After (seconds, from the limiter's reset), through the shared error envelope with a stable code (api-architecture).RateLimit-Policy and RateLimit fields ("name";q=<quota>;w=<window> and "name";r=<remaining>;t=<reset>) say which budget was spent. A public API sends them on every response, so integrators can pace themselves.Retry-After, otherwise back off exponentially with jitter, cap the attempts, and retry automatically only a request that's safe to repeat. The project's own clients follow it too.Retry-After — 429 says "you sent too much", 503 says "we can't right now".Every provider the API calls — email, payments, media, search — has limits of its own:
Retry-After, back off with jitter, and cap retries; a tight retry loop gets the whole account throttled or banned.webhook-delivery).api-architecture).Mock @upstash/ratelimit with a fake whose next verdict a test sets (testing). Assert the 429 and its headers, that a closed tier refuses on a Redis error, that an open tier lets the request through, and that two addresses in one IPv6 /64 share a key.
x-forwarded-for; proxy a high-volume browser call through the frontend server; fail open on a lockout; publish the numbers; let a lockout be permanent; auto-block shared addresses; treat a quota as a rate limit; retry a provider in a tight loop.Where the call sits in a route api-architecture · the Redis client, locks and failure directions redis · the SDK upstash-ratelimit-js (official) · sign-in, verification and second factors auth · keys and passcodes access-control · quotas plan-entitlements · other resource limits (body size, page size, timeouts) backend-security · the limiter fake testing.
What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub timonwa/engineering-skills --plugin beOther plugins' skills for the same job
22 skills in this plugin
/access-controlAccess control for a Next.js API on Firebase — roles, relationships and attributes (RBAC, ReBAC, ABAC) behind permission verbs and one pure can(); guards as the only gate, 404 before 403; tenant scoping; invitations; escalation limits; two-person approval and access reviews; stale claims; API-key scopes; share links and passcodes; where plan and flag checks sit; UI gates that only hide; and tests. Use when adding a permission, role, guarded route, API key, share link, or a control only some people see./access-control-auditManually invoked. Access-control audit — guards on every route and Server Action (BFLA), 404 before 403 and tenant scoping (BOLA), allowlisted writes and projected reads (BOPLA), verbs never role names, roles that add up, escalation and invitations, claims and revocation, sessions and sign-in, API keys and share links, the plan and flag order, UI gates, data rules and the tests. Verifies each finding and writes a prioritised report./api-architectureHow an API route is built in a Next.js API — the fixed order of rate limit, authorise, validate, delegate, audit, respond; thin routes over services; the response envelope and typed errors; caching headers; concurrent edits; long-running work; cursor pagination and allowlisted sorts; resource paths, versions, deprecation and state-transition sub-routes; and what every new route ships with. Cron, webhooks and audit logs are references. Use when adding, changing or reviewing a route handler or the API layer's structure.