# API Generating

> Generate REST API endpoints following project conventions. Activate when user asks to create a new API endpoint, add a route, or build a new API resource with CRUD operations.

- Skill: `huangjia2019/api-generating` (Agent Skill, multi-file: 2 files)
- Install (CLI): `npx skillmds@latest add huangjia2019/api-generating`
- Raw SKILL.md: https://api.skillmd.com/api/skills/huangjia2019/api-generating/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Integrations & APIs
- Author: huangjia2019 (https://skillmd.com/u/huangjia2019)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/huangjia2019/api-generating

---


# API Endpoint Generator

Generate REST API endpoints following the project's established patterns.

## Before Generating

1. Read existing route files to understand the project's patterns
2. Check for validation library usage (Zod, Joi, etc.)
3. Identify the architecture pattern (layered, MVC, etc.)

## Generation Template

For each new resource, create:

1. **Route file** (`src/routes/{resource}.ts`)
   - Zod validation schemas
   - Route handlers that parse and delegate
   - NO business logic in routes

2. **Service file** (`src/services/{resource}Service.ts`)
   - Business rules and validation
   - Orchestration of repo calls
   - Domain error throwing

3. **Repo file** (`src/repos/{resource}Repo.ts`)
   - Data access only
   - Prisma operations
   - NO business logic

4. **Test file** (`tests/{resource}.test.ts`)
   - Happy path tests
   - Edge case tests
   - Error handling tests

## Naming Conventions

- Files: camelCase (`orderService.ts`)
- Classes: PascalCase (`OrderService`)
- Routes: kebab-case (`/api/order-items`)
- Database: snake_case (handled by Prisma)

