rate-limit

rate-limit is a skill for Claude Code from tushaarmehtaa/tushar-skills. It costs 43 tokens per session (551 once invoked), scanned A, original, MIT.

A guide for adding request limits to Next.js web routes using Upstash Redis, a hosted data store. It covers identifying users or clients, returning standard 429 responses, and deciding what happens if the limit service is unavailable.

In plain words
What is it for?
Use it to design or review limits for routes based on users, tenants, API keys, or trusted IP addresses, including different limits by route, user tier, request cost, and outage behavior.
Why use it?
It helps prevent excessive requests that could abuse an application or create unexpected costs. It also avoids unsafe client identification, such as trusting forged IP headers.

Skill for Claude Code

Written for Claude Code: shipped in a Claude Code plugin.

Part of the slashskills plugin — 34 skills shipped together

Good fit Use it to design or review limits for routes based on users, tenants, API keys, or trusted IP addresses, including different limits by route, user tier, request cost, and outage behavior.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/tushaarmehtaa/tushar-skills/rate-limit
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add tushaarmehtaa/tushar-skills --skill rate-limit
Clone the repo
git clone --depth 1 https://github.com/tushaarmehtaa/tushar-skills

Made for: Claude Code.

Or install slashskills, the plugin that ships this one along with the rest of its 34 skills.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for rate-limit

README.md
[![agentmods](https://agentmods.dev/badge/skills/tushaarmehtaa/tushar-skills/rate-limit/github.svg)](https://agentmods.dev/skills/tushaarmehtaa/tushar-skills/rate-limit)
Your own site
<a href="https://agentmods.dev/skills/tushaarmehtaa/tushar-skills/rate-limit"><img src="https://agentmods.dev/badge/skills/tushaarmehtaa/tushar-skills/rate-limit/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for rate-limit

Your own site · 80×15
<a href="https://agentmods.dev/skills/tushaarmehtaa/tushar-skills/rate-limit"><img src="https://agentmods.dev/badge/skills/tushaarmehtaa/tushar-skills/rate-limit.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 43 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 551 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00043 $0.00551
Opus 5 $0.00022 $0.00275
Sonnet 5 $0.00009 $0.00110
Haiku 4.5 $0.00004 $0.00055

Measured 11d ago against content hash 0eae47072c9e, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-11, from the pricing page.

Security

Grade A, and why

rate-limit scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 11d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

rate-limit/SKILL.md · 31 lines

How it starts

The opening of the file, as written. The whole thing — 31 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Rate limiting with Upstash

Rate limits are one layer of abuse and cost control. Design policy before wiring middleware.

Workflow

  1. Detect Next.js/runtime/version, deployed proxy/CDN, auth/API-key model, installed Upstash versions, protected routes, operation cost, existing quotas, and whether middleware/proxy already touches the request.
  2. Define a policy table per route class: identifier, algorithm/window/burst, cost weight, user tier, response behavior, and store-outage behavior. Ask only when the threat/cost tradeoff cannot be inferred.
  3. Prefer authenticated user, API key, or tenant+user identifiers. Use IP only for anonymous traffic and only from a deployment-provided trusted source. Never trust arbitrary x-forwarded-for from the public internet; configure trusted proxy depth/platform headers. Do not collapse unknown clients to 127.0.0.1.
  4. Namespace by environment and route/policy. Do not apply blanket middleware and a per-route limiter to the same request unless deliberate layered limits use different keys.
  5. Configure explicit Upstash timeout and logging/metrics. Choose outage behavior by endpoint:
    • low-risk availability paths may fail open with degraded telemetry;
    • authentication, high-cost generation, or abuse-sensitive paths may use a local emergency limit, queue, credit reservation, or fail closed with a clear temporary response.
  6. Return 429 with a non-negative Retry-After and consistent rate-limit headers. Add headers to successful responses where useful. Do not emit misleading zero limits during fail-open degradation.
  7. For weighted work, consume tokens based on server-calculated batch/operation cost. Combine rate limits with body-size limits, concurrency controls, idempotency, budgets/credits, and provider quotas where relevant.
  8. Preserve async work such as analytics synchronization using the runtime’s waitUntil mechanism when the SDK exposes a pending promise.

Verification

Use deterministic tests with an isolated key prefix and controllable clock/window where possible. Test allowed/blocked/reset behavior, route isolation, authenticated and anonymous keys, spoofed forwarding headers, paid/free policies, concurrency, weighted requests, store timeout/outage behavior, and duplicate middleware avoidance. Run repository lint/type/test/build and inspect Upstash analytics only when enabled.

Read the full file on GitHub · 31 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 11d ago First seen · 31 lines · 43 tokens per session scan A 0eae47072c9e

Subscribe to this mod's changes

rate-limit is a skill published in the GitHub repository tushaarmehtaa/tushar-skills (11 stars, last pushed yesterday), licensed MIT. It adds 43 tokens to every session and 551 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

using-redis-token-buckets

Use when adding a bucket-like rate limit backed by Redis: a per-caller budget with burst capacity and continuous refill, a refund path for requests that did no work, or a limit whose Retry-After must be a real wait rather than a window edge. posthog/tokenbucket.py provides an atomic Lua token bucket (consume, refund…

PostHog/posthog-foss · 148 tokens

spring-boot-cache

Provides patterns for implementing Spring Boot caching: configures Redis/Caffeine/EhCache providers with TTL and eviction policies, applies @Cacheable/@CacheEvict/@CachePut annotations, validates cache hit/miss behavior, and exposes metrics via Actuator. Use when adding caching to Spring Boot services, configuring…

giuseppe-trisciuoglio/developer-kit · 79 tokens

using-redis-token-buckets

Use when adding a bucket-like rate limit backed by Redis: a per-caller budget with burst capacity and continuous refill, a refund path for requests that did no work, or a limit whose Retry-After must be a real wait rather than a window edge. posthog/tokenbucket.py provides an atomic Lua token bucket (consume, refund…

PostHog/posthog · 148 tokens

spring-data-redis

Use when implementing caching, session storage, rate limiting, or any Redis integration. Covers cache-aside pattern, key naming, TTL strategy, and serialization config.

rrezartprebreza/spring-boot-skills · 37 tokens

background-job-orchestrator

Expert in background job processing with Bull/BullMQ (Redis), Celery, and cloud queues. Implements retries, scheduling, priority queues, and worker management. Use for async task processing, email campaigns, report generation, batch operations. Activate on "background job", "async task", "queue", "worker", "BullMQ"…

curiositech/some_claude_skills · 95 tokens

nw-sd-patterns

Core distributed systems patterns - load balancing, caching, sharding, consistent hashing, message queues, rate limiting, CDN, Bloom filters, ID generation, replication, conflict resolution, CAP theorem.

nWave-ai/nWave · 43 tokens