agentleFS
xcrrrxcrrr/claude-skills/skills/coding/api-designer/SKILL.md

api-designer

Skill6 starsChanged 8 months agoMITView on GitHub

Use this skill when designing or reviewing REST APIs, writing OpenAPI specifications, or making decisions about URL structure, HTTP methods, and response formats. Trigger phrases: 'design an API for', 'what endpoints do I need', 'how should I structure this API'. Not for implementing the API server code or designing GraphQL schemas.

34 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use shopify-expert, monitoring-expert and 10 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • JeffallanSkill

    shopify-expert

    Builds and debugs Shopify themes (.liquid files, theme.json, sections), develops custom Shopify apps (shopify.app.toml, OAuth, webhooks), and implements Storefront API integrations for headless storefronts. Use when building or customizing Shopify themes, creating Hydrogen or custom React storefronts, developing Shopify apps, implementing checkout UI extensions or Shopify Functions, optimizing performance, or integrating third-party services. Invoke for Liquid templating, Storefront API, app development, checkout customization, Shopify Plus features, App Bridge, Polaris, or Shopify CLI workflows.

    Also in 7 projects that use this

  • JeffallanSkill

    monitoring-expert

    Configures monitoring systems, implements structured logging pipelines, creates Prometheus/Grafana dashboards, defines alerting rules, and instruments distributed tracing. Implements Prometheus/Grafana stacks, conducts load testing, performs application profiling, and plans infrastructure capacity. Use when setting up application monitoring, adding observability to services, debugging production issues with logs/metrics/traces, running load tests with k6 or Artillery, profiling CPU/memory bottlenecks, or forecasting capacity needs.

    Also in 9 projects that use this

  • +10 more from Jeffallan

The file

We split this skill into the rules it gives an agent

12 rules. 0 are common, 7 are distinctive, and 5 are very specific to this project.

  • 0

    Common

    Most of the 33 edited versions we read keep these.

  • 7

    Distinctive

    This author's own choices. Worth a look.

  • 5

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Never use GET for mutations.

    line 58
  2. Very specific:

    Use hierarchical nesting only when the child resource is meaningfully owned by the parent: /users/{userId}/addresses.

    line 61
  3. Distinctive:

    Avoid nesting more than 2 levels deep — flatten with query params instead.

    line 62
  4. Very specific:

    Use kebab-case for multi-word segments: /shipping-addresses, not /shippingAddresses.

    line 63
  5. Distinctive:

    Never return passwords, secrets, or sensitive internal fields.

    line 70
  6. Distinctive:

    Document every field in the OpenAPI spec, including optional ones

    line 308
  7. Very specific:

    Avoid verbs in URLs — the HTTP method is the verb (POST /payments, not POST /make-payment)

    line 309
  8. Distinctive:

    Use HTTPS everywhere and require authentication on all non-public endpoints

    line 310
  9. Distinctive:

    Not versioning from day one — retrofitting versioning is painful

    line 318
  10. Very specific:

    Use requestId in every error response to correlate with server logs

    line 323
  11. Very specific:

    Add a X-Request-Id header echo in all responses for distributed tracing

    line 324
  12. Distinctive:

    Use Swagger UI or Redoc to generate interactive docs from the OpenAPI spec automatically

    line 327

“Common” is measured: kept by at least 6 in 10 of the 33 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

API Designer

Overview

The API Designer skill produces consistent, developer-friendly REST API designs following industry conventions: RESTful resource naming, correct HTTP method semantics, standardized status codes, structured error responses, pagination patterns, and versioning strategies. It includes OpenAPI 3.0 spec snippets so designs can be immediately documented and validated. A well-designed API is intuitive to consume, easy to evolve, and resilient to misuse.

When to Use

  • Designing a new API surface for a service or microservice
  • Adding endpoints to an existing API and needing consistency
  • Reviewing an API design for RESTful correctness
  • Writing an OpenAPI/Swagger specification
  • Deciding on versioning, pagination, or error response format

When NOT to Use

  • Implementing the actual server-side logic (use a framework guide instead)
  • Designing a GraphQL schema (different paradigm)
  • Designing a WebSocket or streaming protocol API
  • Internal function/library API design (different conventions apply)

Quick Reference

