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.
npx skills add mickeyyaya/refactoring-skills --skill api-rate-limiting-throttlinggit clone --depth 1 https://github.com/mickeyyaya/refactoring-skillsWrote 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.
[](https://agentmods.dev/skills/mickeyyaya/refactoring-skills/api-rate-limiting-throttling)<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.
<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>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.
| Model | Per session | Once 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 |
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.
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 } };
}
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.
- 11d ago First seen · 595 lines · 67 tokens per session scan A 85382808c910
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.
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…
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…
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…
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.
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"…
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.