agentleFS
kwhornekwhorne/elyra-skills/skills/api-design/SKILL.md

api-design

Skill1 starsChanged 6 months agoMITView on GitHub

Design consistent HTTP/REST endpoints with sensible naming, status codes, pagination, error formats, and versioning. Use when the user asks to design, review, or extend an HTTP API, or wants feedback on endpoint shape.

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 8 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

We split this skill into the rules it gives an agent

12 rules. 0 are common, 6 are distinctive, and 6 are very specific to this project.

  • 0

    Common

    Most of the 104 edited versions we read keep these.

  • 6

    Distinctive

    This author's own choices. Worth a look.

  • 6

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Anchor to existing patterns: Read 2–3 existing endpoints in the same codebase.

    line 26
  2. Very specific:

    Use plural nouns for collections: /users, /orders, /articles

    line 34
  3. Very specific:

    Use IDs, not slugs, for identity: /users/42 (slugs are for SEO, not for APIs)

    line 35
  4. Very specific:

    Use kebab-case in paths: /account-settings, not /accountSettings or /account_settings

    line 39
  5. Distinctive:

    No verbs in paths — the HTTP method *is* the verb

    line 41
  6. Very specific:

    Don't invent custom codes.

    line 75
  7. Distinctive:

    Use a single, documented error shape across the entire API:

    line 79
  8. Distinctive:

    Consider RFC 9457 Problem Details if the consumer already uses it.

    line 100
  9. Very specific:

    Always cap limit / per_page server-side.

    line 113
  10. Distinctive:

    Only bump the major version for breaking changes.

    line 129
  11. Distinctive:

    When CRUD doesn't fit (publish, archive, retry, refund), prefer:

    line 133
  12. Very specific:

    Don't go full RPC: POST /publishArticle?id=42.

    line 138

“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

Principles for HTTP/REST APIs that are predictable, debuggable, and pleasant to consume. Opinionated where the field has converged; flexible where reasonable people disagree.

When to use

  • "Design an endpoint for X"
  • "How should this API look?"
  • "Review this API"
  • "Add an endpoint to …"

Procedure

  1. Anchor to existing patterns. Read 2–3 existing endpoints in the same codebase. New endpoints should look like neighbors.
  2. Model the resource, not the action. Most actions become CRUD on a resource. If they don't (e.g. "publish"), see "Actions on resources" below.
  3. Sketch the contract before writing code: path, method, request body, response body, status codes, errors.
  4. Check it against the consistency checklist below.
  5. Document it — even one paragraph in the PR is better than nothing.

Resource naming

  • Use plural nouns for collections: /users, /orders, /articles
  • Use IDs, not slugs, for identity: /users/42 (slugs are for SEO, not for APIs)
  • Nest to express ownership, max 2 levels deep:
    • ✅ /users/42/orders
    • ❌ /users/42/orders/7/items/3/shipments
  • Use kebab-case in paths: /account-settings, not /accountSettings or /account_settings
  • Lowercase everything in paths
  • No verbs in paths — the HTTP method is the verb

Methods

MethodPurposeIdempotentSafe
GETRetrieveyesyes
POSTCreate, or non-idempotent actionnono
PUTReplace (full update)yesno
PATCHPartial updateno*no
DELETERemoveyesno

* PATCH can be idempotent if you design it that way; don't rely on it.

Status codes

Pick from this short list. Resist the urge to be clever.

CodeMeaningUse for
200 OKSuccess with bodyGET, PATCH, PUT returning resource
201 CreatedResource createdPOST that creates a resource (return it + Location header)
202 AcceptedAccepted for async processingLong-running jobs
204 No ContentSuccess, no bodyDELETE, PUT without return
400 Bad RequestMalformed requestBad JSON, missing required fields
401 UnauthorizedNot authenticatedMissing/invalid credentials
403 ForbiddenAuthenticated but not allowedPermission denied
404 Not FoundResource doesn't existUnknown ID
409 ConflictState conflictDuplicate, version mismatch
422 Unprocessable EntityValidation failedWell-formed but semantically invalid
429 Too Many RequestsRate-limitedInclude Retry-After
500 Internal Server ErrorWe broke itUnexpected server fault
503 Service UnavailableTemporarily downMaintenance, dependency outage

Don't invent custom codes. Don't return 200 with {"error": "..."}.

Errors

Use a single, documented error shape across the entire API:

{
  "error": {
    "code": "validation_failed",
    "message": "Request failed validation.",
    "details": [
      { "field": "email", "code": "invalid_format" },
      { "field": "age", "code": "must_be_positive" }
    ],
    "request_id": "req_01HX…"
  }
}
  • Stable, machine-readable code (snake_case, never localized)
  • Human-readable message (English; localize on the client)
  • details for per-field validation
  • request_id for support / log correlation

Consider RFC 9457 Problem Details if the consumer already uses it.

Pagination

Pick one and stick with it across the API.

  • Cursor-based (preferred for large/changing data):
    • Request: ?limit=50&cursor=eyJpZCI6...
    • Response: { "data": [...], "next_cursor": "...", "has_more": true }
  • Page-based (fine for small/static data):
    • Request: ?page=2&per_page=50
    • Response: { "data": [...], "page": 2, "per_page": 50, "total": 1234 }

Always cap limit / per_page server-side. Document the max.

Filtering, sorting, sparse fields

  • Filter: ?status=active&created_after=2025-01-01
  • Sort: ?sort=-created_at,name (leading - = descending)
  • Sparse fields: ?fields=id,email,created_at

Versioning

Pick one strategy and commit:

  • URL: /v1/users — most visible, easiest to route
  • Header: Accept: application/vnd.example.v1+json — cleaner URLs, harder to debug
  • Avoid query-string versioning

Only bump the major version for breaking changes. Additive changes (new fields, new endpoints) don't require a new version.

Actions on resources

When CRUD doesn't fit (publish, archive, retry, refund), prefer:

  • State transitions via PATCH: PATCH /articles/42 {"status": "published"} — best if you have multiple states
  • Sub-resources for explicit actions: POST /articles/42/publish — pragmatic when the action has side effects or its own payload

Don't go full RPC: POST /publishArticle?id=42. You're using HTTP; use it.

Consistency checklist

  • Resource name is a plural noun
  • Path uses kebab-case and lowercase
  • HTTP method matches semantics (idempotency!)
  • Status codes from the short list
  • Error response matches the API-wide error shape
  • POST that creates returns 201 + Location header
  • List endpoints paginate and cap limit
  • Timestamps are ISO 8601 with timezone (2026-05-22T14:30:00Z)
  • IDs are opaque strings (not auto-increment ints leaked) when possible
  • No sensitive data in URLs (use headers / body)
  • Versioning strategy followed
  • Authentication / authorization checks documented per endpoint

Anti-patterns

  • ❌ GET /getUser?id=42 — verb in path, query param for identity
  • ❌ POST /users/delete/42 — DELETE exists for a reason
  • ❌ Returning 200 with {"success": false}
  • ❌ Inconsistent casing: userId in one response, user_id in another
  • ❌ Auto-increment IDs in URLs leaking row counts to the public
  • ❌ Pagination with no upper bound on limit
  • ❌ Mixing snake_case and camelCase in the same payload
  • ❌ "Soft 200" — returning HTTP success but logical failure

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.