backend-resilience-patterns
Use when the user asks about a circuit breaker around a flaky service, retries with backoff and jitter, timeouts, bulkheads, fallbacks, Resilience4j or Polly…
от j4flmao★ 47 звёзд на GitHub
Установить backend-resilience-patterns в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Об этом скилле
Backend Resilience Patterns
Purpose
Protect backend services from cascading failures by applying circuit breakers, retries with backoff, bulkheads, timeouts, and fallbacks. Resilience is not optional — every external call must be wrapped in fault-tolerance patterns.
Agent Protocol
Trigger
Exact user phrases: "resilience", "circuit breaker", "retry", "bulkhead", "timeout", "fallback", "resilience4j", "fault tolerance", "retry strategy", "backoff", "rate limiter".
Input Context
- Type of external calls (HTTP, database, message queue).
- Existing retry or timeout configuration.
- SLAs and latency requirements.
Output Artifact
Configuration snippets or code. No file unless requested.
Response Format
Pattern: {circuit-breaker|retry|bulkhead|timeout|fallback}
Config: {key parameters and values}
Completion Criteria
- At least timeout configured for every external call.
- Retry with exponential backoff and jitter configured.
- Circuit breaker defined per dependency (not one for all).
- Fallback handler defined for every circuit breaker.
- Bulkhead isolation applied to thread pools where needed.
Max Response Length
4 lines per pattern. 20 lines for full configuration.
Architecture Decision Tree
Which Resilience Pattern?
What type of failure are you protecting against?
├── Slow responses (server busy, GC pause, overloaded)
│ └── Timeout + Circuit Breaker
├── Transient failures (network blip, connection reset, DNS failure)
│ └── Retry with backoff + Circuit Breaker
├── Resource exhaustion (thread pool, connection pool, memory)
│ └── Bulkhead + Circuit Breaker
├── Downstream service completely down
│ └── Circuit Breaker + Fallback
└── Client sending too many requests
└── Rate Limiter + Bulkhead
Pattern Composition Order
How should patterns be composed?
┌─────────────────────────────────┐
│ 1. Timeout (outermost) │ ← Fail fast
│ 2. Bulkhead (semaphore limit) │ ← Isolate resources
│ 3. Circuit Breaker │ ← Stop cascading failures
│ 4. Retry (innermost) │ ← Retry transient failures
│ 5. Fallback (catch-all) │ ← Degrade gracefully
└─────────────────────────────────┘
Timeout Strategy Decision
What is the nature of the downstream call?
├── Internal service (same datacenter) → 2-5s
├── External API (third-party) → 5-10s
├── Database query → 5-30s (depending on query)
├── Batch/analytics query → 30-60s
└── Must be LOWER than the caller's timeout of YOU
Workflow
Step 1: Configure Timeouts
Every external call needs a timeout. No exceptions.
timeouts:
http_internal: { connect: 2s, read: 5s, write: 5s }
http_external: { connect: 5s, read: 10s, write: 10s }
database: { query: 10s, transaction: 30s }
message_queue: { publish: 5s, consume: 30s }
Step 2: Configure Retries
retry:
max_attempts: 3
backoff: exponential
initial_delay: 100ms
multiplier: 2
jitter: 50ms
max_delay: 10s
retry_on:
- 5xx (except 500 if idempotent)
- network_error
- timeout
do_not_retry:
- 4xx (client errors)
- 400 (bad request — will always fail)
- 401/403 (auth — will always fail)
- 404 (not found — will always fail)
- 409 (conflict — needs human resolution)
async function retryWithBackoff(fn, options = {}) {
const { maxAttempts = 3, initialDelay = 100, maxDelay = 10000 } = options;
for (let attempt = 1; attempt <= maxAttempts; attempt++) {
try {
return await fn();
} catch (error) {
if (attempt === maxAttempts) throw error;
if (!isRetryable(error)) throw error;
const delay = Math.min(initialDelay * Math.pow(2, attempt - 1), maxDelay);
const jitter = delay * 0.5 * Math.random();
await sleep(delay + jitter);
}
}
}
Step 3: Configure Circuit Breaker
circuit_breaker:
per_dependency: true # One CB per downstream service
sliding_window_size: 10 # Number of calls to evaluate
minimum_calls: 5 # Minimum before evaluating
failure_rate_threshold: 50 # % failures to open circuit
wait_duration_open: 30s # Time before half-open
half_open_max_calls: 3 # Probe requests in half-open
record_slow_calls: true # Treat slow calls as failures
slow_call_duration_threshold: 5s # What counts as "slow"
// Node.js implementation using opossum
import CircuitBreaker from 'opossum';
const circuitBreaker = new CircuitBreaker(callExternalService, {
timeout: 5000,
errorThresholdPercentage: 50,
resetTimeout: 30000,
volumeThreshold: 5,
});
circuitBreaker.fallback(() => {
return { status: 'degraded', cachedData: getStaleData() };
});
circuitBreaker.on('open', () => logger.warn('Circuit breaker opened for payment-service'));
circuitBreake
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
- references/bulkhead-patterns.md
- references/circuit-breaker-patterns.md
- references/fallback-strategies.md
- references/resilience-cache.md
- references/resilience-testing.md
- references/resilience4j-guide.md
- references/retry-backoff-strategies.md
- references/timeout-retry-patterns.md
FAQ
Что делает скилл backend-resilience-patterns?
Use when the user asks about a circuit breaker around a flaky service, retries with backoff and jitter, timeouts, bulkheads, fallbacks, Resilience4j or Polly. Produces fault-tolerance config and code per dependency. Not for API request throttling (use rate-limiting).
Как установить скилл backend-resilience-patterns?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл backend-resilience-patterns запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
AnthropicGuide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
claude-api
AnthropicReference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
algorithmic-art
AnthropicCreating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
mcp-integration
AnthropicThis skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…