api-handler

Wrap API route handlers with withApiHandler for auth, validation, and error handling.

Updated Aug 23, 2026
One-click install
npx skills add https://github.com/vassovass/scl-v3 --skill api-handler
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: api-handler
Source: https://github.com/vassovass/scl-v3/tree/main/.claude/skills/api-handler
Command: npx skills add https://github.com/vassovass/scl-v3 --skill api-handler

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill standardizes API route creation by wrapping handlers with withApiHandler, ensuring consistent authentication, validation, and error handling across the /api layer.

Core Features & Use Cases

  • Unified API route pattern: Use withApiHandler for GET, POST, PUT, DELETE endpoints to reduce boilerplate.
  • Auth & validation baked in: Enforces defined auth levels and Zod-based input validation with automatic error responses.
  • Return & error handling: Supports auto-wrapped responses or direct json/badRequest/forbidden with typed AppError errors for robust error reporting.

Quick Start

Create a new API route using withApiHandler and a validation schema; implement auth as required, and return a typed response.

Frequently Asked Questions about api-handler

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I standardize API route creation with consistent validation and authentication?

Wrap your API handlers with withApiHandler to enforce standardized authentication levels, Zod-based input validation, and error handling across all /api routes. This eliminates boilerplate and ensures every endpoint follows the same safety pattern.

What's the best way to validate API request inputs in TypeScript endpoints?

Use Zod schemas with withApiHandler to define and validate request data automatically. The wrapper applies your schema validation and returns typed errors, preventing invalid data from reaching your handler logic.

How do I implement authentication levels across multiple API endpoints?

Define auth requirements within withApiHandler; it enforces your specified auth level on each route and rejects unauthenticated requests before handler execution. All endpoints inherit consistent auth validation without repetition.

Can I use withApiHandler for different HTTP methods like GET, POST, and DELETE?

Yes, withApiHandler supports GET, POST, PUT, and DELETE endpoints uniformly. One wrapper pattern applies validation, auth, and error handling across all HTTP methods in your /api routes.

What error handling does withApiHandler provide for API responses?

withApiHandler wraps responses automatically and supports typed AppError exceptions for consistent error reporting. You can return direct json, badRequest, or forbidden responses; the handler standardizes format and status codes.