api-rate-limiting-throttling

api-rate-limiting-throttling is a skill for Claude Code, Codex from mickeyyaya/refactoring-skills. It costs 67 tokens per session (5,265 once invoked), scanned A, original, MIT.

A guide for controlling how often an API accepts requests. An API is a way for programs to communicate; rate limiting helps keep it from being overloaded or abused.

In plain words
What is it for?
Use it when designing or checking rate limits in TypeScript, Go, Python, or Redis Lua. It covers token buckets, leaky buckets, sliding and fixed windows, Redis-based limits, backoff, and common mistakes.
Why use it?
It helps choose and review limits that balance protection with legitimate bursts of traffic. It also covers distributed limits, response headers, and client retry behavior.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it when designing or checking rate limits in TypeScript, Go, Python, or Redis Lua. It covers token buckets, leaky buckets, sliding and fixed windows, Redis-based limits, backoff, and common mistakes.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/mickeyyaya/refactoring-skills/api-rate-limiting-throttling
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.

Any agent
npx skills add mickeyyaya/refactoring-skills --skill api-rate-limiting-throttling
Clone the repo
git clone --depth 1 https://github.com/mickeyyaya/refactoring-skills

Made for: Claude Code, Codex.

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-throttling

README.md
[![agentmods](https://agentmods.dev/badge/skills/mickeyyaya/refactoring-skills/api-rate-limiting-throttling/github.svg)](https://agentmods.dev/skills/mickeyyaya/refactoring-skills/api-rate-limiting-throttling)
Your own site
<a href="https://agentmods.dev/skills/mickeyyaya/refactoring-skills/api-rate-limiting-throttling"><img src="https://agentmods.dev/badge/skills/mickeyyaya/refactoring-skills/api-rate-limiting-throttling/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for api-rate-limiting-throttling

Your own site · 80×15
<a href="https://agentmods.dev/skills/mickeyyaya/refactoring-skills/api-rate-limiting-throttling"><img src="https://agentmods.dev/badge/skills/mickeyyaya/refactoring-skills/api-rate-limiting-throttling.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 67 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 5,265 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
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.00067 $0.05265
Opus 5 $0.00034 $0.02632
Sonnet 5 $0.00013 $0.01053
Haiku 4.5 $0.00007 $0.00526

Measured 11d ago against content hash 85382808c910, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-11, from the pricing page.

Security

Grade A, and why

api-rate-limiting-throttling 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 11d 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.

skills/api-rate-limiting-throttling/SKILL.md · 595 lines

How it starts

The opening of the file, as written. The whole thing — 595 lines — stays where its author put it; the contents beside it link to each section on GitHub.

API Rate Limiting and Throttling

Overview

Rate limiting protects services from traffic spikes, abuse, and accidental overload. Choosing the wrong algorithm leads to either boundary spikes that allow bursting through limits, or excessive rejection of legitimate traffic. Use this guide to implement, review, or debug rate limiting logic.

When to use: Designing public or internal APIs; reviewing middleware for throttling correctness; evaluating Redis-based distributed limiting; auditing rate limit response headers; checking client-side retry and backoff behavior.

Quick Reference

Algorithm Burst Tolerance Accuracy Complexity Best For
Token Bucket High — refills at rate R, allows bursts up to capacity C Good Medium APIs that allow short bursts
Leaky Bucket None — constant drain rate Good Medium Smoothing traffic to downstream
Sliding Window Counter High — no boundary spikes Excellent Medium-High Accurate per-user limits
Fixed Window Counter Medium — full quota resets at boundary Fair Low Simple counters, background jobs
Distributed (Redis Lua) Configurable Excellent High Multi-instance production APIs

Patterns in Detail

1. Token Bucket Algorithm

The token bucket holds up to capacity tokens. Tokens are added at refillRate per second. Each request consumes one token. Requests that arrive when the bucket is empty are rejected or queued.

Red Flags:

  • Storing last-refill timestamp as an integer — truncation error accumulates over time
  • Not capping tokens at capacity — bucket grows unboundedly after idle periods
  • Per-process in-memory state in multi-instance deployments — each instance has a full bucket

TypeScript:

interface TokenBucket {
  tokens: number;
  lastRefillMs: number;
  readonly capacity: number;
  readonly refillRatePerMs: number;
}

function createTokenBucket(capacity: number, refillRatePerSecond: number): TokenBucket {
  return {
    tokens: capacity,
    lastRefillMs: Date.now(),
    capacity,
    refillRatePerMs: refillRatePerSecond / 1000,
  };
}

function consumeToken(bucket: TokenBucket): { allowed: boolean; bucket: TokenBucket } {
  const now = Date.now();
  const elapsed = now - bucket.lastRefillMs;
  const refilled = Math.min(
    bucket.capacity,
    bucket.tokens + elapsed * bucket.refillRatePerMs,
  );
  if (refilled < 1) {
    return { allowed: false, bucket: { ...bucket, tokens: refilled, lastRefillMs: now } };
  }
  return { allowed: true, bucket: { ...bucket, tokens: refilled - 1, lastRefillMs: now } };
}

Read the full file on GitHub · 595 lines

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. 11d ago First seen · 595 lines · 67 tokens per session scan A 85382808c910

Subscribe to this mod's changes

api-rate-limiting-throttling is a skill published in the GitHub repository mickeyyaya/refactoring-skills (6 stars, last pushed 5mo ago), licensed MIT. It adds 67 tokens to every session and 5,265 once invoked, about $0.0003 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-31.

Related

Other skills, from other repositories

using-redis-token-buckets

Use when adding a bucket-like rate limit backed by Redis: a per-caller budget with burst capacity and continuous refill, a refund path for requests that did no work, or a limit whose Retry-After must be a real wait rather than a window edge. posthog/tokenbucket.py provides an atomic Lua token bucket (consume, refund…

PostHog/posthog-foss · 148 tokens

spring-boot-cache

Provides patterns for implementing Spring Boot caching: configures Redis/Caffeine/EhCache providers with TTL and eviction policies, applies @Cacheable/@CacheEvict/@CachePut annotations, validates cache hit/miss behavior, and exposes metrics via Actuator. Use when adding caching to Spring Boot services, configuring…

giuseppe-trisciuoglio/developer-kit · 79 tokens

using-redis-token-buckets

Use when adding a bucket-like rate limit backed by Redis: a per-caller budget with burst capacity and continuous refill, a refund path for requests that did no work, or a limit whose Retry-After must be a real wait rather than a window edge. posthog/tokenbucket.py provides an atomic Lua token bucket (consume, refund…

PostHog/posthog · 148 tokens

spring-data-redis

Use when implementing caching, session storage, rate limiting, or any Redis integration. Covers cache-aside pattern, key naming, TTL strategy, and serialization config.

rrezartprebreza/spring-boot-skills · 37 tokens

background-job-orchestrator

Expert in background job processing with Bull/BullMQ (Redis), Celery, and cloud queues. Implements retries, scheduling, priority queues, and worker management. Use for async task processing, email campaigns, report generation, batch operations. Activate on "background job", "async task", "queue", "worker", "BullMQ"…

curiositech/some_claude_skills · 95 tokens

nw-sd-patterns

Core distributed systems patterns - load balancing, caching, sharding, consistent hashing, message queues, rate limiting, CDN, Bloom filters, ID generation, replication, conflict resolution, CAP theorem.

nWave-ai/nWave · 43 tokens