error-handling

error-handling is a skill for Claude Code from asgarovf/locusai. It costs 36 tokens per session (1,525 once invoked), scanned A, original, MIT.

Guidance for designing how software detects, passes along, records, and reports errors. It includes custom error types, clear user messages, logging, retries, and circuit breakers, which temporarily stop repeated failing calls.

In plain words
What is it for?
Adding error responses to APIs, defining application-specific errors, setting up global error handling, improving logs, and adding retry or circuit-breaker behavior.
Why use it?
It prevents failures from becoming confusing messages, hidden bugs, or broken requests that continue endlessly. It also helps APIs return suitable responses when something goes wrong.

Skill for Claude Code

Written for Claude Code: allowed-tools in frontmatter.

Good fit Adding error responses to APIs, defining application-specific errors, setting up global error handling, improving logs, and adding retry or circuit-breaker behavior.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/asgarovf/locusai/error-handling
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add asgarovf/locusai --skill error-handling
Clone the repo
git clone --depth 1 https://github.com/asgarovf/locusai

Made for: Claude Code.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for error-handling

README.md
[![agentmods](https://agentmods.dev/badge/skills/asgarovf/locusai/error-handling/github.svg)](https://agentmods.dev/skills/asgarovf/locusai/error-handling)
Your own site
<a href="https://agentmods.dev/skills/asgarovf/locusai/error-handling"><img src="https://agentmods.dev/badge/skills/asgarovf/locusai/error-handling/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for error-handling

Your own site · 80×15
<a href="https://agentmods.dev/skills/asgarovf/locusai/error-handling"><img src="https://agentmods.dev/badge/skills/asgarovf/locusai/error-handling.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 36 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,525 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00036 $0.01525
Opus 5.5 $0.00014 $0.00610
Sonnet 5.5 $0.00007 $0.00305
Haiku 4.5 $0.00004 $0.00153

Measured 1mo ago against content hash c465ff56eadf, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

error-handling scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 1mo ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/error-handling/SKILL.md · 251 lines

How it starts

The opening of the file, as written. The whole thing — 251 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Error Handling

When to use this skill

  • Building or improving error handling in an API
  • Adding proper error responses to endpoints
  • Creating custom error classes
  • Setting up global error handling
  • Adding retry logic or circuit breakers
  • Improving error messages and logging

Custom error classes

TypeScript

class AppError extends Error {
  constructor(
    message: string,
    public readonly code: string,
    public readonly statusCode: number = 500,
    public readonly details?: Record<string, unknown>,
  ) {
    super(message);
    this.name = 'AppError';
  }
}

class NotFoundError extends AppError {
  constructor(resource: string, id: string) {
    super(`${resource} with id '${id}' not found`, 'NOT_FOUND', 404);
  }
}

class ValidationError extends AppError {
  constructor(errors: { field: string; message: string }[]) {
    super('Validation failed', 'VALIDATION_ERROR', 400, { errors });
  }
}

class ConflictError extends AppError {
  constructor(message: string) {
    super(message, 'CONFLICT', 409);
  }
}

Python

class AppError(Exception):
    def __init__(self, message: str, code: str, status_code: int = 500, details: dict = None):
        super().__init__(message)
        self.code = code
        self.status_code = status_code
        self.details = details or {}

class NotFoundError(AppError):
    def __init__(self, resource: str, id: str):
        super().__init__(f"{resource} with id '{id}' not found", "NOT_FOUND", 404)

class ValidationError(AppError):
    def __init__(self, errors: list[dict]):
        super().__init__("Validation failed", "VALIDATION_ERROR", 400, {"errors": errors})

Global error handler

Express.js

// Error handler middleware (must be last)
app.use((err: Error, req: Request, res: Response, next: NextFunction) => {
  // Known application errors
  if (err instanceof AppError) {
    return res.status(err.statusCode).json({
      error: {
        code: err.code,
        message: err.message,
        ...(err.details && { details: err.details }),
      },
    });
  }

  // Zod validation errors
  if (err instanceof ZodError) {
    return res.status(400).json({
      error: {
        code: 'VALIDATION_ERROR',
        message: 'Invalid input',
        details: err.issues,
      },
    });
  }

  // Unknown errors — log full details, return generic message
  console.error('Unhandled error:', err);
  res.status(500).json({
    error: {
      code: 'INTERNAL_ERROR',
      message: 'An unexpected error occurred',
    },
  });
});

Read the full file on GitHub · 251 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 1mo ago First seen · 251 lines · 36 tokens per session scan A c465ff56eadf

Subscribe to this mod's changes

error-handling is a skill published in the GitHub repository asgarovf/locusai (23 stars, last pushed 7mo ago), licensed MIT. It adds 36 tokens to every session and 1,525 once invoked, about $0.0001 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

error-handling

Use when designing the reaction to a class of failures — typed error taxonomies, retry/backoff/timeout policy, circuit breakers, React/Next error boundaries, and the user-message vs operator-log split. NOT diagnosing one specific crash (that is debug), NOT logs/metrics/traces (that is observability), NOT the wire…

ericrisco/rsc-harness · 78 tokens

backend-resilience-patterns

Use this skill when the user says 'resilience', 'circuit breaker', 'retry', 'bulkhead', 'timeout', 'fallback', 'resilience4j', 'fault tolerance', 'rate limiter', 'backoff', 'retry strategy', 'bulkhead pattern'. This skill applies production fault-tolerance patterns: circuit breaker, retry with backoff, bulkhead…

j4flmao/agent-skills · 121 tokens

error-handling

Use when implementing custom error classes, error middleware, structured logging, retry logic, or graceful shutdown patterns in backend applications.

MadAppGang/claude-code · 28 tokens

error-handling

Error handling patterns. Exception hierarchies, Result types, structured error responses, retry strategies, circuit breakers.

pan94u/forge · 26 tokens

error-handling-architecture

When designing how a system recovers from and reports failures.

KraitDev/skiLL.Md · 18 tokens

printing-press-amend

Amend a published CLI from one of two input sources: (1) dogfood mode mines the active Claude Code session transcript for friction (missing flags, hand- rolled API payloads, silent-null returns); (2) direct-input mode accepts user-supplied asks (rename a command, add commands or feeds, fix a named bug, optionally…

mvanhorn/cli-printing-press · 222 tokens