agentleFS
michaelsvanbeekmichaelsvanbeek/personal-agent-skills/skills/api-design/SKILL.md

api-design

Skill1 starsChanged 8 months agoMITView on GitHub

REST API design conventions and contract standards. Use when: designing API endpoints, defining request/response schemas, implementing pagination, versioning APIs, creating OpenAPI specs, adding rate limiting, designing error responses, auditing existing APIs for REST convention compliance, or improving API consistency and documentation.

125 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use data-modeling, ci-pipeline and 9 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.
  • mmondoraSkill

    data-modeling

    Schema design, multi-tenant data isolation, and migration management. Firestore and PostgreSQL patterns, RLS, UUID v7 conventions. Use when designing database schemas, writing migrations, or implementing multi-tenant data access.

    Also in 7 projects that use this

  • vndeeSkill

    ci-pipeline

    Use when creating or updating CI/CD pipelines with GitHub Actions or GitLab CI for Go, Python, or React projects

    Also in 4 projects that use this

  • pluginagentmarketplaceSkill

    microservices

    Microservices architecture patterns and best practices. Service decomposition, inter-service communication, and distributed data management.

    Also in 4 projects that use this

  • kevinaimonsterSkill

    typescript-strict

    TypeScript strict mode and advanced type system assistant. Helps write strictly-typed TypeScript code with generics, type guards, utility types, conditional types, mapped types, and template literal types. Trigger when user says 'TypeScript types' 'type gymnastics' 'TypeScript generics' 'strict TypeScript' 'type guard' 'TS类型' 'TypeScript严格模式' '类型体操' '泛型怎么写' 'TS type help'. Keywords: TypeScript, strict mode, generics, type guard, utility types, conditional types, mapped types, template literal types, infer, extends, keyof, typeof, type narrowing, discriminated unions, type assertion, type predicate, type gymnastics, TS, 类型体操, 泛型, 类型守卫, 严格类型

    Also in 4 projects that use this

  • InfopibeSkill

    deployment-patterns

    Deployment workflows, CI/CD pipeline patterns, Docker containerization, health checks, rollback strategies, and production readiness checklists for web applications.

    Also in 10 projects that use this

  • DatabricksSkill

    load-testing

    Load test a Databricks App to find its maximum QPS. Use when: (1) User says 'load test', 'benchmark', 'QPS', 'throughput', or 'performance test', (2) User wants to find how many queries per second their app can handle, (3) User wants to set up load testing scripts for their agent, (4) User wants to view load test results/dashboard, (5) User wants to validate results or observe latency/error rate with MLflow tracing.

    Also in 4 projects that use this

The file

Show its rules and text

We split this skill into the rules it gives an agent

15 rules. 0 are common, 10 are distinctive, and 5 are very specific to this project.

  • 0

    Common

    Most of the 104 edited versions we read keep these.

  • 10

    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. Very specific:

    Use plural nouns for collections: /projects, /users, /orders.

    line 25
  2. Very specific:

    Use nested routes for relationships: /projects/{id}/members.

    line 26
  3. Distinctive:

    Keep URLs flat — avoid nesting deeper than 2 levels.

    line 27
  4. Very specific:

    Use kebab-case for multi-word resources: /build-logs, not /buildLogs.

    line 28
  5. Distinctive:

    Use the correct status code.

    line 44
  6. Distinctive:

    All errors return a consistent shape:

    line 62
  7. Distinctive:

    Never expose stack traces, internal paths, or database errors.

    line 82
  8. Distinctive:

    Prefer cursor-based pagination over offset-based.

    line 86
  9. Very specific:

    Use URL path versioning: /v1/projects.

    line 126
  10. Distinctive:

    Only increment the major version for breaking changes.

    line 127
  11. Distinctive:

    If the same key is seen again, return the stored response without re-executing.

    line 141
  12. Very specific:

    Timestamps: Always ISO 8601 with timezone: 2026-03-20T12:00:00Z.

    line 161
  13. Distinctive:

    Every API must have an OpenAPI 3.x spec.

    line 168
  14. Distinctive:

    Document all error responses, not just the happy path.

    line 170
  15. Distinctive:

    Keep the spec in sync — generate from code, don't maintain separately.

    line 172

“Common” is measured: kept by at least 6 in 10 of the 104 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 Design Standards

When to Use

  • Designing new API endpoints or resources
  • Defining request/response schemas
  • Implementing pagination, filtering, or sorting
  • Versioning an API
  • Writing OpenAPI/Swagger documentation
  • Adding rate limiting or idempotency
  • Auditing existing APIs for REST convention violations (naming, status codes, error shapes, pagination patterns)
  • Improving API consistency across endpoints (response envelopes, error formats, query parameter conventions)