ConcernConvention
Resource URLsPlural nouns: /users, /orders/{id}/items
GETRead; idempotent; no body
POSTCreate; non-idempotent; returns 201 + Location header
PUTFull replace; idempotent; returns 200 or 204
PATCHPartial update; returns 200 with updated resource
DELETERemove; idempotent; returns 204
200 OKSuccessful GET, PUT, PATCH
201 CreatedSuccessful POST; include Location header
204 No ContentSuccessful DELETE or PATCH with no body returned
400 Bad RequestClient sent invalid input
401 UnauthorizedMissing or invalid authentication
403 ForbiddenAuthenticated but not authorized
404 Not FoundResource doesn't exist
409 ConflictState conflict (duplicate, version mismatch)
422 UnprocessableValid syntax but failed validation
429 Too Many RequestsRate limit exceeded
500 Internal Server ErrorUnhandled server-side error
PaginationCursor-based preferred; offset for simple cases
VersioningURL path /v1/ for breaking changes; headers for content negotiation

Instructions

  1. Identify resources — List the core nouns in the domain (users, orders, products, comments). Each noun becomes a resource. Resources are plural nouns in the URL.
  2. Map operations to HTTP methods
    • List all required operations for each resource.
    • Map each operation to the correct HTTP method (see Quick Reference).
    • Never use GET for mutations; never use POST when PUT/PATCH applies.
  3. Design URL structure
    • Use hierarchical nesting only when the child resource is meaningfully owned by the parent: /users/{userId}/addresses.
    • Avoid nesting more than 2 levels deep — flatten with query params instead.
    • Use kebab-case for multi-word segments: /shipping-addresses, not /shippingAddresses.
    • Resource IDs belong in the path, not the query string: /users/42, not /users?id=42.
  4. Define request/response shapes
    • Request bodies use camelCase JSON fields.
    • Response envelopes: return the resource directly for single items; use { data: [], meta: {} } for collections.
    • Include id, createdAt, updatedAt on all persisted resources.
    • Never return passwords, secrets, or sensitive internal fields.
  5. Design the standard error response
    {
      "error": {
        "code": "VALIDATION_FAILED",
        "message": "Request validation failed",
        "details": [
          { "field": "email", "message": "Must be a valid email address" }
        ],
        "requestId": "req_abc123"
      }
    }
  6. Design pagination — For collections:
    • Cursor-based (preferred for large/live data):
      { "data": [...], "meta": { "nextCursor": "eyJpZCI6MTB9", "hasMore": true } }
    • Offset-based (simple, small datasets):
      { "data": [...], "meta": { "total": 250, "page": 2, "perPage": 20 } }
    • Accept ?limit= and ?cursor= (or ?page=&perPage=) as query params.
  7. Plan versioning
    • Include /v1/ in the URL path for the initial release.
    • Increment to /v2/ only for breaking changes.
    • Non-breaking additions (new optional fields, new endpoints) don't require a version bump.
    • Maintain old versions for a defined deprecation window (e.g., 12 months).
  8. Write the OpenAPI spec — Document every endpoint with summary, parameters, request body schema, and response schemas including error cases.

Examples

Example 1: Design a User Management API

Input: "Design a REST API for managing users with CRUD operations, including the ability to list users with filtering."

Output:

Endpoints:

POST   /v1/users              Create a user
GET    /v1/users              List users (with filters)
GET    /v1/users/{userId}     Get a user by ID
PATCH  /v1/users/{userId}     Update a user (partial)
DELETE /v1/users/{userId}     Delete a user

POST /v1/users — Request:

{
  "email": "jane@example.com",
  "firstName": "Jane",
  "lastName": "Doe",
  "role": "member"
}

POST /v1/users — Response (201 Created):

{
  "id": "usr_01H8X9Z",
  "email": "jane@example.com",
  "firstName": "Jane",
  "lastName": "Doe",
  "role": "member",
  "createdAt": "2024-01-15T10:30:00Z",
  "updatedAt": "2024-01-15T10:30:00Z"
}

Headers: Location: /v1/users/usr_01H8X9Z

GET /v1/users — Query params:

?role=member&search=jane&limit=20&cursor=eyJpZCI6MTB9

GET /v1/users — Response (200 OK):

{
  "data": [
    {
      "id": "usr_01H8X9Z",
      "email": "jane@example.com",
      "firstName": "Jane",
      "lastName": "Doe",
      "role": "member",
      "createdAt": "2024-01-15T10:30:00Z"
    }
  ],
  "meta": {
    "nextCursor": "eyJpZCI6MjB9",
    "hasMore": true,
    "total": 87
  }
}

