api-error-handler

api-error-handler is a skill for Claude Code from luqiang-code/claude-code-skills. It costs 40 tokens per session (588 once invoked), scanned A, original, MIT.

A tool for adding consistent error handling to API routes, which are the parts of a web service that receive requests and return responses. It defines shared error types, JSON error responses, logging, and request identifiers.

In plain words
What is it for?
Use it to standardise validation, authentication, missing-resource, and rate-limit errors across supported API routes, then run the existing tests.
Why use it?
It replaces inconsistent errors and unclear failure responses with a common format that clients and developers can handle more reliably. It is intended for HTTP API routes, not GraphQL or WebSocket endpoints.

Skill for Claude Code

Written for Claude Code: allowed-tools in frontmatter.

Good fit Use it to standardise validation, authentication, missing-resource, and rate-limit errors across supported API routes, then run the existing tests.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/luqiang-code/claude-code-skills/api-error-handler
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 luqiang-code/claude-code-skills --skill api-error-handler
Clone the repo
git clone --depth 1 https://github.com/luqiang-code/claude-code-skills

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 api-error-handler

README.md
[![agentmods](https://agentmods.dev/badge/skills/luqiang-code/claude-code-skills/api-error-handler/github.svg)](https://agentmods.dev/skills/luqiang-code/claude-code-skills/api-error-handler)
Your own site
<a href="https://agentmods.dev/skills/luqiang-code/claude-code-skills/api-error-handler"><img src="https://agentmods.dev/badge/skills/luqiang-code/claude-code-skills/api-error-handler/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 api-error-handler

Your own site · 80×15
<a href="https://agentmods.dev/skills/luqiang-code/claude-code-skills/api-error-handler"><img src="https://agentmods.dev/badge/skills/luqiang-code/claude-code-skills/api-error-handler.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 40 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 588 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.00040 $0.00588
Opus 5.5 $0.00016 $0.00235
Sonnet 5.5 $0.00008 $0.00118
Haiku 4.5 $0.00004 $0.00059

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

Security

Grade A, and why

api-error-handler 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.

community-skills/api-error-handler/SKILL.md · 76 lines

What it actually says

API Error Handler

Add consistent, production-grade error handling to API routes.

When to Use

  • API routes lack standardized error responses
  • Error handling is inconsistent across endpoints
  • User mentions "error handling", "error responses", "error middleware"

When NOT to Use

  • GraphQL APIs (different error format)
  • WebSocket endpoints (different patterns)
  • The project already has a mature error handling layer

Workflow

  1. Scan API routes to understand current error handling patterns
  2. Identify the framework (Express, Fastify, Koa, etc.)
  3. Create an AppError class with: statusCode, code, message, details
  4. Create error middleware that catches all errors and returns JSON:
    { "error": { "code": "VALIDATION_ERROR", "message": "...", "details": [...] } }
    
  5. Add error categories: ValidationError, AuthError, NotFoundError, RateLimitError
  6. Wire into existing routes — replace bare throw new Error() with AppError subclasses
  7. Add request ID to error responses for traceability
  8. Run existing tests to verify nothing breaks

Output Structure

src/
├── errors/
│   ├── AppError.ts           # Base error class
│   ├── ValidationError.ts    # 400
│   ├── AuthError.ts          # 401
│   ├── ForbiddenError.ts     # 403
│   ├── NotFoundError.ts      # 404
│   └── RateLimitError.ts     # 429
├── middleware/
│   └── errorHandler.ts       # Error middleware

Key Principles

  • Never leak stack traces in production
  • Always include a machine-readable code field
  • Log errors with request ID for debugging
  • DON'T catch errors you can't handle — let the middleware do it
  • Use HTTP status codes semantically

Notes

  • Don't wrap every route in try-catch — use the error middleware
  • Production errors should NOT include internal details
  • Add NODE_ENV check: include stack traces only in development
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 · 76 lines · 40 tokens per session scan A 3972c82c5234

Subscribe to this mod's changes

api-error-handler is a skill published in the GitHub repository luqiang-code/claude-code-skills (4 stars, last pushed 4mo ago), licensed MIT. It adds 40 tokens to every session and 588 once invoked, about $0.0002 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-31.

Related

Other skills, from other repositories

agent-django-fastapi-expert

Specialist subagent: Django ORM, Django REST Framework, FastAPI async patterns, and Pydantic v2 specialist. Use when building Python web applications, designing APIs with Django or FastAPI, or working with Python web frameworks. Trigger phrases: Django, FastAPI, DRF, Django REST Framework, Pydantic, ORM, queryset…

travisjneuman/.claude · 92 tokens

authentication-patterns

OAuth 2.0, JWT, SSO, MFA, NextAuth/Clerk/Supabase Auth implementation patterns.

travisjneuman/.claude · 28 tokens

email-systems

Transactional email (Resend, SendGrid, SES), templates (React Email, MJML), deliverability (SPF/DKIM/DMARC), and inboxing best practices. Use when building email infrastructure, designing templates, or troubleshooting deliverability.

travisjneuman/.claude · 55 tokens

event-driven-architecture

Kafka, RabbitMQ, SQS/SNS, event sourcing, CQRS, saga patterns, dead letter queues, and idempotency. Use when designing asynchronous systems, implementing message-driven workflows, or building event streaming pipelines.

travisjneuman/.claude · 50 tokens

microservices-architecture

Microservices architecture patterns and best practices. Use when designing distributed systems, breaking down monoliths, or implementing service communication.

travisjneuman/.claude · 30 tokens

payment-integration

Stripe, RevenueCat, subscription billing, webhooks, PCI compliance, and tax. Use when integrating payments or subscriptions, handling payment webhooks, or reviewing billing and PCI scope.

travisjneuman/.claude · 40 tokens