Automated summary
This skill guides adding a new API endpoint to an existing NestJS module following a layered architecture (contract, Prisma driver, use-case, Zod DTO, controller, module).
Strengths
- Forces a read of the existing controller, use-cases and drivers first to avoid duplicating functionality
- Clear bottom-up ordering (contract → driver → use-case → DTO → controller → module) that prevents missing pieces
- Explicit conventions for HTTP methods, status codes, and decorator ordering for auth and Swagger
- Ends with concrete verification steps (lint, test) and a reminder that responses are auto-wrapped
Limitations
- Tightly bound to a specific stack and file layout (NestJS, Prisma, Zod, named file paths)
- Assumes in-house helpers exist (TransformInterceptor, PaginationDto, DI tokens) that are not provided
- Does not cover database migrations or writing tests for the new endpoint
Use it when adding a route or API action to an existing NestJS module that already follows these conventions.
Avoid it on projects that do not use NestJS/Prisma or whose folder structure and DTO conventions differ.
Security analysis
SafeThis skill is pure development guidance for adding a NestJS/Prisma API endpoint. It declares no tools and instructs only local file edits plus `yarn lint` and `yarn test` for verification. There are no destructive commands (no rm -rf, no curl|sh), no network calls, no secret/token handling or exfiltration, no obfuscated payloads, and no attempts to disable safety controls. The only mild consideration is that it assumes a specific project layout and DI/route conventions, which could cause an agent to blindly modify files — but that is a correctness risk, not a security one.
No concerns found
How this analysis is madeExamples
Add a deactivate user endpoint to the users module: POST /users/:id/deactivate, admin-only, returning the updated user.Create an endpoint to bulk import suppliers from a list of items in the request body, with a Zod DTO and proper error handling.Add a GET endpoint on the orders module to list orders filtered by status, paginated with the existing PaginationDto.Skill: new-endpoint
Add a new API endpoint to an existing module.
TRIGGER: When the user asks to add a new endpoint, route, or API action to an existing module (e.g., "add a deactivate user endpoint", "create an endpoint to bulk import suppliers").
Instructions
1. Read Before Writing
Always read the existing controller, use-cases, drivers, and contract files before making changes. Understand the current patterns and avoid duplicating existing functionality.
2. Layer-by-Layer (Bottom Up)
Add code in this order:
a) Contract (if new operation is needed)
- Add the method signature to the driver interface in
contracts/<domain>-driver.contract.ts. - Type it with the Zod-derived DTO classes from
dto/— request DTOs (Create*RequestDto,Update*RequestDto) for input,*ResponseDtofor the return. Do not introduce hand-written*Datainterfaces; the DTO is the single source of truth.
b) Driver (if new DB query is needed)
- Add the method implementation in
drivers/prisma-<domain>.driver.ts. - Use Prisma query methods and map the row to the response DTO via the driver's
to<Entity>Responsemapper (timestamps →.toISOString(), omitdeletedAt).
c) Use-Case (for business logic)
- Create a new use-case file:
use-cases/<verb>-<entity>.use-case.ts. - One class per action with an
execute()method. - Inject drivers via DI tokens:
@Inject(<DOMAIN>_DRIVER). - Throw appropriate NestJS exceptions:
NotFoundException,ConflictException,BadRequestException,ForbiddenException.
d) DTO (if endpoint accepts a body or custom query params)
- Create a new DTO file in
dto/using Zod schema +createZodDto(). - Reuse
PaginationDtofromsrc/common/dto/pagination.dto.tsfor paginated list endpoints. - Follow naming:
<verb>-<entity>.dto.ts(e.g.,deactivate-user.dto.ts). - See
/new-dtoskill for full DTO conventions and Zod reference.
e) Controller
- Add the route handler method.
- Inject the new use-case in the constructor.
- Apply decorators in this order:
@Public()or@Roles()or@Permissions(), then HTTP method (@Get,@Post,@Patch,@Delete), then@HttpCode(if not default), then Swagger decorators. - Always include
@ApiOperation,@ApiResponsefor success and error cases. - Use
@ApiParamfor path parameters. - Use
ParseUUIDPipeon all:idpath parameters:@Param('id', ParseUUIDPipe) id: string.
f) Module
- Register the new use-case in the module's
providersarray.
3. HTTP Method Conventions
| Action | Method | Route | Status |
|--------|--------|-------|--------|
| List | GET | / | 200 |
| Get one | GET | /:id | 200 |
| Create | POST | / | 201 |
| Update | PATCH | /:id | 200 |
| Delete | DELETE | /:id | 200 |
| Custom action | POST | /:id/<action> | 200 |
4. Response Handling
All responses are automatically wrapped by TransformInterceptor into { statusCode, data, timestamp }. Do NOT manually wrap responses. Just return the data.
5. Auth Decorators
@Public()— skip JWT auth entirely (login, register, public endpoints).@Roles(DomainRole.ADMIN)— require specific role.@Permissions('domain.action')— require specific permission.- No decorator = authenticated user (JWT required, any role).
6. Verify
yarn lint # Fix any linting issues
yarn test # Ensure nothing is broken
From the file to a first result
The download contains exactly the content displayed on this page. This copy may differ from the latest version in the source repository.
View the source and supporting filesThis download contains SKILL.md only. Any scripts, references, templates and dependencies are not included. Get the required files from the source, preserving their directory structure, before continuing.
1. Download the file
Download SKILL.mdFrom the root of a test project, save the file as .skill-downloads/add-a-new-api-endpoint-ms2s7crn/SKILL.md, or use the command below. This folder is for inspecting the skill before installation.
Command for macOS/Linux or WSL: requires a POSIX shell and curl. On Windows without WSL, use the download button and create the folder manually.
mkdir -p '.skill-downloads/add-a-new-api-endpoint-ms2s7crn' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/add-a-new-api-endpoint-ms2s7crn/download' --output '.skill-downloads/add-a-new-api-endpoint-ms2s7crn/SKILL.md.part' && mv '.skill-downloads/add-a-new-api-endpoint-ms2s7crn/SKILL.md.part' '.skill-downloads/add-a-new-api-endpoint-ms2s7crn/SKILL.md'2. Check prerequisites
Read SKILL.md before using it. If it references scripts or external services, inspect them and prepare the required access in your test environment.
No recognized prerequisites section in this file. This does not mean it is self-contained: libraries, tools and access requirements may be mentioned elsewhere in the content or source repository.
The platforms on this page are catalog indications. The paths below follow tool documentation; they do not prove this skill has been run in those tools. No minimum tool version is confirmed for this listing.
3. Load the skill
This file does not provide a usable name/description header for this native procedure. It remains available to download and inspect; use the manual method below.
Manual method or another tool: attach SKILL.md to a conversation, or open it in an agent that can read files. Include any required supporting resources. No universal folder is recognized by every tool.
4. Try a first task
Use a short, synthetic input: an API endpoint, a small document or an interface brief. In a new conversation, attach the file or give the agent its path, then adapt this request:
Read .skill-downloads/add-a-new-api-endpoint-ms2s7crn/SKILL.md and apply its instructions to this example: [describe a test input]. Identify any missing files, dependencies or access. Produce the result requested by the skill without inventing data or running unreviewed scripts.Expected result: output matching the skill instructions, or a precise list of missing prerequisites. A read confirmation alone does not validate a first use. If an external resource is unavailable, that path remains untested.
React Hook Form Best Practices
Development
Master React Hook Form: avoid anti-patterns, manage subscriptions, and handle reset, dirty state, and controlled inputs correctly.
Emotion to Mantine Migration
Development
Migrate Emotion styled-components to Mantine components with style props and CSS modules. Use when converting .styled.tsx files or removing @emotion imports.
Scope Creep Detector
Development
Analyzes git diffs against a stated intent to detect scope creep, unrelated files, broad PRs, and oversized changes, then suggests keep, split, or justify actions.