api-design-principles

Designs REST and GraphQL APIs with pagination, versioning, error handling, and schema patterns.

2|Updated Jun 16, 2026
One-click install
npx skills add https://github.com/monang404/lunawave --skill api-design-principles-monang404
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: api-design-principles
Source: https://github.com/monang404/lunawave/tree/main/.agent/skills/api-design-principles
Command: npx skills add https://github.com/monang404/lunawave --skill api-design-principles-monang404

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) and assets (resource) components.

What problem does it solve? Teams building APIs often ship inconsistent endpoints, wrong HTTP status codes, missing pagination, and GraphQL schemas that suffer from N+1 query problems. This Skill provides structured design principles, checklists, and code templates so APIs are consistent, versioned, and maintainable from the start. ## Core Features & Use Cases - REST API Design Guidance: Covers resource-oriented URL naming, HTTP method semantics, status codes, pagination (offset, cursor, Link header), filtering, sorting, rate limiting, idempotency keys, and HATEOAS. - GraphQL Schema Patterns: Provides schema-first design patterns including Relay cursor pagination, input/payload mutation types, union error handling, DataLoader-based N+1 prevention, query depth limiting, and deprecation strategies. - Review Checklists and Templates: Ships a pre-implementation checklist covering security, performance, and documentation, plus a FastAPI REST template with pagination, error handling, and CORS middleware. - Use Case: Before implementing a new users endpoint, run the design checklist to confirm plural resource naming, correct 201/422 status codes, cursor pagination, and a consistent error response format. ## Quick Start Ask the assistant to review your API endpoint design or draft a REST or GraphQL API specification for your resource using the api-design-principles skill.

Frequently Asked Questions about api-design-principles

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

FAQPage Schema
How do I design a REST API with proper pagination?▼

Use offset-based pagination with page and page_size parameters for simple cases, or cursor-based pagination for large datasets. Always include pagination metadata like total count and page numbers, enforce a maximum page size such as 100, and apply it to every collection endpoint.

REST vs GraphQL: which should I choose for my API?▼

REST fits resource-oriented services with simple CRUD operations and leverages HTTP caching and status codes. GraphQL suits clients needing flexible field selection and aggregated data from multiple sources, but requires DataLoaders and query complexity limits to stay performant.

How do I prevent N+1 queries in GraphQL resolvers?▼

Use the DataLoader pattern to batch and cache database requests per request cycle. A DataLoader collects all IDs requested during a tick and fetches them in a single query, then combine it with query depth limiting and complexity analysis to block expensive queries.

What HTTP status codes should a REST API return?▼

Return 200 for successful GET/PATCH/PUT, 201 for POST creation, 204 for DELETE, 400 for malformed requests, 401 for missing authentication, 403 for insufficient permissions, 404 for missing resources, 422 for validation errors, and 429 for rate limiting.

How do I version an API without breaking existing clients?▼

Use URL versioning like /api/v1/users for clarity, or header/query parameter versioning for cleaner URLs. For GraphQL, evolve the schema by adding nullable fields and marking old ones with the @deprecated directive instead of removing them.

When should I not use this API design guidance?▼

Skip it when you only need framework-specific implementation help, are doing infrastructure-only work without API contracts, or cannot change or version public interfaces. The guidance assumes you control the API contract and can apply design standards.