api-resilience-patterns

api-resilience-patterns is a skill for Claude Code, Codex from BuilderCed/agent-skills. It costs 33 tokens per session (959 once invoked), scanned A, original, MIT.

A collection of software design patterns for keeping applications working when external services are slow, unavailable, or rate-limited. It covers circuit breakers, delayed retries, rate limits, isolation, timeouts, and reduced-service fallbacks.

In plain words
What is it for?
Use it when calling external APIs, connecting microservices, building agents that use several tools, handling language-model provider limits, or preventing cascading failures.
Why use it?
Calls to APIs can fail repeatedly or pile up, causing wider outages and slow applications. These patterns limit repeated failures and define safer ways to retry or degrade service.

Skill for Claude CodeCodex

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/builderced/agent-skills/api-resilience-patterns
Any agent
npx skills add BuilderCed/agent-skills --skill api-resilience-patterns
Clone the repo
git clone --depth 1 https://github.com/BuilderCed/agent-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-resilience-patterns

README.md
[![agentmods](https://agentmods.dev/badge/skills/builderced/agent-skills/api-resilience-patterns.svg)](https://agentmods.dev/skills/builderced/agent-skills/api-resilience-patterns)
Your own site
<a href="https://agentmods.dev/skills/builderced/agent-skills/api-resilience-patterns"><img src="https://agentmods.dev/badge/skills/builderced/agent-skills/api-resilience-patterns.svg" alt="Measured on agentmods" height="20"></a>
Per session 33 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 959 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 $0.00033 $0.00959
Opus 5 $0.00016 $0.00479
Sonnet 5 $0.00007 $0.00192
Haiku 4.5 $0.00003 $0.00096

Measured 3d ago against content hash 86c462ebe4e5, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

api-resilience-patterns 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 3d 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/resilience/api-resilience-patterns/SKILL.md · 116 lines

How it starts

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

API Resilience Patterns

When to Use

  • Calling external APIs that might fail or slow down
  • Designing microservice communication
  • Building agents that call multiple tools/APIs
  • Handling rate limits from LLM providers
  • Preventing cascade failures

Pattern 1: Circuit Breaker

Prevents repeated calls to a failing service.

States: Closed (normal) → Open (failing) → Half-Open (testing)

State Behavior Transition
Closed Forward requests normally → Open after N consecutive failures
Open Reject immediately (fail fast) → Half-Open after cooldown period
Half-Open Allow 1 test request → Closed if success, → Open if fail

Config: threshold=3 failures, cooldown=30s, half-open-max=1.

Pattern 2: Retry with Exponential Backoff

Attempt 1: immediate
Attempt 2: wait 1s + random(0-500ms)
Attempt 3: wait 2s + random(0-500ms)
Attempt 4: wait 4s + random(0-500ms)
Max: 5 attempts, 16s max wait

Rules:

  • Only retry on transient errors (429, 500, 502, 503, timeout)
  • Never retry on client errors (400, 401, 403, 404)
  • Always add jitter to prevent thundering herd
  • Set a total timeout budget (not just per-attempt)

Pattern 3: Rate Limiting (Client-Side)

Respect provider limits proactively:

Strategy When How
Token bucket Steady rate with bursts Refill N tokens/sec, consume per request
Sliding window Strict per-minute limits Track timestamps of last N requests
Queue-based Ordered processing FIFO queue with configurable concurrency

Pattern 4: Bulkhead Isolation

Isolate failures to prevent cascade:

  • Separate connection pools per service
  • Separate thread/worker pools per dependency
  • If service A fails, services B and C are unaffected

Pattern 5: Timeout Management

Tier Timeout Purpose
Connection 5s Detect unreachable host
Request 30s Detect slow response
Total operation 60s Budget for retries included

Read the full file on GitHub · 116 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. 3d ago First seen · 116 lines · 33 tokens per session scan A 86c462ebe4e5

Subscribe to this mod's changes

api-resilience-patterns is a skill published in the GitHub repository BuilderCed/agent-skills (2 stars, last pushed 4mo ago), licensed MIT. It adds 33 tokens to every session and 959 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-31.

Related

Other skills, from other repositories

acceptance

当用户困在无法改变的处境(坏关系/讨厌的同事/不如意的事)里反复内耗、问「该忍还是该走」时调用。 核心理念: 面对任何情境只有三选项——改变它/接受它/离开它; 三者都不做是痛苦之源; 接受=快速适应, 用「积极方面是什么」重释训练。 不适用于: 可以改变的处境(应先改变), 以及涉及违法/人身安全的场景。 Triggers: 接受/忍/内耗/放不下/该走该留/acceptance/let go/change-accept-leave.

kangarooking/cangjie-skill · 153 tokens

matematic-mcp-fastmcp-instructions-pl

Buduj nowy MCP server MateMatic (lub retrofit istniejacego) z 9 elementami (5 zwalidowanych na dograh v1.31.0) - FastMCP(instructions=) z procedural orchestration, drift test, dwukanalowy auth X-API-Key LUB Bearer, OTel atrybut orgid dla per-tenant routing, ToolAnnotations dla read-only, stabilne kody bledow +…

matematicsolutions/awesome-matematic-skills-pl · 335 tokens

matematic-konstytucja-ai

Generuje "Konstytucje AI" dla kancelarii prawnej - dokument governance definiujacy zasady uzycia AI w organizacji, na bazie cherry-pick patternu github/spec-kit (constitution -> spec -> plan -> tasks). 6 sekcji - mission, principles (max 9 articles), boundaries, governance roles, audit, evolution. Output - dokument…

matematicsolutions/awesome-matematic-skills-pl · 243 tokens

matematic-patron-pr-review-pl

Recenzent PR/diffow dla PATRONa - polski LegalTech AI agent dla kancelarii. Wylapuje regresje specyficzne dla repo PATRON ktorych nie zlapie generyczny lint - org scoping multi-tenant, authless routes, niespodzianki w migracjach SQLite/Postgres, bezposredni SQL poza warstwa db, brak worker sync w cache, UI bez…

matematicsolutions/awesome-matematic-skills-pl · 302 tokens

matematic-spec-driven

Spec-Driven Development dla wewnetrznych projektow MateMatic (PATRON, KGLF, POAS, skille, mikroprodukty, aplikacje). Cherry-pick + adaptacja patternu github/spec-kit (MIT) - 4 fazy (Konstytucja -> Specyfikacja -> Plan -> Zadania) plus opcjonalna walidacja. Wbudowany Constitution Check GATE z 4 bramkami MateMatic…

matematicsolutions/awesome-matematic-skills-pl · 320 tokens

adversarial-legal-review-pl

Czerwony zespół dla pisma prawnego - bierze gotowy deliverable wysokiej stawki (opinia, memo DD, M&A, pismo procesowe, rekomendacja do zarządu) i prowadzi kontradyktoryjną debatę: builder buduje najmocniejszą wersję tezy, attacker ją atakuje kontrargumentami i kontr-orzecznictwem, synthesizer godzi, verifier robi…

matematicsolutions/awesome-matematic-skills-pl · 268 tokens