moai-ref-api-patterns

Provides REST and GraphQL API design conventions, error handling, and validation patterns for backend development.

2|Updated May 27, 2026
One-click install
npx skills add https://github.com/yekinya/moai-novel --skill moai-ref-api-patterns-yekinya
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: moai-ref-api-patterns
Source: https://github.com/yekinya/moai-novel/tree/main/moai-novel/.claude/skills/moai-ref-api-patterns
Command: npx skills add https://github.com/yekinya/moai-novel --skill moai-ref-api-patterns-yekinya

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Backend developers often ship APIs with inconsistent naming, ad-hoc error formats, missing pagination, and unplanned versioning, which creates maintenance burden and breaks client integrations. ## Core Features & Use Cases - REST Design Conventions: Standardized resource naming, HTTP method mapping, status code selection, and URL versioning rules. - Error & Pagination Patterns: Consistent error response schema with machine-readable codes, plus offset and cursor-based pagination formats. - Validation & Rate Limiting: Input validation checklist covering injection and XSS prevention, with rate limit tiers and response headers. - Use Case: When implementing a new /users endpoint, apply the conventions to choose correct status codes, structure validation errors with field-level details, and add pagination from the start. ## Quick Start Ask the backend expert agent to design or review a REST endpoint for your resource using these API patterns.

Frequently Asked Questions about moai-ref-api-patterns

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

FAQPage Schema
How do I design a RESTful API endpoint correctly?

Use plural lowercase nouns for resources like /api/v1/users, map CRUD operations to GET, POST, PUT, PATCH, and DELETE, and limit nesting to two levels. Return 201 for creation, 204 for deletes without a body, and paginate all collection endpoints.

What HTTP status code should a validation error return?

Return 400 Bad Request for malformed requests and validation failures, or 422 when syntax is valid but semantics are wrong. Include a machine-readable error code and field-level details in the response body.

When should I use PATCH vs PUT for updates?

PATCH applies partial updates to specific fields, while PUT replaces the entire resource. Using them interchangeably breaks idempotency expectations, so choose based on whether clients send complete or partial representations.

Does API versioning require a new version for every change?

No. Only breaking changes like removing fields, changing types, or removing endpoints require a version bump. Adding optional fields, new endpoints, or new query parameters are non-breaking and need no new version.

What are common API design mistakes to avoid?

Avoid verbs in resource names like /getUser, inconsistent error formats across endpoints, unpaginated list endpoints, and deploying breaking changes without a version bump. Also limit GraphQL query depth to prevent abuse.