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

api-design

Skill1 starsChanged 7 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.

191 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use db-design, everything-claude-code 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.
  • yuexueyuSkill

    db-design

    数据库工程师技能 - Schema设计、索引优化、并发安全、数据库审计。当你涉及数据库表/字段/索引/SQL/迁移/MCP数据库操作、建表改表、写查询时必须使用此技能。即使用户只是说"加个字段"或"查下数据",也应触发。

    Also in 4 projects that use this

  • InfopibeSkill

    everything-claude-code

    Also in 9 projects that use this

  • mryeastcodeSkill

    everything-claude-code-conventions

    Development conventions and patterns for everything-claude-code. JavaScript project with conventional commits.

    Also in 8 projects that use this

  • tpavanipradeepSkill

    nextjs-turbopack

    Next.js 16+ and Turbopack — incremental bundling, FS caching, dev speed, and when to use Turbopack vs webpack.

    Also in 15 projects that use this

  • Indium-AI-LabsSkill

    data-pipeline-design

    Design batch or incremental ETL and ELT pipelines and warehouse models: grain, partitioning, idempotent loads, late-arriving data, data quality tests, PII controls, and cost monitoring, before building them. Use when adding or changing a dbt model, warehouse table, scheduled transformation, or ingestion job. Not for transactional schema design (use the database-design skill) or event-sourced stores (use the event-sourcing-architecture skill).

    Also in 3 projects that use this

  • thejordanleopoldSkill

    third-party-integration

    Use when integrating with external APIs, payment processors (Stripe), webhooks, or third-party services. Use when implementing API clients with authentication and rate limiting, handling webhooks with signature verification and idempotency, writing contract tests for external services, or isolating third-party dependencies behind adapters. Triggers: \"Stripe\", \"payment integration\", \"webhook\", \"third-party API\", \"external service\", \"API client\", \"integrate with\", \"signature verification\", \"idempotency key\".

    Also in 3 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 165 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 165 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.