error-handling
Skill3 starsChanged 4 months agoMITView on GitHub
Use when designing error-handling strategy for a feature — error classification, throw-vs-return conventions, retry/circuit-breaker/fallback decisions, and error-to-user-message mapping. Triggers on "error handling", "retry strategy", "circuit breaker", "error propagation", "错误处理", "重试策略", "熔断", "降级" — also when user says "这个错误该怎么处理" / "要不要重试". Not for diagnosing a specific bug (use debugging); system-level resilience architecture (use architecture).
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 logging, state-management 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.
diego-tobalinaSkilllogging
Logging best practices for Java (SLF4J/Logback) and Node.js (Winston/Pino). Use for structured logging, log levels, and avoiding sensitive data exposure.
Also in 5 projects that use this
conorluddySkillstate-management
Cache management, configuration best practices, and progressive disclosure patterns for efficient context window usage. Use when working with large responses, optimizing token costs, or managing plugin state across operations.
Also in 5 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
ElasticSkillaccessibility
Accessibility guidance for Kibana. Use this skill when working with or reviewing EUI components, resolving a11y-related (@elastic/eui) ESLint issues, and ensuring proper use of ARIA attributes, focus management, keyboard interactions, and accessible naming conventions.
Also in 5 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 repository49 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- brainstormSkill
- oss-strategySkill
- specSkill
- researchSkill
- api-designSkill
- architectureSkill
- codebase-designSkill
- design-researchSkill
- domain-modelingSkill
- frontend-designSkill
- imagegenSkill
- image-to-codeSkill
- prompt-engineeringSkill
- prototypeSkill
- schema-designSkill
- auth-implementationSkill
- breakdownSkill
- context-engineeringSkill
- i18nSkill
- implementSkill
- multi-agent-orchestrationSkill
- cost-optimizationSkill
- performanceSkill
- refactoringSkill
- simplifySkill
- api-testingSkill
- e2e-testingSkill
- load-testingSkill
- tddSkill
- test-generationSkill
- a11y-reviewSkill
- code-reviewSkill
- debuggingSkill
- lintingSkill
- security-reviewSkill
- ci-cdSkill
- deprecation-migrationSkill
- git-workflowSkill
- oss-polishSkill
- shippingSkill
- documentation-auditSkill
- handoffSkill
- incident-responseSkill
- observabilitySkill
- purity-auditSkill
- skill-authoringSkill
- using-skillsSkill
The file
We split this skill into the rules it gives an agent
6 rules. 0 are common, 4 are distinctive, and 2 are very specific to this project.
0
Common
Most of the 37 edited versions we read keep these.
4
Distinctive
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 21
Every error falls into one of four categories, and the category drives the strategy:
- Distinctive: line 30
If you can't classify an error, default to permanent — retrying an unclassified error masks real bugs.
- Very specific: line 39
Follow the language ecosystem's dominant convention: Rust/Go return error values.
- Distinctive: line 61
When a dependency fails, decide what the user gets instead:
- Distinctive: line 72
Generic external, specific internal: never expose SQL fragments, stack traces, or internal hostnames to users.
- Very specific: line 80
No secrets: redact tokens, passwords, PII before logging (see debugging skill's redaction discipline).
“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
When to use
- Designing how errors propagate across layers for a new feature or service boundary
- Choosing retry, circuit-breaker, or fallback strategy for calls to external systems
- Establishing throw-vs-return conventions for a module or codebase
- Mapping internal errors to user-facing messages at an edge boundary
Not for: diagnosing a specific bug or test failure (use debugging); system-level resilience architecture — cross-service error strategy, overall failure posture (use architecture, specifically architecture/references/error-resilience.md); API error response envelope shape (use api-design); production logging/metrics instrumentation (use observability).
Steps
For system-level resilience architecture (cross-service error propagation, failure posture design), read architecture's error-resilience reference first. This skill is the implementation-level companion — the decisions you make at the keyboard when writing the error-handling code.
1. Classify errors
Every error falls into one of four categories, and the category drives the strategy:
| Category | Examples | Strategy |
| Transient | network timeout, 503, connection reset | retry with backoff (step 3) |
| Permanent | 404, 400, logic failure | fail fast, no retry |
| Validation | bad input, schema mismatch | return 422-style result to caller |
| Auth | expired token, insufficient scope | return 401/403, prompt re-auth |
If you can't classify an error, default to permanent — retrying an unclassified error masks real bugs.
2. Choose throw-vs-return convention
Pick one convention per layer and enforce it (architecture ref §1 has the full rationale):
- Throw (exceptions) for invariant violations and infrastructure failures — "this should never happen, the operation cannot continue." Catch at boundaries, not at every call.
- Return (Result/error values) for expected, recoverable failures the caller must branch on — not-found, conflict, validation. A 404 is a result, not an exception.
Follow the language ecosystem's dominant convention: Rust/Go return error values; Python/Java/JS throw. Fighting the ecosystem creates inconsistent code.
3. Design retry strategy (transient errors only)
Retry only transient errors. Retrying permanent errors wastes resources and can amplify failures. See references/retry-patterns.md for formulas and code.
- Exponential backoff + jitter: base × 2^n, capped, with jitter to prevent retry stampedes. Full jitter (random between 0 and the capped value) is the safe default.
- Max attempts: 3 covers most transient blips. More than 5 rarely helps and delays failure.
- Idempotency: retry only idempotent operations (GET, PUT, DELETE with stable IDs). For POST, require an idempotency key so a retry after an ambiguous timeout doesn't double-charge or double-create.
- Timeout on every call. A call without a timeout can hang forever and hold resources.
4. Add circuit breaker when retry is not enough
Retry handles isolated transient failures. A circuit breaker protects a struggling downstream from retry storms during a sustained outage.
- States: closed (normal) → open (fail fast, no calls) → half-open (probe one request to test recovery).
- Open threshold: N consecutive failures or a failure-rate threshold (e.g., 50% over a rolling window).
- Cooldown: fixed time or exponential reset. Half-open probes one request; success closes, failure re-opens.
- Use when: a downstream dependency has repeated sustained outages and retries would make things worse. Don't add a circuit breaker for a call that rarely fails.
5. Plan graceful degradation
When a dependency fails, decide what the user gets instead:
- Critical path (payment, auth, core data): fail the request — no degradation.
- Non-critical path (recommendations, search, analytics): catch the failure, serve a fallback (cached data, empty state, default) — the core page still renders.
- Feature-flag kill switch: for integration failures that recur, a flag to disable the feature path instantly beats debugging under load.
6. Map errors to user-facing messages (at the edge)
Maintain a single mapping from stable error codes to user-facing messages, at the edge boundary (architecture ref §3):
- Stable error codes (
PAYMENT_DECLINED,RATE_LIMITED), not free text. The code is the cross-service contract. - Generic external, specific internal: never expose SQL fragments, stack traces, or internal hostnames to users. Map to "Could not complete this action" + a correlation ID for support.
- Actionable: tell the user what to do ("Check your payment details and try again").
7. Log with structured context
Log every error with enough context to reproduce the diagnosis without re-running:
- Structured fields: error code, operation, correlation ID, request context.
- No secrets: redact tokens, passwords, PII before logging (see
debuggingskill's redaction discipline). - Log at the boundary where the error is handled, not at every catch site — duplicated logs obscure the real failure path.
Verify
- Every error in the new code is classified (transient / permanent / validation / auth) — strategy follows classification
- Throw-vs-return convention is consistent within each layer; no exceptions used for expected control flow
- Retry only fires on transient, idempotent operations; max attempts and backoff are set
- Circuit breaker (if used) has defined thresholds, cooldown, and half-open probe logic
- Non-critical dependency failures degrade gracefully (fallback/empty state), not cascade to a full page failure
- User-facing errors use stable codes + generic messages; no internal details leak
- Errors are logged with structured context and a correlation ID; no secrets in log output
- Tests cover: retry on transient, no-retry on permanent, circuit-breaker open/half-open/closed transitions, fallback path
References
- ${CLAUDE_PLUGIN_ROOT}/references/engineering-principles.md — discipline shared by every skill
- ${CLAUDE_PLUGIN_ROOT}/skills/03-design/architecture/references/error-resilience.md — system-level resilience architecture (cross-layer error propagation, failure posture); this skill is its implementation-level companion
- references/retry-patterns.md — backoff/jitter formulas, circuit breaker state machine, idempotency-key patterns, retry budgets (with code)
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.

