api-rate-limiting

api-rate-limiting is a skill for Claude Code from secondsky/claude-skills. It costs 45 tokens per session (496 once invoked), scanned A, original, MIT.

A guide to limiting how often users or clients can call an API, which is a service that software uses to exchange data. It covers token bucket, sliding-window, and Redis-based approaches.

In plain words
What is it for?
Use it to protect public APIs, set different limits per user or endpoint, support tiered access, and add rate-limiting middleware.
Why use it?
It helps prevent abuse and denial-of-service attacks, where excessive traffic makes a service unavailable.

Skill for Claude Code

Written for Claude Code: shipped in a Claude Code plugin.

Part of the api-rate-limiting plugin — 1 skill shipped together

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/secondsky/claude-skills/api-rate-limiting
Any agent
npx skills add secondsky/claude-skills --skill api-rate-limiting
Clone the repo
git clone --depth 1 https://github.com/secondsky/claude-skills

Made for: Claude Code.

Or install api-rate-limiting, the plugin that ships this one along with the rest of its 1 skill.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for api-rate-limiting

README.md
[![agentmods](https://agentmods.dev/badge/skills/secondsky/claude-skills/api-rate-limiting.svg)](https://agentmods.dev/skills/secondsky/claude-skills/api-rate-limiting)
Your own site
<a href="https://agentmods.dev/skills/secondsky/claude-skills/api-rate-limiting"><img src="https://agentmods.dev/badge/skills/secondsky/claude-skills/api-rate-limiting.svg" alt="Measured on agentmods" height="20"></a>
Per session 45 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 496 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00045 $0.00496
Opus 5 $0.00023 $0.00248
Sonnet 5 $0.00009 $0.00099
Haiku 4.5 $0.00005 $0.00050

Measured 6d ago against content hash 7a5101542c72, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-06, from the pricing page.

Security

Grade A, and why

api-rate-limiting scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 6d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

plugins/api-rate-limiting/skills/api-rate-limiting/SKILL.md · 88 lines

What it actually says

API Rate Limiting

Protect APIs from abuse using rate limiting algorithms with per-user and per-endpoint strategies.

Algorithms

Algorithm Pros Cons
Token Bucket Handles bursts, smooth Memory per user
Sliding Window Accurate Memory intensive
Fixed Window Simple Boundary spikes

Token Bucket (Node.js)

class TokenBucket {
  constructor(capacity, refillRate) {
    this.capacity = capacity;
    this.tokens = capacity;
    this.refillRate = refillRate; // tokens per second
    this.lastRefill = Date.now();
  }

  consume() {
    this.refill();
    if (this.tokens >= 1) {
      this.tokens--;
      return true;
    }
    return false;
  }

  refill() {
    const now = Date.now();
    const elapsed = (now - this.lastRefill) / 1000;
    this.tokens = Math.min(this.capacity, this.tokens + elapsed * this.refillRate);
    this.lastRefill = now;
  }
}

Express Middleware

const rateLimit = require('express-rate-limit');

const limiter = rateLimit({
  windowMs: 15 * 60 * 1000, // 15 minutes
  max: 100,
  standardHeaders: true,
  message: { error: 'Too many requests, try again later' }
});

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

Response Headers

X-RateLimit-Limit: 100
X-RateLimit-Remaining: 45
X-RateLimit-Reset: 1705320000
Retry-After: 60

Tiered Limits

Tier Requests/Hour
Free 100
Pro 1,000
Enterprise 10,000

Best Practices

  • Use Redis for distributed rate limiting
  • Include proper headers in responses
  • Return 429 status with Retry-After
  • Implement tiered limits for different plans
  • Monitor rate limit metrics
  • Test under load
Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 6d ago First seen · 88 lines · 45 tokens per session scan A 7a5101542c72

Subscribe to this mod's changes

api-rate-limiting is a skill published in the GitHub repository secondsky/claude-skills (214 stars, last pushed 3d ago), licensed MIT. It adds 45 tokens to every session and 496 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.