Skip to content
secondsky avatar

Api Error Handling

Standardized API error responses with status codes, request IDs, logging, and circuit breakers for production services.

CCM score
51 of 100
skills.sh installs
463
GitHub stars
257
last updated
Aug 21, 2026
View on GitHub

Own this skill? Claim it

What it does

  • Covers the standard error response shape with code, message, status, requestId, timestamp, and per-field details
  • Includes a Node.js ApiError class with badRequest, notFound, and unauthorized factories plus a global Express error handler
  • Enforces hiding internal error messages and stack traces from clients on 5xx responses while logging them server-side
  • Provides a circuit breaker and a Python Flask reference covering custom exceptions, exponential-backoff retries, and Sentry integration

Install

$ npx -y skills add secondsky/claude-skills --skill api-error-handling -y

Installs into .agents/skills for every agent it finds here, and .claude/skills for Claude Code.

Files

API Error Handling

Implement robust error handling with standardized responses and proper logging.

Standard Error Response Format

{
  "error": {
    "code": "VALIDATION_ERROR",
    "message": "Invalid request parameters",
    "status": 400,
    "requestId": "req_abc123",
    "timestamp": "2025-01-15T10:30:00Z",
    "details": [
      { "field": "email", "message": "Invalid email format" }
    ]
  }
}

Error Class (Node.js)

class ApiError extends Error {
  constructor(code, message, status = 500, details = null) {
    super(message);
    this.code = code;
    this.status = status;
    this.details = details;
  }

  static badRequest(message, details) {
    return new ApiError('BAD_REQUEST', message, 400, details);
  }

  static notFound(resource) {
    return new ApiError('NOT_FOUND', `${resource} not found`, 404);
  }

  static unauthorized() {
    return new ApiError('UNAUTHORIZED', 'Authentication required', 401);
  }
}

Details

Repository
github.com/secondsky/claude-skills
Categories
Backend & APIs, Go, Python
First seen
Jun 3, 2026

Questions

What does the api-error-handling skill do?

The api-error-handling skill implements standardized API error responses with proper status codes, logging, and user-friendly messages. It gives a Node.js ApiError class, a global error handler, and a circuit breaker pattern for error recovery.

How do I install the api-error-handling skill?

Run npx -y skills add secondsky/claude-skills --skill api-error-handling -y in your project to install the api-error-handling skill. After that, the agent can apply its consistent error format with request IDs to the API endpoints you build.

Who should use api-error-handling?

The api-error-handling skill is for developers building production APIs, implementing error recovery patterns, or integrating error monitoring services. It covers Python Flask error handling and Sentry integration in its reference file.

Does api-error-handling need any tools or accounts?

The api-error-handling SKILL.md lists no accounts or API keys. Its Node.js examples assume an Express-style app with a logger and request IDs, and its Python and Sentry material lives in a separate reference file.

More from secondsky/claude-skills

All 116

Similar to Api Error Handling

More Backend & APIs