agentleFS
d-o-hubd-o-hub/github-template-ai-agents/.agents/skills/api-design-first/SKILL.md

api-design-first

Skill2 starsChanged 10 days agoMITView on GitHub

Design and document RESTful APIs using design-first principles with OpenAPI specifications. Use this skill when the user asks to design an API, create an API spec, plan endpoints, model request/response schemas, or discuss API versioning — even if they just say "design the API" or "create the OpenAPI spec". Not for cloudflare-worker-api.

1 other project uses a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

4 rules. About 0 are common, 4 are distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈4

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Use OpenAPI 3.0 as the source of truth

    line 26
  2. Distinctive:

    Use nouns for resources (not verbs)

    line 31
  3. Distinctive:

    Follow naming conventions throughout

    line 38
  4. Distinctive:

    Use consistent request/response formats

    line 39

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “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 Design First

Design RESTful APIs using design-first principles with comprehensive OpenAPI 3.0 specifications.

When to Use

  • User asks to design an API or create an API spec
  • Planning endpoints, modeling request/response schemas
  • Discussing API versioning or OpenAPI/Swagger documentation
  • Even if they just say "design the API" or "create the OpenAPI spec"

Design Principles

1. API-First Mindset

  • Design the API contract before implementation
  • Use OpenAPI 3.0 as the source of truth
  • Generate code from specifications, not vice versa

2. RESTful Design

  • Use nouns for resources (not verbs)
  • Leverage HTTP methods semantically
  • Implement proper status codes
  • Support filtering, pagination, and sorting

3. Consistency

  • Follow naming conventions throughout
  • Use consistent request/response formats
  • Maintain backward compatibility with versioning

Resource Naming

GET    /users              # List users
GET    /users/{id}         # Get specific user
POST   /users              # Create user
PUT    /users/{id}         # Update user (full)
PATCH  /users/{id}         # Partial update
DELETE /users/{id}         # Delete user
GET    /users/{id}/orders  # Sub-resource collection

HTTP Status Codes

CodeUsage
200Successful GET, PUT, PATCH
201Successful POST (resource created)
204Successful DELETE
400Bad request (validation error)
401Unauthorized
403Forbidden
404Resource not found
409Conflict (duplicate, etc.)
422Unprocessable entity
429Rate limited
500Server error

Request/Response Patterns

Pagination

{
  "data": [...],
  "meta": {
    "page": 1,
    "per_page": 20,
    "total": 150,
    "total_pages": 8
  },
  "links": {
    "self": "/users?page=1",
    "next": "/users?page=2",
    "last": "/users?page=8"
  }
}

Error Response

{
  "error": {
    "code": "VALIDATION_ERROR",
    "message": "Request validation failed",
    "details": [
      { "field": "email", "message": "Invalid email format" }
    ]
  }
}

OpenAPI Structure

openapi: 3.0.3
info:
  title: Example API
  version: 1.0.0
paths:
  /users:
    get:
      summary: List users
      parameters:
        - name: page
          in: query
          schema:
            type: integer
      responses:
        '200':
          description: Success

Versioning Strategies

  1. URL Path: /v1/users, /v2/users
  2. Header: Accept: application/vnd.api+json;version=2
  3. Query Param: /users?api-version=2

See Also

  • cloudflare-worker-api — Cloudflare Worker API routes
  • secure-invite-and-access — Auth endpoints and permissions

Rationalizations

RationalizationReality
"We'll design the API after implementing the feature."Post-hoc API design leads to inconsistent contracts, breaking changes, and poor developer experience.
"Verbs in URLs are fine — /getUser is clear."REST uses HTTP methods for actions; verb-based URLs break caching, proxying, and violate RESTful conventions.

Red Flags

  • Designing endpoints without an OpenAPI specification first
  • Using verbs in resource URLs instead of nouns with HTTP methods
  • Ignoring versioning strategy until breaking changes force a rewrite

References

  • references/rest-guidelines.md - Comprehensive REST design guidelines
  • references/openapi-examples.md - Complete OpenAPI 3.0 specification examples
  • references/naming-conventions.md - Resource and field naming standards

Voice & Context

  • Default: professional + blog
  • Reference: voice-profiles skill for definitions and auto-detection.

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.