upstash-ratelimit-js — Claude Code skill: request limits
A skill that teaches your coding agent to add request limits with the @upstash/ratelimit SDK in API routes, Next.js middleware or edge runtimes.
npx skills add upstash/skills --skill upstash-ratelimit-js -a claude-codeWhat upstash-ratelimit-js does
The skill covers @upstash/ratelimit, the TypeScript/JavaScript SDK backed by Upstash Redis. Your agent gets guidance on three algorithms: fixed window, sliding window and token bucket. Picking between them is the first snag — sliding window smooths out the boundary spikes, fixed window costs fewer Redis commands.
The bundle ships several files. algorithms.md explains how each algorithm behaves, pricing-cost.md covers pricing and Redis command cost, features.md lists prefixes, custom keys and behavioural options, methods-getting-started.md is the full method reference, and traffic-protection.md deals with abuse and bot patterns. The quick start is short: build a Redis client with url and token, create a Ratelimit with the limiter you want, then call limiter.limit("user-id").
You need Upstash Redis credentials — url and token. Without them the sample code will not run, so set the keys up before asking the agent to write anything. Limits can be keyed per user, IP, API key or tenant using prefixes and custom keys.
What it helps with
- add a request limit to an API route and return 429
- choose between fixed window, sliding window and token bucket
- throttle per IP, user or API key
- protect a login or signup form from brute force
- estimate the Redis command cost of rate limiting
Example prompts for the agent
- Add rate limiting to this API route with @upstash/ratelimit, 5 requests per 10s
- Set up a Next.js middleware limiter keyed by IP that returns 429
- Which algorithm fits an API-key limit — sliding window or token bucket?
How to install upstash-ratelimit-js
1Skills CLI (Vercel)
npx skills add upstash/skills --skill upstash-ratelimit-js -a claude-code2Manually: put the files in place
~/.claude/skills/upstash-ratelimit-js/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/upstash-ratelimit-js/
1Skills CLI (Vercel)
npx skills add upstash/skills --skill upstash-ratelimit-js -a codex2Manually: put the files in place
.agents/skills/upstash-ratelimit-js/SKILL.mdFor all projects use ~/.agents/skills/
1Skills CLI (Vercel)
npx skills add upstash/skills --skill upstash-ratelimit-js -a cursor2Manually: put the files in place
.cursor/skills/upstash-ratelimit-js/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install upstash/skills upstash-ratelimit-js2Manually: put the files in place
.github/skills/upstash-ratelimit-js/SKILL.md1Skills CLI (Vercel)
npx skills add upstash/skills --skill upstash-ratelimit-js -a gemini-cli2Platform CLI
gemini skills install https://github.com/upstash/skills --path skills/upstash-ratelimit-jsManually: put the files in place
.devin/skills/upstash-ratelimit-js/SKILL.mdThe legacy .windsurf/skills/ path still works
Skills CLI (Vercel)
npx skills add upstash/skills --skill upstash-ratelimit-js -a opencodeClaude.ai
Zip the folder and upload it in Settings → Capabilities → Skills
Step by step, with commands for each platform: How to install skills in Claude Code: five ways
Questions about upstash-ratelimit-js
How do I install upstash-ratelimit-js in Claude?
Run npx skills add upstash/skills --skill upstash-ratelimit-js -a claude-code. The skill lands in ~/.claude/skills/upstash-ratelimit-js/SKILL.md.
What does upstash-ratelimit-js do?
It gives your agent a reference for the @upstash/ratelimit SDK: algorithms, methods, prefixes and custom keys, Redis command cost, and abuse protection patterns.
What do I need before using it?
Upstash Redis credentials — url and token. The quick-start example passes both into the Redis constructor.
Source text
SKILL.md · MIT
---
name: upstash-ratelimit-js
description: Rate limiting for serverless and edge apps with the @upstash/ratelimit TypeScript/JavaScript SDK backed by Upstash Redis. Use when adding a rate limiter or throttling to an API route, Next.js middleware, Vercel Edge, Cloudflare Workers, or any HTTP endpoint; returning 429 Too Many Requests; choosing between fixed window, sliding window, and token bucket algorithms; limiting per user, IP, API key, or tenant with prefixes and custom keys; protecting login, signup, form, or AI endpoints from abuse, bots, and brute force; using deny lists, ephemeral caching, analytics, timeouts, and multi-region rate limits; or estimating the Redis command cost of rate limiting. Also use when the user says rate limit, rate-limiting, throttle, quota, request limits, or traffic protection.
license: MIT
metadata:
author: Upstash
homepage: https://upstash.com
---
# Rate Limit TS SDK
## Quick Start
- Install the SDK and connect to Redis.
- Create a rate limiter and apply it to incoming operations.
Example:
```ts
import { Ratelimit } from "@upstash/ratelimit";
import { Redis } from "@upstash/redis";
const redis = new Redis({ url: "<url>", token: "<token>" });
const limiter = new Ratelimit({ redis, limiter: Ratelimit.slidingWindow(5, "10s") });
const { success } = await limiter.limit("user-id");
if (!success) {
// throttled
}
```
## Other Skill Files
- **algorithms.md**: Describes all available rate‑limiting algorithms and how they behave.
- **pricing-cost.md**: Explains pricing, Redis cost implications, and operational considerations.
- **features.md**: Lists SDK features such as prefixes, custom keys, and behavioral options.
- **methods-getting-started.md**: Full method reference for the SDK's API and getting started guide.
- **traffic-protection.md**: Guidance on applying rate limiting for traffic shaping, abuse prevention, and protection patterns.
© Upstash · MIT · upstash/skills