Skip to content
Back to skills

Add Api Route

ASecurity

Add an API endpoint, route, controller action, handler, server action or webhook with auth, authorization, validation, consistent errors and tests.

  • 3 stars
  • 0 votes
  • 0 copies
  • 3 views
  • Added November 26, 2026
developmentgophpnextjsfastapidjangoapi

Works with

  • api

Security analysis

A100/100

Scanned November 26, 2026

npx -y skills add Rasimoghlu/sarkhans-claude-starter --skill add-api-route --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Add Api Route?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Add Api Route
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/rasimoghlu-add-api-route/badge)](https://www.skillsdirectory.com/skills/rasimoghlu-add-api-route)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: add-api-route
description: Add an API endpoint, route, controller action, handler, server action or webhook with auth, authorization, validation, consistent errors and tests.
argument-hint: "[METHOD /path – what it does]"
---
# Add an API endpoint

Request: $ARGUMENTS

## 1. Find the house style first
Open 1–2 existing endpoints of the same kind in this repo and copy their structure: routing registration, auth middleware/guards, validation approach, service layer, response/error shape, test style. Cite them (file:line) in your plan. If there is no existing endpoint, use the stack defaults below.

## 2. Required flow (every stack)
authenticate → authorize (this user, this resource) → validate input → call service → map to response DTO → correct status code. See `.claude/rules/api-and-server.md`.

| Stack | Routing | Validation | Authorization | Response |
|---|---|---|---|---|
| Next.js | `app/**/route.ts` or Server Action | zod `safeParse` | session check + ownership in service | `NextResponse.json` / typed result |
| Go | router used in repo (net/http, chi, gin, echo) | decode + validator / explicit checks | middleware for authn + check in service | encoder helper of the repo |
| Laravel | `routes/api.php` + controller | FormRequest | Policy / Gate (`authorize`) | API Resource |
| Symfony | attribute routes | DTO + Validator constraints | Voter (`denyAccessUnlessGranted`) | serializer/normalizer |
| Django / DRF | `urls.py` + view/ViewSet | Serializer | permission classes + object permissions | Serializer |
| FastAPI | `APIRouter` | Pydantic model | `Depends` auth + ownership check | `response_model` |

## 3. Checklist before finishing
- [ ] Authentication and per-resource authorization enforced server-side
- [ ] Input validated; unknown/extra fields handled; output contains only needed fields
- [ ] Error shape and status codes match the project convention
- [ ] Rate limiting considered for public/expensive endpoints; webhook signatures verified
- [ ] No business logic or raw queries in the handler; dependencies injected
- [ ] Tests: success, invalid input, 401, 403 (and 404 where relevant), run and green
- [ ] Every API/package used verified to exist in the installed version — no guessed imports or methods
- [ ] `/verify` passes; `### Third eye` written

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in development →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.