REST Conventions

Resource Naming

  • Use plural nouns for collections: /projects, /users, /orders.
  • Use nested routes for relationships: /projects/{id}/members.
  • Keep URLs flat — avoid nesting deeper than 2 levels. Use query params for filtering beyond that.
  • Use kebab-case for multi-word resources: /build-logs, not /buildLogs.

HTTP Methods

MethodPurposeIdempotentResponse
GETRead resource(s)Yes200 with body
POSTCreate resourceNo201 with created resource
PUTReplace resource entirelyYes200 with updated resource
PATCHPartial updateNo*200 with updated resource
DELETERemove resourceYes204 no body

*PATCH can be made idempotent with proper design.

Status Codes

Use the correct status code. Don't return 200 for everything.

CodeWhen
200Successful read or update
201Resource created
204Successful delete (no body)
400Invalid request (validation error, malformed body)
401Authentication required or invalid
403Authenticated but not authorized
404Resource not found
409Conflict (duplicate, state mismatch)
422Semantically invalid (well-formed but logically wrong)
429Rate limited
500Server error (never expose internals)

Error Response Format

All errors return a consistent shape:

{
  "error": "validation_error",
  "message": "Name is required and must be between 1-100 characters",
  "status": 400,
  "details": [
    { "field": "name", "issue": "required" }
  ],
  "request_id": "abc-123"
}
  • error: Machine-readable error code (snake_case).
  • message: Human-readable explanation.
  • status: HTTP status code (duplicated for convenience).
  • details: Optional array of field-level errors.
  • request_id: Correlation ID for debugging.

Never expose stack traces, internal paths, or database errors.

Pagination: Cursor-Based

Prefer cursor-based pagination over offset-based. Offset pagination breaks when data changes between pages.

Request

GET /projects?limit=25&cursor=eyJpZCI6MTIzfQ
  • limit: Page size (default: 25, max: 100).
  • cursor: Opaque string encoding the position. Base64-encoded JSON is common.

Response

{
  "data": [...],
  "pagination": {
    "next_cursor": "eyJpZCI6MTQ4fQ",
    "has_more": true,
    "total": 247
  }
}
  • total is optional — include if cheaply available, omit if it requires a full count query.
  • First page request omits cursor.

Filtering and Sorting

GET /projects?status=active&owner=usr_42&sort=-updated_at&fields=id,name,status
  • Filter by field name as query param.
  • Sort with sort param. Prefix with - for descending.
  • Sparse fields with fields param to reduce payload size.
  • Multiple values for same filter: status=active,archived (comma-separated).

Versioning

  • Use URL path versioning: /v1/projects.
  • Only increment the major version for breaking changes.
  • Support the previous version for a deprecation period. Return Sunset and Deprecation headers on the old version.
  • Non-breaking changes (new optional fields, new endpoints) do not require a version bump.

Idempotency

For non-idempotent operations (POST), support an Idempotency-Key header:

POST /orders
Idempotency-Key: unique-client-generated-uuid
  • Store the key + response for a TTL (e.g., 24 hours).
  • If the same key is seen again, return the stored response without re-executing.
  • Return 409 Conflict if the key was used with different request body.

Rate Limiting

Return rate limit info in response headers:

X-RateLimit-Limit: 100
X-RateLimit-Remaining: 42
X-RateLimit-Reset: 1711000800
  • Return 429 Too Many Requests when limit is exceeded.
  • Include Retry-After header with seconds until reset.
  • Rate limit by API key, user, or IP — not globally.

Request/Response Conventions

  • Request bodies: camelCase for JSON APIs consumed by JavaScript clients, snake_case for Python-to-Python APIs. Pick one and be consistent.
  • Timestamps: Always ISO 8601 with timezone: 2026-03-20T12:00:00Z.
  • IDs: Strings, not integers. Use prefixed IDs when helpful: prj_123, usr_456.
  • Nulls: Omit null fields from responses rather than including "field": null.
  • Envelope: Wrap collections in { "data": [...] }. Single resources can be returned directly or wrapped consistently.

OpenAPI Documentation

  • Every API must have an OpenAPI 3.x spec.
  • FastAPI generates this automatically — ensure all routes have type annotations, descriptions, and example values.
  • Document all error responses, not just the happy path.
  • Include authentication requirements per endpoint.
  • Keep the spec in sync — generate from code, don't maintain separately.

For FastAPI web server implementation patterns, see the python-web-server skill. For database design and query patterns backing API endpoints, see the database skill. For input validation and security hardening, see the security skill.

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.