agentsclimarketplace

Api design

Skill SWEStash/swe-workflow-skills/skills/api-design

Design RESTful and GraphQL APIs — endpoint naming, request/response contracts, error handling, pagination, versioning, auth patterns, OpenAPI specs. Triggers: design the API, API contract, REST API, GraphQL schema, error response format, pagination, API versioning, OpenAPI, swagger, endpoints. Use architecture-design for REST-vs-GraphQL or monolith-vs-microservices decisions.From its SKILL.md

Install
npx -y skills add SWEStash/swe-workflow-skills --skill api-design

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

SKILL.md

5.3 KB, ~1.2k tokens by cl100k_base, as published. Nobody here has run it

API Design

Design APIs that are consistent, predictable, and easy to consume. A well-designed API is intuitive to use without reading documentation — but has great documentation anyway.

Scope Boundary

This skill designs the contract (endpoints, request/response shapes, error formats, pagination). For higher-level decisions (REST vs GraphQL, API gateway, authentication strategy), use the architecture-design skill first, then return here to design the specifics.

Workflow

Step 1: Identify Resources and Operations

Start from the domain model, not the UI:

  • What are the resources? (nouns: users, orders, products, comments)
  • What operations exist? (CRUD + domain-specific: archive, publish, approve)
  • What are the relationships? (user has orders, order contains items)
  • Who consumes this API? (web app, mobile app, third-party, internal service)

Map each resource to its operations before choosing URLs or methods.

Step 2: Design Endpoints

Apply RESTful naming conventions — see references/rest-conventions.md:

GET    /api/v1/users          → List users
POST   /api/v1/users          → Create user
GET    /api/v1/users/:id      → Get user
PATCH  /api/v1/users/:id      → Update user (partial)
DELETE /api/v1/users/:id      → Delete user

# Nested resources (when the child only makes sense in parent context)
GET    /api/v1/users/:id/orders    → List user's orders
POST   /api/v1/users/:id/orders    → Create order for user

# Actions that don't map to CRUD
POST   /api/v1/orders/:id/cancel   → Cancel an order
POST   /api/v1/users/:id/verify    → Verify a user's email

Present the endpoint list to the user and refine before designing schemas.

Step 3: Define Request/Response Schemas

For each endpoint, define:

Request: Query parameters (for filtering/pagination), path parameters, request body with field types and validation rules.

Response: Status code, response body shape, included relationships.

Use consistent patterns across all endpoints — see references/rest-conventions.md for standard shapes.

Key decisions to make with the user:

  • ID format: Integer, UUID, or ULID? (be consistent)
  • Date format: ISO 8601 always (2025-03-05T14:30:00Z)
  • Null vs absent: Are missing fields returned as null or omitted?
  • Envelope or not: { data: [...], meta: {...} } vs flat response?

Step 4: Standardize Error Responses

Every API error should use the same shape. Recommend this format:

{
  "error": {
    "code": "VALIDATION_ERROR",
    "message": "Human-readable description for developers",
    "details": [
      {
        "field": "email",
        "message": "Must be a valid email address"
      }
    ]
  }
}

Map HTTP status codes consistently:

  • 400 — Client sent invalid data (validation errors)
  • 401 — Authentication required or invalid
  • 403 — Authenticated but not authorized for this action
  • 404 — Resource not found
  • 409 — Conflict (duplicate, state violation)
  • 422 — Valid syntax but semantically invalid (business rule violation)
  • 429 — Rate limited
  • 500 — Server error (never expose internals)

Step 5: Design Pagination, Filtering, Sorting

For any list endpoint that could return many results:

Pagination (recommend cursor-based for most cases):

GET /api/v1/orders?cursor=abc123&limit=20

Response:
{
  "data": [...],
  "pagination": {
    "next_cursor": "def456",
    "has_more": true
  }
}

Filtering: Use query parameters with clear naming:

GET /api/v1/orders?status=pending&created_after=2025-01-01

Sorting: Use a sort parameter with - prefix for descending:

GET /api/v1/orders?sort=-created_at,total

Step 6: Define Authentication and Authorization

For each endpoint, specify:

  • Authentication: Required? What scheme? (Bearer token, API key, session)
  • Authorization: What roles/permissions can access this? Document per-endpoint.
  • Public endpoints: Explicitly mark which endpoints don't require auth.

Step 7: Produce the Specification

Output the API design as one of:

  • Markdown document — for internal APIs and quick designs
  • OpenAPI 3.x spec — for formal APIs, enables codegen and tooling

Use the template at templates/api-spec.md for markdown output.

Principles Applied

  • KISS: Prefer flat resource URLs over deeply nested ones. /orders?user_id=123 is simpler than /users/123/orders/456/items/789.
  • DRY: Standardize error format, pagination, and envelope structure once. Don't reinvent per-endpoint.
  • YAGNI: Don't add filtering, sorting, or pagination until a list endpoint actually needs them. Add later when the need is real.
  • Functional Independence: Each endpoint should do one thing. Avoid "Swiss army knife" endpoints that change behavior based on query parameters.

What ships with it: 3 files

9.6 KB alongside SKILL.md

evals/

references/

templates/

Gives 1 of the 12 instructions most apis services skills give in ~1.2k tokens

Counted across 448 of the 471 authors here whose files we hold, read 2026-09-06

  • Use HTTP status codes semanticallyin 25 of 448, across 11 files
  • Return 201 with a Location header on createin 24 of 448, across 9 files
  • Name resources plural, lowercase, kebab-casein 23 of 448, across 9 files
  • Configure rate limiting with limit headersin 22 of 448, across 8 files
  • Paginate list endpoints with cursor or offsethere, and in 21 of 448, across 10 files
  • Version APIs in the URL pathin 21 of 448, across 11 files
  • Validate request input with a schemain 21 of 448, across 7 files
  • Add pagination to all list endpointsin 18 of 448, across 15 files
  • Match HTTP method to the operationin 12 of 448, across 6 files
  • Return 400 or 422 with field-level detailsin 12 of 448, across 2 files
  • Check ownership before returning resourcesin 12 of 448, across 2 files
  • Limit query depth and complexityin 12 of 448, across 7 files

Said here and by no other author read

  • Start from the domain model, not the UI
  • Map each resource to its operations before designing URLs
  • Present the endpoint list to the user before designing schemas
  • Map HTTP status codes consistently
  • Specify authentication and authorization per endpoint
  • Prefer flat resource URLs over deeply nested ones

Grouped from the skills themselves: near-identical wordings counted once, and counted by distinct author, so one author publishing three of these counts once. Length counted with cl100k_base; the agent that loads this file may tokenize it differently.

Keep looking

Skills are one crate of 325,949. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.