agentleFS
nahid-sparktalesnahid-sparktales/agent-dispatcher/skills/backend/api-design/SKILL.md

api-design

Skill59 starsChanged 2 months agoMITView on GitHub

Design or change an HTTP API — resources, verbs, status codes, one error shape, pagination, versioning, and an OpenAPI description that cannot drift from the handlers. Use when adding or reshaping endpoints, when asked what a response should return, or when reviewing whether a change to a published API breaks its consumers. Not for choosing between REST, GraphQL and RPC, not for database schema design, and not for implementing the handler's business logic.

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

1 rule. 0 are common, 1 is distinctive, and 0 are very specific to this project.

  • 0

    Common

    Most of the 104 edited versions we read keep these.

  • 1

    Distinctive

    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:

    Allowlist filtering and sorting fields: Never pass a client string into a sort or filter expression.

    line 46

“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

The shape of an endpoint is a promise to code you do not control. Most of this skill exists to stop a change being made casually that a consumer will experience as an outage.

When this fires

Adding an endpoint, changing a response body, changing validation, or reviewing someone else's API change. It does not fire for an internal function signature, or for a private endpoint with exactly one caller in the same deployment unit — there, match the surrounding code and move on.

Procedure

  1. Read the neighbours before designing anything. Three or four existing endpoints: their URL style, error envelope, auth mechanism, pagination style, date format, casing. An endpoint that disagrees with the ones beside it is a defect even when it is individually better. If the existing API disagrees with itself, say so and pick the dominant convention — do not silently introduce a third.
  2. Name resources, not actions. Plural nouns; nesting only where the child genuinely cannot exist without the parent. When an operation is a verb that resists this (/orders/{id}/refunds, /jobs/{id}/cancel), model it as a subordinate resource or a state transition rather than bending the noun.
  3. Pick the verb by its contract, not by convenience. GET is safe and cacheable and never mutates. PUT replaces the whole resource and is idempotent. PATCH is partial — say which patch format. DELETE is idempotent in effect. POST is everything else and is the only one a client may not blindly repeat. If you want a repeatable POST, that is idempotency-and-retries.
  4. Choose status codes deliberately. 201 with a Location for a created resource; 202 when the work is queued and the body says how to follow it; 204 only when there is genuinely nothing to return. 400 for malformed, 422 for well-formed but invalid; 401 unauthenticated vs 403 unauthorized; 404 rather than 403 when merely confirming existence leaks information; 409 for a conflict with current state; 429 with Retry-After. Never return 5xx for a client's mistake, and never 200 with an error inside.
  5. Define one error shape for the whole API and reuse it. A stable machine-readable code, a human-readable message, per-field detail for validation, and a correlation id. If the project has no precedent, application/problem+json is a reasonable default. Errors must not carry stack traces, SQL, internal hostnames or another tenant's identifiers.
  6. Pagination: cursor by default. Opaque cursor, a stable sort key with a unique tiebreaker, a server-enforced maximum page size, and a documented answer for what happens when rows change mid-scan. Offset paging is acceptable only for small, stable, human-browsed lists. Return the next cursor; a total count is a separate, optional, often expensive promise.
  7. Allowlist filtering and sorting fields. Never pass a client string into a sort or filter expression. An unbounded filter surface is both an injection risk and a permanent compatibility obligation.
  8. Decide the compatibility rule before shipping, not at the first break. Within a version, additive only: new optional fields, new endpoints, new enum values only if consumers were told to tolerate unknown ones. Breaking includes removing or renaming a field, tightening validation, changing a default, changing an error code, narrowing a type, and changing the meaning of a value while keeping its name. Pick one versioning mechanism — URL path, media type, or a date header — and do not mix two.
  9. Write the description from the thing that serves the requests. Generate the OpenAPI document from the handlers, types or schemas where the stack allows it. Where it must be hand-written, add a contract check that fails CI when the document and the handlers disagree, and treat drift as a defect rather than a documentation chore. A spec nobody can fail is decoration.
  10. Walk one real consumer sequence end to end — authenticate, create, read back, page, hit a validation error, hit a 404. Write out the actual requests and responses. Most design mistakes surface here and nowhere earlier.
  11. Stop at the boundary. Writing the route is created. Calling it once is executed. A contract or integration test is tested. Publishing it, deploying it, or changing an endpoint other teams already call is outward-facing: name the breaking changes and the consumers, and ask before shipping.

Checklist

  • Conventions of the existing API were read, and any deviation is deliberate and stated
  • Every new endpoint has resource, verb, success status, and each error status listed
  • Errors use the project's single error shape and leak nothing internal
  • Collections paginate with a bounded page size and a stable order
  • Filter and sort fields are an allowlist
  • Each change classified as additive or breaking, with the breaking ones named
  • The OpenAPI description is generated or checked against the handlers, not just edited
  • One consumer sequence written out with real requests and responses
  • Auth and authorization stated per endpoint, including who may read another user's row

Failure handling

  • Cannot tell whether a change is breaking — treat it as breaking. The cost of a needless version is a fraction of the cost of a silent one.
  • Spec and implementation disagree — the implementation is what consumers have already built against; the spec is what they were promised. Report both, change the one that is wrong, and do not quietly edit the spec to match a regression.
  • No consumer is known — that is not the same as no consumer existing. Say the blast radius is unknown rather than assuming it is zero.
  • The framework's behaviour is uncertain (how it serializes, validates, or maps status codes) — check its current documentation or test it. Do not describe behaviour you have not confirmed.
  • Asked to design around a database table — say so. An API that is a view of the schema will break every time the schema does.

Evidence to report

The endpoint table — path, verb, success status, error statuses, auth. One real request and response per new endpoint, including an error. The diff of the OpenAPI document and the result of the contract check. An explicit list of breaking changes with the consumers affected, or "none, and here is why". And the distinction kept honest: which endpoints were merely written, which were executed, and which have a test that would fail if the contract changed.

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.