api-handler
Use withApiHandler for all API routes. It eliminates boilerplate and ensures consistent auth, validation, and error handling.
npx skills add majiayu000/claude-skill-registry --skill api-handler --agent claude-code
Same command for any agent — swap --agent for codex, cursor, copilot.
Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.
--- 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-
- Overview
- Basic Usage
- Auth Levels
- League Auth Examples
- League ID Resolution
- Handler Context
- Schema Validation
- Validation Errors
- Returning Responses
- Return Object (Auto-wrapped)
- Return Response Directly
- Error Handling
- Complete Example
- Legacy Pattern
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.
