AI Blocks › Keep your code secure
API rate limit adder
Point it at your API. Get rate limiting added with Upstash, using the right window type for each route.
API rate limit adder is a free AI skill for the job "Keep your code secure". Give the instructions to an AI assistant that supports the required files and tools, then review its output.
Free · No account · CC BY 4.0 licence · Made by sickn33
Made by sickn33. See the original on GitHub; we copied it as it is, with its licence.
What it does
Your API gets a request limit that works across every server instance, so one bad actor cannot flood your login or sign-up routes. You get the code in place and a clear reason for each choice. The skill uses the Upstash rate limit library with Upstash Redis, so all instances share the same counters. You need an Upstash account and two keys set in your environment. It picks a window type for each route: sliding window for smooth limits, fixed window for simple ones, and token bucket where short bursts are fine. The limiter is built once, outside the handler, so blocked callers are turned away without a database call. Over-limit callers get a 429 reply.
You give it
- The routes to protect
- Who to count by, such as IP, user or key
- Allowed requests and time window
- Upstash keys in your environment
You get
- Rate limiting wired into your routes
- A window type chosen per route
- 429 replies with reset info
- Optional usage analytics
Use it when
- Your login or sign-up route is being hammered.
- An AI endpoint costs money per call and needs a cap per user.
- You run serverless functions and in-memory limits do not work.
- You are not sure which limit style fits each route.
How to use it
- Add it to your AI once: download it and add the folder to Claude, ChatGPT or Codex as a skill.
- Ask for the job in your own words. Your AI opens the skill when it fits.
- It works best when your AI can edit your project files.