Sponsor Suno AI Music arrow_forward
Slash Command

Implement Error Handling

Implement standardized API error handling

Type
Slash Command
GitHub stars
2.8k
License
MIT
Repo last updated
Sep 27, 2026

What Implement Error Handling is

Implement Error Handling is a slash command published in the jeremylongshore/tons-of-skills-marketplace repository on GitHub, which has about 2.8k stars. The repository describes itself as: “Model-agnostic agent-skills platform with a harness-free canonical layer, verified adapters, and the ccpi package manager. Explore at tonsofskills.com.”

A slash command is a reusable prompt saved as a markdown file and run by typing its name after a slash. In Claude Code, custom commands have been merged into skills: a file in .claude/commands/ and a skill folder in .claude/skills/ both create the same kind of command, and existing command files keep working.

Implement Error Handling gives you a repeatable way to run the same instructions without retyping them, optionally with arguments.

How to install Implement Error Handling

Claude Code

  1. Download implement-error-handling.md from the repository.
  2. Save it to ~/.claude/commands/ (all projects) or .claude/commands/ (one project). As a skill, you can instead save it as ~/.claude/skills/<name>/SKILL.md.
  3. Run it by typing / followed by its name.

Claude Cowork

  1. Turn the command into a skill: create a folder with the file saved as SKILL.md and zip it.
  2. In Customize → Skills, click +, then upload the ZIP.
  3. Run it from any task with / and the skill name.

New to extending Cowork? Our plugins guide and Customize guide explain how skills, plugins, and connectors fit together.

Inside the source file

An excerpt from plugins/api-development/api-error-handler/commands/implement-error-handling.md, shared under the repository's MIT license. Read the full file on GitHub.

Create standardized, production-ready error handling middleware with proper HTTP status codes, consistent error formats, and comprehensive logging. This command generates custom error classes, middleware, and error recovery strategies for Node.js, Python, and other backend frameworks.

Design Decisions

Why standardized error handling matters:

  • Client experience: Consistent error formats make client integration predictable
  • Debugging: Structured errors with context accelerate troubleshooting
  • Security: Proper error handling prevents information leakage in production
  • Monitoring: Standardized errors integrate cleanly with observability tools

Alternatives considered:

  • HTTP-only errors: Simpler but lacks context for debugging
  • Framework defaults: Inconsistent across endpoints, lacks business context
  • Exception-based only: Can leak sensitive information, harder to test

This approach balances: Developer experience, security, debugging, and API consistency.

When to Use

Use this command when:

  • Starting a new API project that needs error handling
  • Refactoring inconsistent error responses across endpoints
  • Adding error monitoring and alerting to an existing API
  • Migrating from generic framework errors to business-specific errors
  • Implementing error handling for microservices that need consistency

Don't use when:

  • Your framework's default error handling already meets your needs
  • Building proof-of-concept code without production requirements
  • Working with legacy systems that can't adopt new error formats

Prerequisites

  • Node.js 16+ (for Express/Fastify examples) or Python 3.8+ (for Flask/FastAPI)
  • Existing API project structure
  • Basic understanding of HTTP status codes (4xx client errors, 5xx server errors)
  • (Optional) Logging framework installed (Winston, Pino, Structlog)
  • (Optional) Monitoring service (Sentry, DataDog, New Relic)

Process

  1. Generate Custom Error Classes
  • Create base error class with HTTP status codes
  • Define specific error types (ValidationError, NotFoundError, AuthError)
  • Add error codes for programmatic handling
  1. Build Error Middleware
  • Catch all errors in centralized handler
  • Format errors consistently (RFC 7807 Problem Details or custom)
  • Handle both operational and programmer errors
  1. Configure Environment-Specific Behavior
  • Development: Include stack traces, detailed messages
  • Production: Sanitize errors, log internally, return safe messages
  1. Integrate Logging
  • Log all errors with context (request ID, user, endpoint)
  • Add severity levels (error, warning, critical)
  • Include metadata for troubleshooting
  1. Add Error Recovery
  • Graceful degradation strategies
  • Retry logic for transient failures
  • Circuit breaker integration

Output Format

Express.js Error Handler

// errors/AppError.js
class AppError extends Error {
  constructor(message, statusCode, errorCode = null) {
    super(message);
    this.statusCode = statusCode;
    this.errorCode = errorCode;
    this.isOperational = true;
    this.timestamp = new Date().toISOString();
    Error.captureStackTrace(this, this.constructor);
  }
}

class ValidationError extends AppError {
  constructor(message, errors = []) {
    super(message, 400, 'VALIDATION_ERROR');
    this.errors = errors;
  }
}
…

FastAPI (Python) Error Handler

# errors/exceptions.py
from typing import Optional, Any, Dict
from fastapi import HTTPException
from datetime import datetime

class AppError(HTTPException):
    def __init__(
        self,
        status_code: int,
        message: str,
        error_code: Optional[str] = None,
        details: Optional[Dict[str, Any]] = None
    ):
        self.status_code = status_code
        self.message = message
        self.error_code = error_code
        self.details = details or {}
        self.timestamp = datetime.utcnow().isoformat()
…

Example Usage

Example 1: Handling Validation Errors

const { ValidationError } = require('./errors/AppError');
const { body, validationResult } = require('express-validator');

router.post('/users',
  [
    body('email').isEmail().normalizeEmail(),
    body('password').isLength({ min: 8 }),
    body('name').trim().notEmpty()
  ],
  async (req, res, next) => {
    try {
      const errors = validationResult(req);
      if (!errors.isEmpty()) {
        throw new ValidationError('Validation failed', errors.array());
      }

      const user = await createUser(req.body);
      res.status(201).json(user);
…

Example 2: Resource Not Found

from fastapi import APIRouter
from errors.exceptions import NotFoundError

router = APIRouter()

@router.get("/users/{user_id}")
async def get_user(user_id: int):
    user = await db.get_user(user_id)
    if not user:
        raise NotFoundError("User")
    return user

# Response:
# {
#   "error": {
#     "message": "User not found",
#     "code": "NOT_FOUND",
#     "statusCode": 404,
…

Before you install

  • Read the whole file first. Skills, commands, and subagents are instructions Claude will follow, so make sure they match what you want.
  • Check which tools, scripts, or MCP servers it uses. Local servers and scripts run with your permissions.
  • Try it in a test project or a copy of your files before pointing it at real work.
  • Pin the version you tested, and review changes before updating.
  • Watch for instructions that fetch web content or run shell commands; those are where prompt injection risks start. See our prompt injection guide.

FAQ

What is Implement Error Handling?

Implement Error Handling is a slash command for Claude Code and Claude Cowork from the jeremylongshore/tons-of-skills-marketplace repository on GitHub. Implement standardized API error handling

How do I install Implement Error Handling in Claude Code?

Download implement-error-handling.md from the repository. Save it to ~/.claude/commands/ (all projects) or .claude/commands/ (one project). As a skill, you can instead save it as ~/.claude/skills/<name>/SKILL.md. Run it by typing / followed by its name.

Can I use Implement Error Handling in Claude Cowork?

Turn the command into a skill: create a folder with the file saved as SKILL.md and zip it. In Customize → Skills, click +, then upload the ZIP. Run it from any task with / and the skill name.

Is Implement Error Handling safe to install?

It is a third-party community resource, not reviewed by Anthropic or this site. Read the source file first, check which tools and connectors it uses, and install only from sources you trust.

Similar resources

Browse all skills, subagents, and plugins →

Listing data comes from the public GitHub repository and was last checked in September 2026. Excerpts are © their authors and shared under MIT. This directory is independent and not affiliated with Anthropic or the resource's authors.