api-resilience-patterns
Skill2 starsChanged 7 months agoMITView on GitHub
Implement API resilience patterns — circuit breakers, retry with backoff, rate limiting, bulkhead isolation, timeout management, and graceful degradation.
In this repository33 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- llms.txtllms.txt
- africa-mobile-moneySkill
- africa-ussd-developmentSkill
- eu-ai-act-complianceSkill
- eu-ai-act-content-disclosureSkill
- eu-dora-complianceSkill
- eu-nis2-complianceSkill
- eu-regulatory-routerSkill
- gdpr-data-protectionSkill
- fr-open-data-explorerSkill
- devsecops-supply-chainSkill
- contract-analysisSkill
- invoice-processingSkill
- agent-eval-frameworkSkill
- tech-debt-detectorSkill
- skill-lifecycle-managementSkill
- context-engineeringSkill
- find-skillsSkill
- fr-comptabiliteSkill
- fr-droit-immobilierSkill
- fr-facturation-electroniqueSkill
- fr-fec-generatorSkill
- fr-fiscalite-investissementSkill
- fr-fiscalite-particulierSkill
- fr-notariatSkill
- fr-recherche-emploiSkill
- offline-first-developmentSkill
- pii-detectionSkill
- skill-quality-linterSkill
- skill-security-auditSkill
- data-sovereignty-patternsSkill
The file
We split this skill into the rules it gives an agent
8 rules. About 0 are common, 8 are distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈8
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
- Distinctive: line 59
Only retry on transient errors (429, 500, 502, 503, timeout)
- Distinctive: line 60
Never retry on client errors (400, 401, 403, 404)
- Distinctive: line 61
Always add jitter to prevent thundering herd
- Distinctive: line 79
If service A fails, services B and C are unaffected
- Distinctive: line 112
Does not implement specific libraries (guides patterns)
- Distinctive: line 113
Does not monitor uptime (use APM tools)
- Distinctive: line 114
Does not manage API keys or authentication
- Distinctive: line 115
Does not handle business logic fallbacks (only infrastructure patterns)
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 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.
Files
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 waitRules:
- 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 |
Rule: Total timeout > (max_retries × request_timeout). Always set all three.
Pattern 6: Graceful Degradation
| Scenario | Fallback |
| Search API down | Return cached results + "results may not be current" |
| Payment API slow | Queue payment, confirm later |
| AI API rate-limited | Switch to cheaper/faster model |
| Database read replica down | Read from primary (accept perf hit) |
Anti-Patterns
| Anti-Pattern | Problem | Fix |
| Retry without backoff | Amplifies load on failing service | Exponential backoff + jitter |
| No timeout | Thread/connection leak | Always set timeouts |
| Retry on all errors | Retrying 401 wastes time | Only retry transient errors |
| Sync retry in UI thread | Blocks user interface | Async retry with status feedback |
| Cascading timeouts | Inner timeout > outer timeout | Budget timeouts from outside in |
What This Skill Does NOT Do
- Does not implement specific libraries (guides patterns)
- Does not monitor uptime (use APM tools)
- Does not manage API keys or authentication
- Does not handle business logic fallbacks (only infrastructure patterns)
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
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.

