error-handling-architecture
Skill0 starsChanged 5 months agoMITView on GitHub
Designs system-wide error handling, propagation, and recovery strategy distinguishing recoverable faults from bugs. Use when defining how failures flow through a system, choosing exceptions vs result types, designing retries/timeouts/fallbacks, or when error handling is ad hoc and failures cascade.
We split this skill into the rules it gives an agent
5 rules. About 0 are common, 5 are distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈5
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 12
Every failure falls into one of three buckets — they demand opposite responses:
- Distinctive: line 23
Add context on the way up (what operation, which inputs) without leaking internals to untrusted callers.
- Distinctive: line 28
Timeout: every remote call needs one.
- Distinctive: line 29
Retry: only for idempotent ops; use exponential backoff + jitter.
- Distinctive: line 30
Circuit breaker: stop hammering a dead dependency.
≈ “Common” is an estimate: at least 1 in 5 of the 308,232 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
Error Handling Architecture
Errors are control flow you forgot to design. A system's behavior under failure is its real behavior; the happy path is the rare case at scale.
Classify before you handle
Every failure falls into one of three buckets — they demand opposite responses:
- Bugs (programmer errors): broken invariants, nulls that "can't happen". Fail fast and loud; do not catch-and-continue. Recovering from a bug corrupts state.
- Expected operational faults: network blips, contention, rate limits, transient unavailability. Anticipate, retry with bounds, degrade gracefully.
- Domain outcomes: "insufficient funds", "not found". These are not errors — model them as ordinary return values, not exceptions.
Conflating these is the root cause of most bad error handling: catching bugs as if they were faults, or modeling business outcomes as exceptions.
Propagation strategy
- Decide where errors are handled vs propagated. Handle at the layer with enough context to act; propagate (with added context) everywhere else. Don't catch what you can't meaningfully handle.
- Add context on the way up (what operation, which inputs) without leaking internals to untrusted callers.
- Pick one mechanism per layer (exceptions vs result types) and convert deliberately at boundaries; mixing silently drops errors.
Recovery primitives — and their failure modes
- Timeout: every remote call needs one; an unbounded wait is a liveness bug. Tune to the dependency's p99, not its mean.
- Retry: only for idempotent ops; use exponential backoff + jitter. Naive retries cause retry storms that amplify the outage.
- Circuit breaker: stop hammering a dead dependency; trade freshness for system survival.
- Bulkhead: isolate resource pools so one failing dependency can't exhaust threads for all.
- Fallback / degrade: define the reduced-but-correct mode (stale cache, default, queue-for-later).
Adversarial validation
- Trace one failure end to end: does it surface, get swallowed, or cascade? Swallowed errors are the worst — they corrupt silently.
- Does a retry policy multiplied across N callers DDoS your own dependency?
- On partial failure of a multi-step operation, is the system left consistent or half-written? (Needs compensation/saga or atomicity.)
- Does the error path allocate, lock, or call the failing dependency again? Error handling must be cheaper and more robust than the happy path.
Non-obvious risks
- Logging-and-rethrow at every layer produces duplicate noise and hides the real handler.
- Catch-all handlers turn crash-worthy bugs into silent data corruption that surfaces days later.
- Fallbacks can mask outages until the fallback itself fails under load with no headroom left.
Output structure
Deliver: the three-way classification applied to the actual failures, the propagation boundaries, the recovery primitives with their tuning and idempotency constraints, and a traced example proving a representative failure ends in a defined, consistent state.
In this repository29 other files it gives its agents.
- adversarial-code-reviewSkill
- api-contract-designSkill
- attack-surface-mappingSkill
- authn-authz-design-reviewSkill
- benchmark-designSkill
- capacity-scalability-planningSkill
- concurrency-race-analysisSkill
- data-consistency-modelingSkill
- data-exfiltration-analysisSkill
- distributed-consensus-designSkill
- event-driven-architectureSkill
- experiment-designSkill
- hypothesis-falsificationSkill
- incident-rca-postmortemSkill
- legacy-refactoring-strategySkill
- literature-synthesisSkill
- metrics-designSkill
- multi-layer-caching-strategySkill
- mvp-scope-cuttingSkill
- performance-profilingSkill
- rate-limiting-designSkill
- requirements-disambiguationSkill
- secrets-management-auditSkill
- statistical-validity-analysisSkill
- supply-chain-risk-analysisSkill
- system-decomposition-synthesisSkill
- threat-modelingSkill
- tradeoff-decision-frameworkSkill
- user-failure-mode-mappingSkill
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.

