Skip to content
Back to skills

Api Endpoint

ASecurity

Scaffold a REST API endpoint with route, controller, validation, and tests. Use when creating new API endpoints, adding resources, or when asked to build a new backend route.

  • 18 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added November 6, 2026
ai-agentsapibackend

Works with

  • api

Security analysis

A100/100

Scanned November 6, 2026

npx -y skills add zakelfassi/skills-driven-development --skill api-endpoint --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Api Endpoint?

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

Security grade badge for Api Endpoint
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/zakelfassi-api-endpoint/badge)](https://www.skillsdirectory.com/skills/zakelfassi-api-endpoint)

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: api-endpoint
description: Scaffold a REST API endpoint with route, controller, validation, and tests. Use when creating new API endpoints, adding resources, or when asked to build a new backend route.
metadata:
  forged-by: codex-agent
  forged-from: session-2026-02-18
  forged-reason: "Third endpoint scaffolded with identical structure — time to encode the pattern"
  usage-count: "9"
  last-used: "2026-02-26"
---

# API Endpoint Scaffold

Create a new REST API endpoint following project conventions.

## Inputs
- Entity name (singular, e.g., `comment`)
- Fields (name:type pairs, e.g., `body:string, author_id:number`)
- Auth required? (boolean, defaults to `true`)
- Nested under? (optional parent entity, e.g., `post`)

## Steps

1. **Create the route file**
   ```
   src/routes/{entity}.routes.ts
   ```
   - Define CRUD routes: `GET /`, `GET /:id`, `POST /`, `PUT /:id`, `DELETE /:id`
   - If nested: `GET /{parent}s/:parentId/{entity}s`

2. **Create the controller**
   ```
   src/controllers/{entity}.controller.ts
   ```
   - One method per route
   - All responses use `{ data, error, meta }` shape
   - Handle not-found with 404, validation with 422

3. **Create the validation schema**
   ```
   src/validators/{entity}.validator.ts
   ```
   - Use Zod schemas matching the field definitions
   - Separate schemas for create vs. update (update = partial)

4. **Create the test file**
   ```
   tests/api/{entity}.test.ts
   ```
   - Test each CRUD operation
   - Test validation (bad input returns 422)
   - Test auth (if required: 401 without token)
   - Use test factories for fixtures

5. **Register the route**
   ```
   src/routes/index.ts
   ```
   - Add import + `app.use('/{entity}s', {entity}Routes)`
   - If auth required: add auth middleware

## Conventions
- Route paths are plural (`/comments`, not `/comment`)
- File names are singular (`comment.routes.ts`)
- All endpoints return `{ data, error, meta }`
- `meta` includes pagination for list endpoints
- Auth middleware is applied at the route level, not controller level

## Edge Cases
- **File upload endpoints:** Add `multer` middleware, accept `multipart/form-data`
- **Nested routes:** Parent ID is validated in middleware (404 if parent doesn't exist)
- **Soft delete:** `DELETE` sets `deleted_at` timestamp, doesn't remove the row

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 ai-agents →

Comments

Loading comments…

Newsletter

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