error-handling
Skill1 starsChanged 9 months agoMITView on GitHub
Designs error handling strategies across application layers. Covers error types, propagation patterns, user-facing errors, retry logic, circuit breakers, and graceful degradation. Use when designing error handling, reviewing error paths, or debugging error propagation issues.
44 other projects use a version of this.
Adopted by
Most recently taken up by
- SkillMedev/ai-engineer-toolkittheir own version, first seen Oct 5, 2026
- LuisUrrutia/skillstheir own version, first seen Oct 4, 2026
- JameMy0001/antigravity-skills-hubtheir own version, first seen Oct 2, 2026
- aprameyak/coding-skillstheir own version, first seen Oct 2, 2026
- komluk/scaffoldingtheir own version, first seen Sep 28, 2026
- alfredobs97/flutter_agentic_templatetheir own version, first seen Sep 24, 2026
Used with
Projects with it also use refactoring, react-patterns and 3 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
pproencaSkillrefactoring
Code refactoring best practices based on Martin Fowler's catalog and Clean Code principles. This skill should be used when refactoring existing code, improving code structure, reducing complexity, eliminating code smells, or reviewing code for maintainability. Triggers on tasks involving extract method, rename, decompose conditional, reduce coupling, or improve readability.
Also in 6 projects that use this
benshapyroSkillreact-patterns
Modern React patterns for TypeScript applications including hooks, state management, and component composition. Use when building React components, managing state, or implementing React best practices.
Also in 4 projects that use this
OpenAISkillobservability
Vercel Observability expert guidance — Drains (logs, traces, speed insights, web analytics), Web Analytics, Speed Insights, runtime logs, custom events, OpenTelemetry integration, and monitoring dashboards. Use when instrumenting, debugging, or optimizing application performance and user experience on Vercel.
Also in 5 projects that use this
BlockSkilldebugging
Debugging guidelines and best practices
Also in 7 projects that use this
AnthropicSkilltesting-strategy
Design test strategies and test plans. Trigger with "how should we test", "test strategy for", "write tests for", "test plan", "what tests do we need", or when the user needs help with testing approaches, coverage, or test architecture.
Also in 3 projects that use this
Other versions44 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 44
- microsoft/data-formulator★ 18ksame name
- CloudAI-X/claude-workflow-v2★ 1.4ksame name
- codewithmukesh/dotnet-claude-kit★ 750same name
- templetongroup/radiant★ 113same name
- DevelopersGlobal/ai-agent-skills★ 69same name
- metarhia/metaskills★ 57same name
- suhailkakar/the-skills★ 26same name
- komluk/scaffolding★ 15same name
- zircote-plugins/claude-team-orchestration★ 15same name
- wpank/ai★ 11same name
34 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository48 other files it gives its agents.
- accessibilitySkill
- api-designSkill
- api-integrationSkill
- architectSkill
- async-patternsSkill
- best-practicesSkill
- bugSkill
- buildSkill
- cachingSkill
- ci-cdSkill
- config-managementSkill
- containerizeSkill
- database-designSkill
- data-modelingSkill
- data-pipelineSkill
- debug-latencySkill
- dependency-updateSkill
- deploySkill
- dev-setupSkill
- docsSkill
- estimateSkill
- feature-flag-opsSkill
- git-recoverySkill
- i18nSkill
- iacSkill
- incidentSkill
- load-testingSkill
- loggingSkill
- migrateSkill
- monitoringSkill
- observability-debugSkill
- onboardSkill
- perfSkill
- phase-gateSkill
- pr-authorSkill
- qaSkill
- refactorSkill
- reviewSkill
- rollbackSkill
- schema-evolutionSkill
- scope-checkSkill
- security-auditSkill
- state-managementSkill
- tech-debtSkill
- tech-stackSkill
- telemetrySkill
- testingSkill
- workflowSkill
The file
We split this skill into the rules it gives an agent
9 rules. 0 are common, 9 are distinctive, and 0 are very specific to this project.
0
Common
Most of the 37 edited versions we read keep these.
9
Distinctive
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 23
Handle at the right level: Don't catch errors where you can't do anything useful.
- Distinctive: line 26
Don't swallow errors: Every caught error must be: handled (recovered), re-thrown (propagated), or logged (recorded).
- Distinctive: line 27
Users get friendly messages. Developers get details: Never expose stack traces, SQL errors, or internal state to users.
- Distinctive: line 53
Only retry transient errors.
- Distinctive: line 75
Only retry idempotent operations (GET, PUT - not POST unless designed for it)
- Distinctive: line 80
When a dependency is consistently failing, stop calling it instead of piling up timeouts.
- Distinctive: line 97
When a non-critical dependency fails, keep the core experience working:
- Distinctive: line 107
Rule: Only the critical path should be able to take down the whole request.
- Distinctive: line 129
Never blame the user ("Invalid input" → "Please enter a valid email address")
“Common” is measured: kept by at least 6 in 10 of the 37 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Error Handling
Good error handling means: users get a clear message, developers get a clear trace, and the system recovers when possible.
Error Categories
| Category | Recoverable? | Action | Example |
| Validation | Yes (by user) | Return specific error, show to user | Invalid email, missing field, out of range |
| Business rule | Yes (by user) | Return clear explanation | Insufficient balance, expired coupon, duplicate entry |
| Transient | Yes (by retry) | Retry with backoff | Network timeout, 503, database connection reset |
| Dependency failure | Maybe | Circuit breaker, fallback | Payment API down, search service unreachable |
| Programming error | No | Crash, fix the code | Null dereference, type error, assertion failure |
| Infrastructure | No | Alert, ops response | Disk full, OOM, certificate expired |
Principles
- Handle at the right level. Don't catch errors where you can't do anything useful. Let them propagate to where there's enough context to respond.
- Fail fast. Detect errors as early as possible. Validate inputs at the boundary, not deep in business logic.
- Be specific. Catch specific error types, not all errors. A blanket catch hides bugs.
- Don't swallow errors. Every caught error must be: handled (recovered), re-thrown (propagated), or logged (recorded).
- Users get friendly messages. Developers get details. Never expose stack traces, SQL errors, or internal state to users.
Error Propagation Pattern
Boundary (API/UI)
→ Validate input → return 400 with field-level errors
→ Call business logic
→ Business rule violated → return domain error
→ Call external service
→ Timeout → retry (up to N times)
→ Still failing → circuit breaker → fallback or error
→ Unexpected error → log with context → return 500 generic messageAt Each Layer
| Layer | Catch | Action |
| Controller/Handler | Validation errors | Return 400 with details |
| Service/Business | Domain errors | Return typed error (InsufficientFunds, NotFound, etc.) |
| Client/Integration | Network errors | Retry, circuit break, fallback |
| Global handler | Everything else | Log, return generic 500, alert if new |
Retry Logic
Only retry transient errors. Never retry validation errors or business rule violations.
MAX_RETRIES = 3
INITIAL_DELAY = 100ms
MAX_DELAY = 5000ms
for attempt in 1..MAX_RETRIES:
try:
result = call_service()
return result
catch TransientError:
if attempt == MAX_RETRIES:
raise
delay = min(INITIAL_DELAY * 2^attempt + jitter(), MAX_DELAY)
sleep(delay)Rules:
- Exponential backoff with jitter (not fixed delay)
- Cap the maximum delay
- Set a maximum number of retries
- Only retry idempotent operations (GET, PUT - not POST unless designed for it)
- Log each retry attempt
Circuit Breaker
When a dependency is consistently failing, stop calling it instead of piling up timeouts.
States:
CLOSED (normal) → requests pass through
OPEN (tripped) → requests fail immediately, no calls made
HALF-OPEN (testing) → one request passes to test recovery
Transitions:
CLOSED → OPEN: when failure rate > threshold (e.g., 50% of last 20 calls)
OPEN → HALF-OPEN: after cooldown period (e.g., 30 seconds)
HALF-OPEN → CLOSED: if test request succeeds
HALF-OPEN → OPEN: if test request failsGraceful Degradation
When a non-critical dependency fails, keep the core experience working:
| Dependency Down | Degrade To |
| Recommendation service | Show popular items instead |
| Avatar service | Show default avatar |
| Analytics | Queue events locally, flush later |
| Search | Show category browsing |
| Cache (Redis) | Fall through to database (slower but works) |
Rule: Only the critical path should be able to take down the whole request. Everything else degrades.
User-Facing Error Messages
Good
"That email address is already registered. Try logging in instead."
"Payment failed - your card was declined. Please try a different card."
"This item is no longer available."Bad
"Error 500: Internal Server Error"
"NullPointerException at UserService.java:142"
"SQLSTATE[23505]: duplicate key violates unique constraint"Guidelines
- Say what happened in plain language
- Suggest what the user can do
- Include an error reference ID for support (
Error ID: req_abc123) - Never blame the user ("Invalid input" → "Please enter a valid email address")
Error Response Format (APIs)
{
"error": {
"code": "INSUFFICIENT_BALANCE",
"message": "Your account balance is too low for this transaction.",
"details": {
"required": 5000,
"available": 3200,
"currency": "USD"
},
"request_id": "req_abc123"
}
}code: Machine-readable, stable (clients can switch on it)message: Human-readable, can change (don't parse this)details: Structured data relevant to the specific errorrequest_id: For tracing and support
Anti-Patterns
| Anti-Pattern | Problem | Fix |
| Catch all, log, continue | Hides bugs, corrupts state | Catch specific errors, handle or propagate |
| Return null on error | Caller doesn't know something failed | Throw/return typed error |
| Boolean success flag | No error details, no context | Return result or error, not (bool, data) |
| Retry non-idempotent ops | Duplicate orders, double charges | Only retry idempotent operations |
| No timeout on external calls | Thread/connection blocked forever | Always set timeouts |
| Exception for control flow | Slow, confusing, anti-pattern | Use normal returns for expected cases |
Review Checklist
- Validation errors return field-level details
- Business errors are typed (not generic strings)
- Transient errors retried with backoff
- External calls have timeouts
- Errors logged with request context
- Users see friendly messages, not stack traces
- Global error handler catches unexpected errors
- No swallowed exceptions (catch without handle/log/rethrow)
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.

