API Contracts Generator
Génère des contrats API cohérents entre Frontend (Next.js) et Backend (NestJS) avec types synchronisés, validation standardisée et error handling uniforme. À utiliser lors de la création d'APIs, DTOs, types frontend/backend, ou quand l'utilisateur mentionne "API", "DTO", "types", "contract", "validation", "frontend-backend", "synchronisation".
npx skills add majiayu000/claude-skill-registry --skill api-contracts --agent claude-code
Same command for any agent — swap --agent for codex, cursor, copilot.
Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.
What it does
Generates a coherent API contract between Frontend (Next.js) and Backend (NestJS) ensuring synchronized types, standardized validation, and uniform error handling. It targets tasks around APIs, DTOs, frontend/backend types, and related validation synchronisation.
How it works
- Establishes Backend DTOs (NestJS) with request/response structures, validation via class-validator, and Swagger decorators for documentation.
- Defines Response DTOs including nested DTOs and pagination DTOs, with examples and type consistency.
- Integrates Controller code samples showing how DTOs connect to handlers and how API responses are shaped.
- Outlines Frontend Type strategy: options to generate types from Backend Swagger (openapi-typescript), share types in a monorepo, or manually duplicate types; includes validation rules on the frontend mirroring backend constraints.
- Provides Frontend Validation with Zod that must EXACTLY match backend rules (e.g., length limits, required fields).
- Describes Server Action flow (Frontend → Backend) with input validation, API call, cache revalidation, and error handling patterns.
- Includes API Client code demonstrating authentication, request/response handling, and error translation to a unified error type.
- Specifies Backend and Frontend error handling formats and a translation layer for user-friendly messages.
When to use it
Use when creating APIs, DTOs, or frontend/backend types, or when the user mentions terms like "API", "DTO", "types", "contract", "validation", "frontend-backend", or "synchronisation" to ensure consistent contracts across layers.
What it can touch
- Backend: DTOs, Controller references, pagination DTOs, example code, and validation decorators.
- Frontend: Types synchronization approaches, Zod schemas, and server-action/client API patterns.
- Server/API error handling formats and translation helpers.
Caveats
- License: MIT
- Rules require frontend and backend validation to align exactly; the provided examples enforce consistent validation definitions across both sides.
- The skill assumes Swagger/OpenAPI-based type generation or shared types in a monorepo; exact source integration depends on project setup.
# API Contracts Generator ## 🎯 Mission Garantir une **communication parfaite** entre Frontend (Next.js) et Backend (NestJS) via des contrats API cohérents, types synchronisés et validation standardisée. ## 🏗️ Philosophie des API Contracts ### Le Problème Dans un projet full-stack, les erreurs de communication Frontend ↔ Backend sont fréquentes : - ❌ Types incohérents (backend attend `clubId`, frontend envoie `id`) - ❌ Validations divergentes (backend accepte 100 chars, frontend 50) - ❌ Erreurs non standardisées (format différent selon l'endpoint) - ❌ Documentation obsolète (Swagger non à jour) ### La Solution : API Contracts Un **API Contract** définit le contrat entre frontend et backend : - ✅ **DTOs Backend** : Structure des requêtes/réponses avec validation - ✅ **Types Frontend** : TypeScript synchronisés avec le backend - ✅ **Validation cohérente** : Mêmes règles backend et frontend - ✅ **Error format standard** : Format uniforme pour toutes les erreurs - ✅ **Documentation auto** : Swagger généré depuis le code ### Architecture de Communication ``` Frontend (Next.js) ↓ Server Action (avec types) ↓ Validation Zod ↓ fetch/axios Backend (NestJS) ↓ Controller (avec DTOs) ↓ Valida
- 🎯 Mission
- 🏗️ Philosophie des API Contracts
- Le Problème
- La Solution : API Contracts
- Architecture de Communication
- 📦 1. Backend DTOs (NestJS)
- Request DTOs (Input)
- Response DTOs (Output)
- Pagination DTO (Standard)
- Controller Integration
- 🎨 2. Frontend Types (Next.js)
- Stratégie de Synchronisation
- Validation Frontend avec Zod
- 🔗 3. Server Actions (Frontend → Backend)
Install openapi-typescript npm install --save-dev openapi-typescript Generate types from backend Swagger npx openapi-typescript http://localhost:3000/api-json -o src/types/api.ts
What does the API Contracts Generator skill do?
Génère des contrats API cohérents entre Frontend (Next.js) et Backend (NestJS) avec types synchronisés, validation standardisée et error handling uniforme. À utiliser lors de la création d'APIs, DTOs, types frontend/backend, ou quand l'utilisateur mentionne "API", "DTO", "types", "contract", "validation", "frontend-backend", "synchronisation".
How do I install it?
Run `npx skills add majiayu000/claude-skill-registry --skill api-contracts --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.
Where does this skill come from?
From majiayu000/claude-skill-registry, a repository with 534 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.
Is a popular skill a good skill?
Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.
