Skip to content
Development
Agent

how-to-example

Doc type: **how-to guide**. Goal-first, assumes you can already run the service locally. For the concepts behind rate limiting, see the explanation doc; for every config field, see the reference.

From plugin
skills
954 skills54 agents

Claude Code

$ npx -y skills add vanara-agents/skills --agent claude-code

Agent definition

how-to-example.md

How-to: Add a rate limit to an HTTP endpoint

> Doc type: **how-to guide**. Goal-first, assumes you can already run the service locally. For the > concepts behind rate limiting, see the explanation doc; for every config field, see the reference.

**Goal:** protect a single endpoint with a per-client rate limit so a burst of requests returns `429` instead of overloading the service.

Before you start

  • The service runs locally (`npm run dev`) and you can hit `http://localhost:3000`.
  • You have write access to `src/middleware/`.
  • Redis is reachable at `REDIS_URL` (the limiter stores counters there).

Steps

1. Add the limiter middleware:

   // src/middleware/rate-limit.js
   import { RateLimiter } from "../lib/rate-limiter.js";

   const limiter = new RateLimiter({ windowMs: 60_000, max: 100 }); // 100 req/min/client

   export function rateLimit(req, res, next) {
     const key = req.ip;
     const { allowed, retryAfter } = limiter.hit(key);
     if (!allowed) {
       res.set("Retry-After", String(retryAfter));
       return res.status(429).json({ error: "rate_limited" });
     }
     next();
   }

2. Apply it to the endpoint you want to protect (not globally, yet):

   import { rateLimit } from "./middleware/rate-limit.js";
   app.post("/v1/messages", rateLimit, sendMessage);

3. Restart the dev server so the middleware loads:

   npm run dev

Verify

Fire more than the limit and confirm the `429`:

for i in $(seq 1 101); do
  curl -s -o /dev/null -w "%{http_code}\n" -X POST http://localhost:3000/v1/messages
done | sort | uniq -c

Expected output — 100 allowed, then the limiter trips:

    100 200
      1 429

If it goes wrong

  • **All requests pass:** the counter store isn't shared. Confirm `REDIS_URL` is set and reachable.
  • **Every request is 429:** your client IP is shared (proxy). Key on an API token instead of `req.ip`.
  • **Roll back:** remove the `rateLimit` argument from the route and restart.

---

Why this is a good how-to: it states the goal in one line, lists prerequisites *before* the steps, every snippet is runnable, there's an explicit verification with expected output, and a troubleshooting/rollback section. It does **not** explain the token-bucket algorithm — that's linked, not inlined.

Read more
@vanara-agents
Ships withskills

🐒 Free agents, skills & packs for Claude Code One subscription. An army of Claude Code agents. 30 production-grade agents, skills, and packs for Claude Code — free, Apache-2.0, install with one command.

917 skills54 agents
Get the whole plugin

Stars on GitHub

Momentum

stars in total
9
Star history of vanara-agents/skills on GitHub, a chart by star-history.com

Other agents on skills.

AGENT

AGENT

Agent

Use when designing a new HTTP/GraphQL API or changing an existing one — modeling resources, defining endpoint contracts, choosing…

review-notes

review-notes

Agent

This shows how the api-designer agent reviews a flawed draft. Findings are severity-ranked so the implementer fixes the…

contract-and-openapi

contract-and-openapi

Agent

The contract is the deliverable. Express it as an **OpenAPI 3.1** document so it is human-readable *and* machine-checkable. This…

design-checklist

design-checklist

Agent

Run through this before declaring an API contract done. It is ordered the way you should *design*: resources first, cross-cutting…

pr-comment-template

pr-comment-template

Agent

Copy-paste templates for leaving review comments. Keep each comment to one finding: an anchor, the problem, and the fix.

More agents from other plugins.

a11y-architect
Auto-invoked

a11y-architect

Agent

Accessibility Architect specializing in WCAG 2.2 compliance for Web and Native platforms. Use PROACTIVELY when designing UI…

ecc2w293k
@affaan-m@affaan-mInstall Agent
analyze-pass-impact

analyze-pass-impact

Agent

Analyzes how a specific topic affects a group of compiler passes. Used by the /plan-update skill to parallelize research across…

react5d252k
@facebook@facebookInstall Agent
orchestrator

orchestrator

Agent

- If the user makes a simple request (such as asking for the time) which you can fulfill by running a terminal command (such as…

codex5d135k
@openai@openaiInstall Agent
cavecrew-builder

cavecrew-builder

Agent

Surgical 1-2 file edit. Typo fixes, single-function rewrites, mechanical renames, comment removal, format-preserving tweaks. Hard…

caveman6d119k
@juliusbrussee@juliusbrusseeInstall Agent

Questions about how-to-example.

Which coding agents can use how-to-example?
how-to-example installs in Claude Code and Cursor: each loads subagents from .claude/agents, so copy the file there. Flowy's auto-invocation runs in Claude Code only.