EN

engineer-api-design

Provides professional standards for designing, creating, and documenting clean REST APIs.

Install

mkdir -p .claude/skills/engineer-api-design && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/11395" && unzip -o skill.zip -d .claude/skills/engineer-api-design && rm skill.zip

Installs to .claude/skills/engineer-api-design

Activation

This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.

Professional REST API design producing consistent, secure, and well-documented endpoints. Use whenever the user asks to design, create, review, or document an API — including 'diseñá una API', 'create an endpoint', 'API design', 'add a new route', 'design the backend', 'write an API for', 'REST endpoint', or any request involving serverless functions, API routes, endpoint structure, request/response schemas, pagination, or API documentation. Also triggers for Zod schema design, API error responses, rate limiting, or auth middleware. Do NOT use for frontend data fetching, GraphQL schema design, or database schema design (use database-design skill).
655 chars✓ has a “when” triggerlonger than Claude Code's old 250-char listing cap (fine on current versions)
Intermediate

Key capabilities

  • Define domain resources and their relationships
  • Map operations to standard HTTP methods
  • Design request and response schemas with Zod
  • Incorporate cross-cutting concerns like authentication and rate limiting
  • Document APIs through self-documenting schemas

How it works

The skill guides API design by first identifying domain resources, then mapping operations to HTTP methods, designing request/response schemas, adding cross-cutting concerns, and finally documenting the API.

Inputs & outputs

You give it
API requirements, domain entities, desired operations
You get back
Consistent, secure, and well-documented REST API endpoints

When to use engineer-api-design

  • Designing new REST routes
  • Creating API endpoint documentation
  • Reviewing API design patterns

About this skill

API Design — Professional REST Architecture

Philosophy

A well-designed API is one that a developer can use correctly without reading extensive documentation. URLs should be guessable, responses should be predictable, errors should be actionable, and the entire interface should feel boring — in the best possible way.

This skill follows the conventions established by Microsoft's Azure API guidelines, Google's API design guide, and Postman's best practices: use nouns for resources, HTTP methods for actions, status codes for outcomes, and query parameters for modifiers.

The senior principle: consistency over cleverness. Every endpoint should look and behave like every other endpoint in the same API.


API Design Workflow

Step 1: Define Resources

Before writing any code, identify the domain resources:

  • What are the nouns in the business domain? (events, clients, bookings, payments, leads)
  • What are their relationships? (an event has many payments, a client has many events)
  • Which resources are public vs. protected?

Step 2: Map Operations to HTTP Methods

OperationMethodEndpointStatus Code
List collectionGET/api/events200
Get single itemGET/api/events/:id200 or 404
Create itemPOST/api/events201
Full updatePUT/api/events/:id200 or 404
Partial updatePATCH/api/events/:id200 or 404
Delete itemDELETE/api/events/:id204 or 404
Custom actionPOST/api/events/:id/cancel200

Step 3: Design Request/Response Schemas

Read references/schema-patterns.md for Zod schema design, response envelopes, pagination, and error format.

Every endpoint needs:

  • Request schema: Validated with Zod before processing
  • Response schema: Consistent envelope with data, error, and meta fields
  • Error schema: Standardized format across all endpoints

Step 4: Add Cross-Cutting Concerns

Read references/api-infrastructure.md for auth, rate limiting, CORS, middleware, and logging patterns.

Step 5: Document

Every endpoint should be self-documenting through its schema. For external APIs, generate OpenAPI/Swagger docs from the Zod schemas.


URL Design Rules

Use nouns, not verbs

✅ GET  /api/events         → List events
✅ POST /api/events         → Create event
❌ GET  /api/getEvents
❌ POST /api/createEvent

Use plural nouns for collections

✅ /api/events
✅ /api/clients
❌ /api/event
❌ /api/client

Use kebab-case for multi-word resources

✅ /api/booking-slots
✅ /api/market-intelligence
❌ /api/bookingSlots
❌ /api/MarketIntelligence

Limit nesting to 1 level

✅ /api/events/:id/payments        → Payments for a specific event
✅ /api/clients/:id/events         → Events for a specific client
❌ /api/clients/:id/events/:id/payments/:id/installments

For deeper resources, promote them to top-level with a filter:

✅ /api/payments?eventId=123

Use query parameters for filtering, sorting, pagination

✅ /api/events?status=confirmed&sort=-date&page=2&limit=20
❌ /api/events/confirmed/sorted-by-date/page/2

Non-CRUD actions as sub-resources

✅ POST /api/events/:id/cancel      → Cancel an event
✅ POST /api/bookings/:id/confirm   → Confirm a booking
❌ POST /api/cancelEvent/:id

HTTP Status Codes

Use consistently — don't invent meanings:

CodeMeaningWhen to use
200OKSuccessful GET, PUT, PATCH, or action
201CreatedSuccessful POST that created a resource
204No ContentSuccessful DELETE
400Bad RequestValidation error, malformed input
401UnauthorizedMissing or invalid authentication
403ForbiddenAuthenticated but not authorized
404Not FoundResource doesn't exist
409ConflictDuplicate, stale data, or business rule conflict
422UnprocessableValid JSON but semantically invalid
429Too Many RequestsRate limit exceeded
500Internal ErrorUnexpected server error
502Bad GatewayExternal service failure
503Service UnavailableTemporary overload or maintenance

