Claude Skills Guide

Claude Code REST API Design Best Practices

Building REST APIs that work well with Claude Code requires understanding both traditional API design principles and how Claude skills interpret and interact with your endpoints. This guide provides actionable patterns you can implement immediately.

Resource-Oriented URL Structure

Design your URLs around resources rather than actions. Use nouns for resources and HTTP methods for actions.

# Good design
GET    /api/v1/users
POST   /api/v1/users
GET    /api/v1/users/{id}
PUT    /api/v1/users/{id}
DELETE /api/v1/users/{id}

# Avoid action-based URLs
GET    /api/v1/getUsers
POST   /api/v1/createUser
POST   /api/v1/deleteUserById

When Claude Code generates client code or tests, resource-oriented URLs map naturally to cleaner function names. The superMemory skill benefits from predictable URL patterns when storing and retrieving API interaction history.

Consistent Response Envelopes

Wrap all responses in a consistent structure. This helps Claude skills parse responses reliably.

{
  "data": { },
  "meta": {
    "timestamp": "2026-03-14T10:30:00Z",
    "version": "1.0"
  },
  "pagination": {
    "page": 1,
    "per_page": 20,
    "total": 150
  }
}

Error responses should follow the same envelope pattern:

{
  "error": {
    "code": "VALIDATION_ERROR",
    "message": "Email format is invalid",
    "details": [
      { "field": "email", "issue": "missing @ symbol" }
    ]
  },
  "meta": {
    "timestamp": "2026-03-14T10:30:00Z"
  }
}

The tdd skill generates test cases more accurately when response structures follow predictable patterns across your entire API.

Semantic HTTP Status Codes

Use status codes correctly to communicate outcomes:

Avoid returning 200 OK for error conditions. Claude skills making automated decisions rely on status codes to determine next steps.

Versioning Strategy

Choose a versioning approach early. URL versioning provides clarity:

/api/v1/users
/api/v2/users

Add deprecation headers to responses from older versions:

Deprecation: true
Sunset: Sat, 01 Aug 2026 00:00:00 GMT
Link: <https://api.example.com/v2/users>; rel="latest-version"

The pdf skill can generate version migration guides when your API evolves, but only if you maintain clean version transitions.

Pagination Implementation

Never return unbounded collections. Implement cursor-based or offset pagination:

{
  "data": [...],
  "pagination": {
    "cursor": "eyJpZCI6MTAwfQ==",
    "has_more": true
  }
}

Cursor pagination performs better at scale and avoids offset-based skipping issues. The frontend-design skill can generate pagination components when your API contract is consistent.

Field Selection with Sparse Fieldsets

Allow clients to request specific fields:

GET /api/v1/users?fields=id,name,email
GET /api/v1/users?fields=id,avatar_url

This reduces payload size for mobile clients and helps Claude skills process only relevant data. Implement this with a simple query parameter that filters your response object.

Idempotency for POST Endpoints

POST operations that create resources should support idempotency keys:

POST /api/v1/orders
Idempotency-Key: unique-request-123

{
  "product_id": "prod_abc",
  "quantity": 2
}

Store idempotency keys with a TTL (typically 24-72 hours). Return the original response on duplicate requests. This pattern prevents duplicate orders when Claude skills retry requests after network timeouts.

Webhook Design

If your API sends webhooks, include sufficient context:

{
  "event": "order.created",
  "timestamp": "2026-03-14T10:30:00Z",
  "data": {
    "id": "order_123",
    "status": "pending"
  },
  "webhook": {
    "id": "wh_abc123",
    "delivery_url": "https://client.example.com/webhooks"
  }
}

Always include the event type, timestamp, and a unique webhook identifier. The supermemory skill can track webhook patterns across integrations to help debug event flow issues.

Rate Limiting Documentation

Document and enforce rate limits with standard headers:

X-RateLimit-Limit: 1000
X-RateLimit-Remaining: 999
X-RateLimit-Reset: 1710412800
Retry-After: 60

Return 429 Too Many Requests with a Retry-After header when limits are exceeded. Claude skills can then implement exponential backoff correctly.

OpenAPI Documentation

Maintain an OpenAPI specification that Claude skills can consume. Include:

paths:
  /users/{id}:
    get:
      operationId: getUser
      summary: Get a user by ID
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
          example: "usr_123"
      responses:
        '200':
          description: User found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/User'

The claude-code-api-documentation-openapi-guide skill can generate OpenAPI specs from your existing codebase or help validate your documentation.

Testing Your API with Claude Skills

Use the tdd skill to generate comprehensive API tests:

# Load the tdd skill and generate tests for your endpoints
claude --print "Generate integration tests for /api/v1/users endpoints covering CRUD operations, validation, and error cases"

The claude-code-api-mocking-development-guide skill helps create mock servers for testing without depending on production endpoints.

Summary

Applying these REST API design patterns creates interfaces that Claude Code can interact with reliably. Focus on consistency in response structures, proper HTTP semantics, and comprehensive documentation. When Claude skills can predict your API behavior, they generate better code, tests, and integrations.

Built by theluckystrike — More at zovo.one