agentleFS
Dokkabei97Dokkabei97/forged-claude-code/skills/cto/api-first-design/SKILL.md

api-first-design

Skill2 starsChanged 9 months agoMITView on GitHub

Designs API-first with OpenAPI/GraphQL schemas, then generates server stubs and client SDKs. Enables parallel frontend/backend development for small teams.

The file

Files
SKILL.md

API First Design - Contract-Driven Development

Overview

Design the API contract first, then build frontend and backend in parallel. Small teams move faster when everyone agrees on the interface upfront.


1. When to Apply

TriggerBehavior
Starting new APIFull API design workflow
"OpenAPI", "API design"Schema generation
Frontend/backend need to work in parallelContract-first setup

2. Design Workflow

Step 1: Define Resources

From domain description, identify:

  • Nouns → Resources (User, Post, Order)
  • Verbs → Operations (create, list, update, delete)
  • Relationships → Nested routes or query params

Step 2: Generate OpenAPI Spec

openapi: 3.1.0
info:
  title: My App API
  version: 1.0.0
paths:
  /api/v1/users:
    get:
      summary: List users
      parameters:
        - name: page
          in: query
          schema: { type: integer, default: 1 }
        - name: limit
          in: query
          schema: { type: integer, default: 20, maximum: 100 }
      responses:
        '200':
          description: User list
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items: { $ref: '#/components/schemas/User' }
                  pagination:
                    $ref: '#/components/schemas/Pagination'
    post:
      summary: Create user
      requestBody:
        required: true
        content:
          application/json:
            schema: { $ref: '#/components/schemas/CreateUser' }
      responses:
        '201':
          description: Created
components:
  schemas:
    User:
      type: object
      properties:
        id: { type: string, format: uuid }
        email: { type: string, format: email }
        name: { type: string }
        createdAt: { type: string, format: date-time }
    CreateUser:
      type: object
      required: [email, name]
      properties:
        email: { type: string, format: email }
        name: { type: string, minLength: 1, maxLength: 100 }

Step 3: API Design Rules

  • Use plural nouns: /users not /user
  • Version your API: /api/v1/
  • Consistent error format: { error: { code, message, details } }
  • Pagination: cursor-based for large sets, offset for small
  • Filtering: ?status=active&sort=-createdAt

3. REST vs GraphQL Decision

FactorRESTGraphQL
Multiple clients with different needs❌ Over/under-fetching✅ Client-driven queries
Simple CRUD✅ Standard patterns❌ Overkill
Caching✅ HTTP caching built-in⚠️ Requires effort
Team size < 5✅ Simpler to learn❌ Learning curve
Startup default✅ Start hereConsider at scale

4. Tool Coordination

ToolPurpose
WriteGenerate OpenAPI/GraphQL schemas
ReadAnalyze existing API code
BashGenerate stubs (npx openapi-generator-cli generate)

5. Boundaries

Will:

  • Design RESTful APIs with OpenAPI specs
  • Design GraphQL schemas
  • Generate server stubs and client types
  • Apply API design best practices

Will Not:

  • Implement business logic behind endpoints
  • Set up API gateways or rate limiting infrastructure
  • Handle authentication design (use security-audit)
  • Load test APIs

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.