Feature: $ARGUMENTS
Generates a complete API contract with REST endpoints, DTOs, validation rules, and error formats for backend/frontend coordination. Use when designing new features to ensure both teams implement consistent interfaces.
/plugin marketplace add rpiplewar/shipfaster/plugin install prp@rapid-shippingFeature: $ARGUMENTS
Define RESTful endpoints:
Base URL: /api/v1/{feature}
Endpoints:
- GET /api/v1/{features}
Query params: page, size, sort, filter
Response: Page<{Feature}Response>
- GET /api/v1/{features}/{id}
Path param: id (Long)
Response: {Feature}Response
- POST /api/v1/{features}
Body: {Feature}Request
Response: {Feature}Response (201 Created)
- PUT /api/v1/{features}/{id}
Path param: id (Long)
Body: {Feature}Request
Response: {Feature}Response
- DELETE /api/v1/{features}/{id}
Path param: id (Long)
Response: 204 No Content
Define request/response DTOs:
// Request DTO (for POST/PUT)
interface {Feature}Request {
name: string; // min: 2, max: 100
description?: string; // max: 1000
// Add domain-specific fields
}
// Response DTO (for GET)
interface {Feature}Response {
id: number;
name: string;
description?: string;
createdAt: string; // ISO 8601
updatedAt: string; // ISO 8601
// Add computed fields
}
// Page response wrapper
interface Page<T> {
content: T[];
totalElements: number;
totalPages: number;
size: number;
number: number;
}
Define error responses:
{
"timestamp": "2024-01-20T10:30:00Z",
"status": 400,
"error": "Bad Request",
"message": "Validation failed",
"path": "/api/v1/{features}",
"errors": [
{
"field": "name",
"message": "Name is required"
}
]
}
Define validation rules:
name: required, 2-100 chars
description: optional, max 1000 chars
email: valid email format
date: ISO 8601 format
Define status codes:
Integration requirements:
Backend implementation notes:
// Entity fields match response DTO
// Use MapStruct for DTO mapping
// Repository method naming conventions
// Service layer validation
Frontend implementation notes:
// Zod schemas match validation rules
// API client with base configuration
// TanStack Query hooks
// Error handling utilities
Save this contract as: PRPs/working-memory/{feature-name}/contracts/{feature}-api-contract.md
Share this file between backend and frontend teams for alignment.