Agent skill · Security

api-handler

Use withApiHandler for all API routes. It eliminates boilerplate and ensures consistent auth, validation, and error handling.

majiayu000github.com/majiayu000GitHub ↗
claude-codeMIT
Install
npx skills add majiayu000/claude-skill-registry --skill api-handler --agent claude-code

Same command for any agent — swap --agent for codex, cursor, copilot.

Facts
Files in the skill folder: 2
SKILL.md size: 7 KB
Bundled scripts: none
Path: skills/api/api-handler/SKILL.md
Open the folder on GitHub →
Where it comes from
Stars: 534
Language: HTML

Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.

From the SKILL.md

--- name: api-handler description: StepLeague API route pattern using withApiHandler wrapper. Use when creating or modifying any API route in the /api directory. Keywords: API, route, endpoint, handler, auth, POST, GET, PUT, DELETE, validation. compatibility: Antigravity, Claude Code, Cursor metadata: version: "1.1" project: "stepleague" --- # API Handler Skill ## Overview Use `withApiHandler` for all API routes. It eliminates boilerplate and ensures consistent auth, validation, and error handling. --- ## Basic Usage ```typescript import { withApiHandler } from "@/lib/api/handler"; import { z } from "zod"; const mySchema = z.object({ name: z.string(), count: z.number().optional(), }); export const POST = withApiHandler({ auth: 'required', schema: mySchema, }, async ({ user, body, adminClient }) => { const { data } = await adminClient .from("table") .insert({ ...body, user_id: user.id }) .select() .single(); return { success: true, data }; }); ``` --- ## Auth Levels | Level | Description | Context Provided | |-------|-------------|------------------| | `'none'` | No auth required | `user` may be null | | `'required'` | Must be logged in | `user` guaranteed | | `'superadmin'` | Site-

What's inside
Steps it walks through
  1. Overview
  2. Basic Usage
  3. Auth Levels
  4. League Auth Examples
  5. League ID Resolution
  6. Handler Context
  7. Schema Validation
  8. Validation Errors
  9. Returning Responses
  10. Return Object (Auto-wrapped)
  11. Return Response Directly
  12. Error Handling
  13. Complete Example
  14. Legacy Pattern
Ships with 1 file
  • metadata.json
More from claude-skill-registry
All skills →
About this skill
What does the api-handler skill do?

Use withApiHandler for all API routes. It eliminates boilerplate and ensures consistent auth, validation, and error handling.

How do I install it?

Run `npx skills add majiayu000/claude-skill-registry --skill api-handler --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.

Where does this skill come from?

From majiayu000/claude-skill-registry, a repository with 534 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.

Is a popular skill a good skill?

Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.

Keep going