
Circuit Breaker Pattern
Prevents cascading failures when your dependencies go down by wrapping calls in a state machine that trips open after repeated failures, then periodically tests if the service has recovered. Includes TypeScript, Python, and Java implementations with configurable failure thresholds, timeout handling, and half-open testing states. The monitoring examples are solid if you're running this in production. Honestly essential for any system calling flaky external APIs or microservices, though you'll want to tune the thresholds carefully since the defaults won't match your actual traffic patterns. The Opossum and Resilience4j style guides are nice if you're familiar with those libraries.
- skills.sh installs
- 480
- GitHub stars
- 379
- last updated
- Aug 21, 2026
Install
$ npx -y skills add aj-geddes/useful-ai-prompts --skill circuit-breaker-pattern --agent claude-codeInstalls into .claude/skills of the current project.
Files
Circuit Breaker Pattern
Table of Contents
Overview
Implement circuit breaker patterns to prevent cascading failures and provide graceful degradation when dependencies fail.
When to Use
- External API calls
- Microservices communication
- Database connections
- Third-party service integrations
- Preventing cascading failures
- Implementing fallback mechanisms
- Rate limiting protection
- Timeout handling
Quick Start
Minimal working example:
enum CircuitState {
CLOSED = "CLOSED",
OPEN = "OPEN",
HALF_OPEN = "HALF_OPEN",
}
interface CircuitBreakerConfig {
failureThreshold: number;
successThreshold: number;
timeout: number;
resetTimeout: number;
}
interface CircuitBreakerStats {
failures: number;
successes: number;
consecutiveFailures: number;
consecutiveSuccesses: number;
lastFailureTime?: number;
}
Sponsors
Details
- Repository
- github.com/aj-geddes/useful-ai-prompts
- Category
- AI & Agent Building
- First seen
- Jun 3, 2026
More from aj-geddes/useful-ai-prompts
All 258- Batch Processing Jobs479
- Aws Cloudfront Cdn478
- Mutation Testing478
- Api Changelog Versioning477
- Csrf Protection477
- Developer Onboarding477
- Concurrency Patterns476
- Django Application476
- Deployment Automation475
- Gcp Cloud Functions475
- Api Versioning Strategy472
- Cloud Security Configuration472
- Aws Ec2 Setup470
- Email Service Integration470
- Infrastructure Monitoring470
- Angular Module Design469
- Pull Request Automation468
- Database Monitoring467
- Idempotency Handling467
- Session Management466
- Query Caching Strategies465
- Risk Assessment465
- Error Tracking463
- Spring Boot Application463