Back to Skills

error-handling

Patterns for robust error handling across TypeScript, Python, and Go. Covers typed errors, error boundaries, retries, circuit breakers, and user-facing error messages.

230,274stars35,238forksUpdated 7/16/2026

Security Assessment

Safe(100/100)
Security Score100/100

About error-handling

error-handling provides consistent, robust error handling patterns for production applications across TypeScript/JavaScript, Python, and Go. It solves the problem of ad hoc, inconsistent error handling by giving concrete, language-specific templates for typed errors, API error handlers, error boundaries, and error wrapping, so that failures surface clearly, carry structure, and become part of a documented API contract rather than being silently swallowed.

The skill is built around five core principles: fail fast and loudly at the boundary where errors occur, prefer typed errors over string messages, keep user messages distinct from developer messages (friendly text for users, full context logged server-side), never swallow errors silently (every catch must handle, re-throw, or log), and treat errors as part of the API contract by documenting every error code a client may receive. It supplies ready-to-use code for TypeScript including a typed AppError hierarchy (NotFoundError, ValidationError, UnauthorizedError, RateLimitError), a no-throw Result pattern with ok/err helpers, an API error handler for Next.js/Express (handling AppError and Zod ZodError, and returning a generic message for unexpected errors), and a React ErrorBoundary component. For Python it provides a custom exception hierarchy and a FastAPI global exception handler. For Go it demonstrates sentinel errors, error wrapping with %w, and handler-level unwrapping via errors.Is.

The skill is meant to activate when designing error types or exception hierarchies for a new module or service, adding retry logic or circuit breakers for unreliable external dependencies, reviewing API endpoints for missing error handling, implementing user-facing error messages and feedback, or debugging cascading failures or silent error swallowing. It targets backend and full-stack engineers working in TypeScript, Python, or Go who want production-grade, uniform error handling. The documentation is a single SKILL.md of patterns and code samples, so it serves as reference guidance to adapt rather than an installable tool with its own commands.

FAQ

Which languages does this skill cover?

It covers TypeScript/JavaScript, Python, and Go, with typed error hierarchies, framework-specific handlers (Next.js/Express, React, FastAPI), and Go sentinel errors with error wrapping.

What are the core error-handling principles?

Fail fast and loudly at the boundary, prefer typed errors over string messages, keep user messages distinct from developer messages, never swallow errors silently (every catch must handle, re-throw, or log), and treat errors as part of your API contract by documenting every error code a client may receive.

What is the Result pattern it describes?

For operations where failure is expected and common (parsing, external calls), it uses a no-throw Result<T, E> type that is either { ok: true; value } or { ok: false; error }, with ok() and err() helper functions, letting TypeScript narrow to value or error after checking result.ok.

How does it recommend handling unexpected errors in an API?

The API error handler returns structured responses for known AppError and Zod validation errors, but for unexpected errors it logs the full details server-side and returns a generic message (code INTERNAL_ERROR, status 500) so internal details are not leaked to clients.

When should this skill activate?

When designing error types or exception hierarchies, adding retry logic or circuit breakers for unreliable dependencies, reviewing API endpoints for missing error handling, implementing user-facing error messages, or debugging cascading failures or silent error swallowing.

Install error-handling

Download and extract the skill files to your .claude/skills/ directory.

Quick Setup:

  1. Copy the skill folder to .claude/skills/
  2. Claude will automatically detect and use the skill