Rule: Never return 200 with an error in the body. Use the status code to communicate the outcome.


Response Format

Success response

{
  "data": { "id": "evt-123", "title": "Birthday", "status": "confirmed" },
  "meta": { "requestId": "req-abc" }
}

Collection response (with pagination)

{
  "data": [
    { "id": "evt-123", "title": "Birthday" },
    { "id": "evt-456", "title": "Wedding" }
  ],
  "meta": {
    "page": 2,
    "limit": 20,
    "total": 87,
    "totalPages": 5
  }
}

Error response

{
  "error": {
    "code": "VALIDATION_ERROR",
    "message": "Invalid input data",
    "fields": {
      "title": "Title is required",
      "date": "Date must be in the future"
    }
  },
  "meta": { "requestId": "req-def" }
}

Consistency rule: Every endpoint returns the same envelope shape. Consumers should never have to guess whether data or error will be present.


Endpoint Implementation Pattern

For Vercel serverless functions or similar:

export default async function handler(req: Request) {
  // 1. Method routing
  if (req.method !== 'POST') return methodNotAllowed(req.method);

  // 2. Authentication
  const user = await authenticate(req);
  if (!user) return unauthorized();

  // 3. Input validation
  const parsed = createEventSchema.safeParse(await req.json());
  if (!parsed.success) return validationError(parsed.error);

  // 4. Business logic
  try {
    const event = await eventService.create(parsed.data, user.id);
    return created(event);
  } catch (error) {
    return handleError(error);
  }
}

Each step has a single responsibility. Validation errors never reach business logic. Business logic never touches raw request objects.


Idempotency

Operations that can be safely retried without side effects:

  • GET, PUT, DELETE — inherently idempotent
  • POST — NOT idempotent by default. Creating the same event twice creates two events.

For POST operations that should be idempotent (payments, bookings):

  • Accept an Idempotency-Key header from the client
  • Store the result keyed by this token
  • On duplicate requests with the same key, return the stored result instead of processing again

Reference Files

FileWhen to readContents
references/schema-patterns.mdSteps 3-4Zod schema design, response helpers, pagination, filtering, error formatting, TypeScript patterns
references/api-infrastructure.mdStep 4Authentication middleware, rate limiting, CORS, logging, request ID tracking, serverless patterns

Cross-Skill References

API design touches multiple concerns:

  • Database schema for the API?database-design skill for table design, RLS, migrations
  • Error responses?error-handling skill for custom error types, resilience patterns
  • Security (auth, rate limiting, input validation)?security-hardening skill
  • Testing the API?testing-strategy skill for integration test patterns
  • API performance?performance-optimization skill for caching, N+1 prevention
  • Logging API requests?observability skill for structured logging, correlation IDs
  • API in CI/CD?ci-cd-pipeline skill for automated testing and deploy

When not to use it

  • When designing GraphQL schemas
  • When focusing on frontend data fetching

Limitations

  • Does not apply to GraphQL schema design
  • Does not apply to database schema design
  • Does not apply to frontend data fetching

How it compares

This skill provides a structured, convention-based workflow for REST API design, ensuring consistency and predictability, unlike an ad-hoc approach that might lead to inconsistent endpoints.

Compared to similar skills

engineer-api-design side by side with the closest alternatives in the catalog.

SkillInstallsUpdatedSafetyDifficulty
engineer-api-design (this skill)04moNo flagsIntermediate
mcp-builder1363moReviewAdvanced
api-design-principles722moNo flagsIntermediate
langchain-architecture82moReviewIntermediate

Try saying

Example prompts that trigger this skill in your AI assistant.

You might also like

mcp-builder

anthropics

Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK).

136215

api-design-principles

wshobson

Master REST and GraphQL API design principles to build intuitive, scalable, and maintainable APIs that delight developers. Use when designing new APIs, reviewing API specifications, or establishing API design standards.

72170

langchain-architecture

wshobson

Design LLM applications using the LangChain framework with agents, memory, and tool integration patterns. Use when building LangChain applications, implementing AI agents, or creating complex LLM workflows.

899

nodejs-backend-patterns

wshobson

Build production-ready Node.js backend services with Express/Fastify, implementing middleware patterns, error handling, authentication, database integration, and API design best practices. Use when creating Node.js servers, REST APIs, GraphQL backends, or microservices architectures.

1246

springboot-patterns

affaan-m

Spring Boot 架构模式、REST API 设计、分层服务、数据访问、缓存、异步处理和日志记录。适用于 Java Spring Boot 后端工作。

1147

backend-architect

sickn33

Expert backend architect specializing in scalable API design, microservices architecture, and distributed systems. Masters REST/GraphQL/gRPC APIs, event-driven architectures, service mesh patterns, and modern backend frameworks. Handles service boundary definition, inter-service communication, resilience patterns, and observability. Use PROACTIVELY when creating new backend services or APIs.

1014

Search skills

Search the agent skills registry