param087/saas-starter-skills/api-routes-and-validation
Claude Code and agent skill by param087/saas-starter-skills
- community
Checking that the SKILL.md file is still in the repository.
Use when building API endpoints or server actions — validate every input with zod, return consistent typed JSON errors, set correct status codes, and authenticate/authorize before touching data.
Install
npx vskill@latest install param087/saas-starter-skills/api-routes-and-validationSKILL.md
The same SKILL.md was published earlier as param087/saas-starter-skills/api-routes-and-validation.
API Routes & Validation
Overview
Every endpoint is an attack surface. The rule: never trust input. Validate the body, query, and params with zod at the boundary, parse into typed data, then run auth → authorization → data access. Return a consistent error shape with correct HTTP status codes so clients can handle failures predictably. This applies equally to App Router route handlers and Server Actions.
When to use
- Building a route handler (
app/api/.../route.ts) or a Server Action. - Accepting any user/client input.
- You need predictable, typed error responses.
Validated route handler
Consistent contract
- Success:
{ data }. Error:{ error: { code, message?, fields? } }. Pick one shape and keep it everywhere. - Status codes: 400/422 invalid input, 401 unauthenticated, 403 forbidden, 404 not found, 402 needs upgrade, 409 conflict, 429 rate-limited, 500 unexpected.
- Server Actions: validate with the same zod schema and return typed
{ ok: false, error }for the form to render.
Pitfalls
- `as` casting instead of parsing —
body as CreateInputtrusts the client; useschema.parse/safeParse. - Validating on the client only — re-validate server-side; the client check is UX.
- Leaking internals in errors — return a code/message, log the stack server-side; never echo SQL or stack traces.
- Wrong status codes — returning 200 with an error body breaks client handling and retries.
- Auth after the work — check session/permission/limits before mutating, not after.
- Reusing the same zod schema you forgot to bound — cap string lengths and array sizes to prevent abuse.
Hand-off
Typed, validated, authorized endpoints. They call data-access-layer for persistence and subscription-billing for limits; long work hands off to background-jobs.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/api-routes-and-validation/SKILL.md
Popularity
- Repository stars
- 2
- 7-day trend score
- 5
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/param087/saas-starter-skills/api-routes-and-validation)