agentleFS
agentsdanceagentsdance/agentskills/skills/api-rate-limiter/SKILL.md

api-rate-limiter

Skill3 starsChanged 11 months agoApache-2.0View on GitHub

Implement rate limiting for APIs. Use when the user needs to protect endpoints from abuse, implement throttling, or manage API quotas.

1 other project uses a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

1 rule. About 0 are common, 1 is distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Consider separate limits for different endpoints

    line 95

≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

API Rate Limiter

Protect APIs with rate limiting and throttling.

Rate Limiting Strategies

StrategyDescriptionUse Case
Fixed WindowCount requests per time windowSimple limits
Sliding WindowRolling time windowSmoother limits
Token BucketRefilling tokens over timeBurst allowance
Leaky BucketConstant output rateSteady throughput

Express.js Implementation

import rateLimit from 'express-rate-limit';

const limiter = rateLimit({
  windowMs: 15 * 60 * 1000, // 15 minutes
  max: 100, // 100 requests per window
  message: {
    error: 'Too many requests',
    retryAfter: '15 minutes'
  },
  standardHeaders: true, // Return rate limit info in headers
});

app.use('/api', limiter);

Redis-based Rate Limiter

import Redis from 'ioredis';

const redis = new Redis();

async function rateLimit(key, limit, windowSecs) {
  const current = await redis.incr(key);

  if (current === 1) {
    await redis.expire(key, windowSecs);
  }

  if (current > limit) {
    const ttl = await redis.ttl(key);
    return { allowed: false, retryAfter: ttl };
  }

  return { allowed: true, remaining: limit - current };
}

// Usage
const result = await rateLimit(`ratelimit:${userId}`, 100, 3600);

Response Headers

X-RateLimit-Limit: 100
X-RateLimit-Remaining: 95
X-RateLimit-Reset: 1640995200
Retry-After: 3600

Tiered Limits

const tiers = {
  free: { requests: 100, window: '1h' },
  basic: { requests: 1000, window: '1h' },
  pro: { requests: 10000, window: '1h' },
  enterprise: { requests: 100000, window: '1h' },
};

function getLimiter(userTier) {
  const tier = tiers[userTier] || tiers.free;
  return rateLimit({
    windowMs: parseWindow(tier.window),
    max: tier.requests,
  });
}

Best Practices

  • Return informative rate limit headers
  • Provide clear error messages with retry timing
  • Consider separate limits for different endpoints
  • Log rate limit violations for monitoring

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.