backend-api-patterns

Guides creation and review of REST APIs with layered architecture and HTTP error handling.

5|15|Updated Jul 8, 2026
One-click install
npx skills add https://github.com/clfigueiredo/hermes-infra-skills --skill backend-api-patterns-clfigueiredo
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: backend-api-patterns
Source: https://github.com/clfigueiredo/hermes-infra-skills/tree/main/.hermes/skills/curso-hermes/backend-api-patterns
Command: npx skills add https://github.com/clfigueiredo/hermes-infra-skills --skill backend-api-patterns-clfigueiredo

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? When building or reviewing a backend API, it is easy to end up with inconsistent routes, missing input validation, leaked stack traces, or unclear contracts between frontend and backend. This Skill provides a concise checklist and patterns for structuring REST endpoints, organizing code into layers, and returning correct HTTP status codes. ## Core Features & Use Cases - REST Route Conventions: Standard patterns for resource endpoints (GET/POST/PATCH/DELETE) with query-param filtering and pagination. - Layered Architecture: Clear separation between controller/route, service/use-case, repository/DAO, and schema/DTO layers. - HTTP Error Mapping: A reference table mapping common failure cases (auth, validation, conflict, rate limit) to correct status codes. - Use Case: A student building a Node or FastAPI endpoint asks for a review; the Skill checks that input is schema-validated, errors return 400/422 without leaking internals, lists are paginated, and the frontend knows the response contract. ## Quick Start Ask the assistant to review your API endpoint code using the backend-api-patterns checklist for routes, validation, errors, and pagination.

Frequently Asked Questions about backend-api-patterns

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

FAQPage Schema
How do I structure a REST API with controllers and services?▼

Separate your code into four layers: the controller/route handles HTTP, auth, and validation; the service holds business logic; the repository talks to the database or external APIs; and schemas/DTOs define input and output contracts.

What HTTP status code should validation errors return?▼

Validation failures should return 400 or 422. Use 401 for unauthenticated requests, 403 for missing permissions, 404 for missing resources, 409 for conflicts, and 429 for rate limiting.

How do I add pagination to a REST API list endpoint?▼

Use query parameters such as page and pageSize on list endpoints, for example GET /customers?status=active&page=1&pageSize=20. Every list endpoint should support pagination to avoid unbounded responses.

Does this pattern work with FastAPI, Django, and Laravel?▼

Yes, the route conventions, layered architecture, and error mapping are framework-agnostic and apply to Node, FastAPI, Django, and Laravel. Only the syntax for defining routes and schemas differs per framework.

Why should API errors not expose stack traces?▼

Returning stack traces or internal details leaks implementation information and potential secrets to clients. Errors should return a safe message and correct status code, while detailed diagnostics go into server logs with a request correlation id.