OpenAPI snippet:

openapi: 3.0.3
info:
  title: User Management API
  version: 1.0.0
paths:
  /v1/users:
    post:
      summary: Create a user
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateUserRequest'
      responses:
        '201':
          description: User created
          headers:
            Location:
              schema:
                type: string
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/User'
        '400':
          $ref: '#/components/responses/BadRequest'
        '422':
          $ref: '#/components/responses/ValidationError'
components:
  schemas:
    CreateUserRequest:
      type: object
      required: [email, firstName, lastName]
      properties:
        email:
          type: string
          format: email
        firstName:
          type: string
          maxLength: 100
        lastName:
          type: string
          maxLength: 100
        role:
          type: string
          enum: [member, admin]
          default: member
    User:
      type: object
      properties:
        id:
          type: string
        email:
          type: string
        firstName:
          type: string
        lastName:
          type: string
        role:
          type: string
        createdAt:
          type: string
          format: date-time
        updatedAt:
          type: string
          format: date-time

Example 2: Design a File Upload API

Input: "Design an API for uploading files (documents, images) attached to a project."

Output:

Endpoints:

POST   /v1/projects/{projectId}/files          Upload a file
GET    /v1/projects/{projectId}/files          List files for a project
GET    /v1/projects/{projectId}/files/{fileId} Get file metadata
DELETE /v1/projects/{projectId}/files/{fileId} Delete a file
GET    /v1/projects/{projectId}/files/{fileId}/download  Download file content

POST /v1/projects/{projectId}/files — Request:

Content-Type: multipart/form-data

file: <binary>
description: "Q4 financial report"

For large files (> 10 MB), use a two-step upload:

POST /v1/projects/{projectId}/files/upload-url

Request:

{ "filename": "report.pdf", "contentType": "application/pdf", "sizeBytes": 15000000 }

Response:

{
  "uploadUrl": "https://storage.example.com/signed?token=...",
  "fileId": "file_09ZA",
  "expiresAt": "2024-01-15T11:00:00Z"
}

Client uploads directly to the signed URL, then confirms:

POST /v1/projects/{projectId}/files/file_09ZA/confirm

GET /v1/projects/{projectId}/files/{fileId} — Response (200 OK):

{
  "id": "file_09ZA",
  "projectId": "proj_XYZ",
  "filename": "report.pdf",
  "contentType": "application/pdf",
  "sizeBytes": 15000000,
  "description": "Q4 financial report",
  "uploadedBy": "usr_01H8X9Z",
  "url": "/v1/projects/proj_XYZ/files/file_09ZA/download",
  "createdAt": "2024-01-15T10:45:00Z"
}

Best Practices

  • Design for the client developer's experience — make the happy path obvious
  • Be consistent: if one resource uses camelCase, all resources use camelCase
  • Make error messages actionable — tell the client what to do, not just what went wrong
  • Document every field in the OpenAPI spec, including optional ones
  • Avoid verbs in URLs — the HTTP method is the verb (POST /payments, not POST /make-payment)
  • Use HTTPS everywhere and require authentication on all non-public endpoints
  • Return the created/updated resource in the response body — clients shouldn't need a second GET

Common Mistakes

  • Using GET for mutations (breaks caching, idempotency, browser behavior)
  • Nesting URLs more than 2 levels deep (/users/1/posts/5/comments/3/likes — use /likes?commentId=3)
  • Using 200 for all responses including errors (breaks client error handling)
  • Inconsistent naming (snake_case vs camelCase mixed in the same API)
  • Not versioning from day one — retrofitting versioning is painful
  • Returning different shapes for the same resource depending on the endpoint
  • Forgetting to document rate limits and authentication requirements

Tips & Tricks

  • Use requestId in every error response to correlate with server logs
  • Add a X-Request-Id header echo in all responses for distributed tracing
  • Design the SDK or client code you wish you had — that often reveals API design problems
  • API-first: write the OpenAPI spec before writing any implementation code
  • Use Swagger UI or Redoc to generate interactive docs from the OpenAPI spec automatically

Related Skills

  • test-writer
  • security-auditor
  • documentation-writer
  • architecture-designer

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.