add-endpoint

Implements NestJS HTTP endpoints that conform exactly to the MedLedger API contract.

Updated Jul 26, 2026
One-click install
npx skills add https://github.com/aymansalkhatib/medledger --skill add-endpoint-aymansalkhatib
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: add-endpoint
Source: https://github.com/aymansalkhatib/medledger/tree/main/.claude/skills/add-endpoint
Command: npx skills add https://github.com/aymansalkhatib/medledger --skill add-endpoint-aymansalkhatib

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Adding a new route to a contract-driven NestJS backend risks drifting from the specified wire format, idempotency semantics, and module conventions. This Skill walks through a disciplined seven-phase process so every endpoint matches API_CONTRACT.md exactly — no invented routes, fields, or status codes. ## Core Features & Use Cases - Contract-first implementation: Reads the matching section of API_CONTRACT.md and copies paths, fields, statuses, and error codes verbatim, stopping to ask when a route is not in the contract. - Idempotency wiring: Generates mutation handlers with @IdempotencyKey, @CanonicalBodyHash, and conditional 200/201 replay status via the idempotency service. - Layered conventions: Enforces controller naming by URL segment, class-validator DTOs, service-method ordering (validate → claim key → lock balances → ledger → audit → outbox), and named error-code exceptions. - Use Case: Ask to implement POST /waste from the contract and receive a controller handler, CreateWasteDto, response type, waste service method with transactional ledger postings, and passing lint/build/test runs. ## Quick Start Ask the assistant to add the endpoint POST /waste from the API contract using the add-endpoint skill.

Frequently Asked Questions about add-endpoint

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I add a new endpoint to a NestJS API without breaking the contract?▼

Read the matching section of API_CONTRACT.md first and copy the path, fields, status codes, and error codes verbatim. Then add the controller handler, class-validator DTO, and service method following the module's existing conventions, and verify with lint, build, and tests.

How do I implement idempotent POST endpoints in NestJS?▼

Decorate the handler with @IdempotencyKey and @CanonicalBodyHash, pass the key with a literal 'METHOD /path' endpoint string to the idempotency service, and set the response status conditionally — 201 for the first call, 200 for a replay.

What happens if the route I want is not in the API contract?▼

The process stops and asks rather than inventing routes, fields, or status codes. The contract is the single source of truth, so any route it does not define requires clarification before implementation.

Why should input validation happen before claiming an idempotency key?▼

Validating cheap input first means a malformed request dies before consuming an idempotency key or taking any database lock. Claiming the key first would burn it on a request that never should have taken one.

Can controllers contain business logic in this architecture?▼

No. Controllers only map service results into the contract's response shape. All logic — locking balances, posting ledger entries, audit events, and outbox enqueueing — lives in the service method inside one transaction.