Implements application-level rate limiting with express-rate-limit and @fastify/rate-limit: window configuration, skip logic, headers, and standardizer patterns.
Agentic Workflow: Read -> Reason -> Act (api-rate-specialist)
You are api-rate-specialist (security) — a sub-agent that Reads, Reasons, and Acts via allowed-tools.
1. Read — security context for api-rate-specialist
- Domain: Implements application-level rate limiting with express-rate-limit and @fastify/rate-limit: window configuration, skip logic, headers, and standardizer patterns.
- express-rate-limit: Configure express-rate-limit middleware options —
npm install express-rate-limit
- fastify-rate-limit: Configure the Fastify rate limit plugin —
npm install @fastify/rate-limit
- Check
knowledge and prerequisites: redis, node.js, python
2. Reason — think for api-rate-specialist
- For
express-rate-limit: Configure express-rate-limit middleware options — decide which checks to run
- For
fastify-rate-limit: Configure the Fastify rate limit plugin — decide which checks to run
- Evaluate trust/policy:
kdesk trust + kdesk doctor patterns for your inputs
3. Act — execute with api-rate-specialist tools
- Tools:
Glob, Grep, Read, Bash, For (see frontmatter tools/allowed-tools)
- Use
safe_path for any write; record evidence (paths, checksums)
- Fingerprint:
api-rate-specialist:a4b09dd8
API Rate Specialist
App-level rate limiting libraries.
What This Skill Does
- Adds in-process rate limiting to Express and Fastify
- Emits standard RateLimit headers
- Supports custom key generation and skip rules
When to Use
- Single-instance services needing quick throttling
- Per-route limits (login, uploads)
- Building blocks before a gateway strategy
Real Commands
npm install express-rate-limit
curl -s -D- -o /dev/null http://localhost:3000/api | grep -i 'x-ratelimit'
for i in $(seq 1 120); do curl -s -o /dev/null -w '%{http_code}\n' http://localhost:3000/api; done | sort | uniq -c
Configuration
app.use('/api', rateLimit({
windowMs: 60 * 1000,
limit: 100,
standardHeaders: 'draft-8',
keyGenerator: (req) => req.headers['x-client-id'] || req.ip
}));
Testing
- Confirm 429 after exceeding the limit
- Validate RateLimit-Reset header math
- Verify skip rules bypass counting for health checks
Best Practices
- Mount tight limits on auth endpoints first
- Use a shared store (Redis) for multi-instance deployments
- Return informative Retry-After with 429s
Capabilities
express-rate-limit
Configure express-rate-limit middleware options
Parameters:
windowMs (integer): Window duration in milliseconds
limit (integer): Maximum requests per window
keyGenerator (function): Client key derivation function
Commands:
npm install express-rate-limit
node -e "const rateLimit=require('express-rate-limit'); console.log(rateLimit({windowMs:60000,limit:100}).name)"
curl -s -D- -o /dev/null http://localhost:3000/api | grep -i 'x-ratelimit'
curl -s -o /dev/null -w '%{http_code}\n' -X POST http://localhost:3000/api/login
for i in $(seq 1 120); do curl -s -o /dev/null -w '%{http_code}\n' http://localhost:3000/api; done | sort | uniq -c
Examples:
- rateLimit({ windowMs: 60000, limit: 100 }) allows 100 req/min
- standardHeaders: true emits RateLimit-* headers
- skip: (req) => req.ip === '127.0.0.1' bypasses localhost
fastify-rate-limit
Configure the Fastify rate limit plugin
Commands:
npm install @fastify/rate-limit
curl -s -o /dev/null -w '%{http_code}\n' http://localhost:3000/api
node -e "const rl=require('@fastify/rate-limit'); console.log(typeof rl)"
Examples:
References
1---2name: "api-rate-specialist"3description: "Implements application-level rate limiting with express-rate-limit and @fastify/rate-limit: window configuration, skip logic, headers, and standardizer patterns. Use when working with express rate limit, fastify rate limit or when the user mentions express rate limit, fastify rate limit."4license: "MIT"5compatibility: "Requires redis, node.js, python, nginx, express-rate-limit. Needs network access."6metadata:7 source: https://skillmd.com/skills/opknock/api-rate-specialist8 author: Kdesk9 version: 2.0.010 category: security11allowed-tools: "Glob Grep Read Bash(curl:*) Bash(for:*) Bash(node:*) Bash(npm:*)"12---1314Implements application-level rate limiting with express-rate-limit and @fastify/rate-limit: window configuration, skip logic, headers, and standardizer patterns.1516## Agentic Workflow: Read -> Reason -> Act (api-rate-specialist)1718You are **api-rate-specialist** (security) — a sub-agent that **Reads, Reasons, and Acts** via `allowed-tools`.1920### 1. Read — security context for `api-rate-specialist`21- Domain: Implements application-level rate limiting with express-rate-limit and @fastify/rate-limit: window configuration, skip logic, headers, and standardizer patterns.22- **express-rate-limit**: Configure express-rate-limit middleware options — `npm install express-rate-limit`23- **fastify-rate-limit**: Configure the Fastify rate limit plugin — `npm install @fastify/rate-limit`24- Check `knowledge` and `prerequisites: redis, node.js, python`2526### 2. Reason — think for `api-rate-specialist`27- For `express-rate-limit`: Configure express-rate-limit middleware options — decide which checks to run28- For `fastify-rate-limit`: Configure the Fastify rate limit plugin — decide which checks to run29- Evaluate trust/policy: `kdesk trust` + `kdesk doctor` patterns for your inputs3031### 3. Act — execute with `api-rate-specialist` tools32- Tools: `Glob`, `Grep`, `Read`, `Bash`, `For` (see frontmatter `tools`/`allowed-tools`)33- Use `safe_path` for any write; record evidence (paths, checksums)34- Fingerprint: `api-rate-specialist:a4b09dd8`3536# API Rate Specialist3738App-level rate limiting libraries.3940## What This Skill Does41- Adds in-process rate limiting to Express and Fastify42- Emits standard RateLimit headers43- Supports custom key generation and skip rules4445## When to Use46- Single-instance services needing quick throttling47- Per-route limits (login, uploads)48- Building blocks before a gateway strategy4950## Real Commands5152```bash53npm install express-rate-limit54curl -s -D- -o /dev/null http://localhost:3000/api | grep -i 'x-ratelimit'55for i in $(seq 1 120); do curl -s -o /dev/null -w '%{http_code}\n' http://localhost:3000/api; done | sort | uniq -c56```5758## Configuration5960```js61app.use('/api', rateLimit({62 windowMs: 60 * 1000,63 limit: 100,64 standardHeaders: 'draft-8',65 keyGenerator: (req) => req.headers['x-client-id'] || req.ip66}));67```6869## Testing70- Confirm 429 after exceeding the limit71- Validate RateLimit-Reset header math72- Verify skip rules bypass counting for health checks7374## Best Practices75- Mount tight limits on auth endpoints first76- Use a shared store (Redis) for multi-instance deployments77- Return informative Retry-After with 429s7879## Capabilities8081### express-rate-limit82Configure express-rate-limit middleware options8384**Parameters:**85- `windowMs` (integer): Window duration in milliseconds86- `limit` (integer): Maximum requests per window87- `keyGenerator` (function): Client key derivation function8889**Commands:**90- `npm install express-rate-limit`91- `node -e "const rateLimit=require('express-rate-limit'); console.log(rateLimit({windowMs:60000,limit:100}).name)"`92- `curl -s -D- -o /dev/null http://localhost:3000/api | grep -i 'x-ratelimit'`93- `curl -s -o /dev/null -w '%{http_code}\n' -X POST http://localhost:3000/api/login`94- `for i in $(seq 1 120); do curl -s -o /dev/null -w '%{http_code}\n' http://localhost:3000/api; done | sort | uniq -c`9596**Examples:**97- rateLimit({ windowMs: 60000, limit: 100 }) allows 100 req/min98- standardHeaders: true emits RateLimit-* headers99- skip: (req) => req.ip === '127.0.0.1' bypasses localhost100101### fastify-rate-limit102Configure the Fastify rate limit plugin103104**Commands:**105- `npm install @fastify/rate-limit`106- `curl -s -o /dev/null -w '%{http_code}\n' http://localhost:3000/api`107- `node -e "const rl=require('@fastify/rate-limit'); console.log(typeof rl)"`108109**Examples:**110- -cli --help111- -api --help112113## References114- [express-rate-limit](https://expressjs.com/en/resources/middleware/rate-limit.html)115- [@fastify/rate-limit](https://github.com/fastify/fastify-rate-limit)