agentleFS
leroyguillaumeleroyguillaume/claude/api-conventions/SKILL.md

api-conventions

Skill7 starsChanged 2 days agoMITView on GitHub

HTTP/JSON API payloads in any language: DTOs, JSON casing, pagination, OpenAPI docs. TRIGGER when: adding or changing an endpoint, handler, route, controller or DTO/schema type; returning a list from an endpoint; designing a JSON body, params or an OpenAPI spec; user asks about API contracts, serialisation, casing or pagination. SKIP when: no request/response surface is touched, or the surface is not JSON over HTTP (gRPC, GraphQL, JSON-RPC). Load `rest-conventions` alongside for URLs and methods.

17 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use add-a-use-case, branches-and-pull-requests 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.
  • LeanMeanCleanAppsSkill

    add-a-use-case

    How to add a command or query to the Application layer as a vertical slice (request, handler, validator, tests) using source-generated Mediator. Use when adding a new feature, a new query, or a new write operation.

    Also in 5 projects that use this

  • LeanMeanCleanAppsSkill

    branches-and-pull-requests

    Branch naming (feature/, fix/, chore/), how labels and release notes follow from the branch, the pull request template, and how changes get merged in the template repository. Use when creating a branch, writing a commit or opening a pull request.

    Also in 5 projects that use this

  • +10 more from LeanMeanCleanApps

The file

We split this skill into the rules it gives an agent

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

  • 0

    Common

    Most of the 12 edited versions we read keep these.

  • 0

    Distinctive

    This author's own choices. Worth a look.

  • 1

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Prefer to make the rule unbreakable by construction: keep the (de)serialisation capability off the domain types themselves (e.g.

    line 38

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

Applies to every JSON-over-HTTP surface, in any language or framework. The language skills restate the mechanics (which validation crate, which serde attribute) where they need to be concrete.

This skill owns what goes in the messages. rest-conventions owns the URLs and methods — the path names a resource, the method is the verb, and no endpoint is called /list or /update. Both apply to every HTTP endpoint.

  • Never bind a domain, entity, or persistence model directly to a request or response body. Domain / ORM / database structs stay behind the boundary; they must not be (de)serialised at the wire.
  • For every endpoint, define dedicated DTOs named after the operation — CreateXRequest / UpdateXRequest for inputs and XResponse for outputs (using the language's idiomatic casing). One DTO per request and per response; do not reuse a domain type "because the fields happen to match", and do not share one DTO across create and update.
  • Validate at the DTO layer (e.g. the validator crate in Rust, Pydantic in Python) and convert explicitly between DTOs and domain models (From/Into, a mapper, etc.). A handler's job is exactly: deserialise the request DTO → validate → map to a domain model → call the domain/repository layer → map the result into a response DTO.
  • Prefer to make the rule unbreakable by construction: keep the (de)serialisation capability off the domain types themselves (e.g. do not derive Serialize/Deserialize on entities) so binding one to the wire fails to compile.
  • This keeps the wire contract decoupled from internal models: renaming a column or restructuring an entity never silently changes the public API.
  • All JSON body fields are camelCase, regardless of the language's native casing. Apply it at the serialisation layer, not by renaming each field: in Rust put #[serde(rename_all = "camelCase")] on every request/response DTO (schemars honours it, so the OpenAPI schema matches the wire). Path and query parameters are camelCase too — {jobId}, ?teamId= — so a name reads the same in the URL and in the body.
  • Name foreign-key fields consistently as <entity>_id (→ <entity>Id on the wire): creator_id, game_id — never a mix like created_by alongside game_id. The referenced entity's own identifier stays id. Pick the suffix convention once and apply it to every reference field.
  • Group endpoints into named categories so the generated reference is navigable: tag every operation (OpenAPI tag / the framework's equivalent) and declare the tags up front with a description and a deliberate order (e.g. Authentication, then the main resources). No operation ships untagged.
  • Serve the OpenAPI document from the application itself, at /openapi.json. It is generated from the code by the framework (aide in Rust, FastAPI's own generator in Python, …), never hand-written, and no copy is committed to the repository — a generated file that can only ever be a stale duplicate of what the process already publishes is not worth the upkeep.
  • Render that document with Scalar at /docs, and with nothing else. The path and the tool are both fixed, in every language and framework: a reader who knows one of our APIs knows where the reference is on all of them. Whatever documentation UI the framework bundles gets switched off so it cannot drift from Scalar or squat the path — in FastAPI that is docs_url=None and redoc_url=None on the application, then a route of your own on /docs.
  • Load Scalar from its CDN, at an exact version (https://cdn.jsdelivr.net/npm/@scalar/api-reference@<x.y.z>, the latest release resolved when you write it — npm view @scalar/api-reference version — never from memory), not from a build vendored into the service, which moves only when the library bundling it does (check which Scalar build the aide version in use ships). An unpinned URL serves whatever was published last: the page changes, or breaks, with no change to the service, and two deploys of one commit render differently. The trade-off is that /docs needs egress from the reader's browser — the service itself never calls out for it, and /openapi.json answers regardless — which is the right side of the bargain for a docs page.
  • /docs is a page, not an operation: keep it out of the document (in FastAPI, include_in_schema=False), so it never shows up in a generated client or in the tool set an MCP layer derives from the spec.
  • Always paginate list endpoints — never return an unbounded collection. Any endpoint that returns a collection takes pagination parameters and caps how much it returns. The repository/data-layer method that backs it must likewise never materialise the whole table in memory: it either takes a limit or returns a stream that the boundary consumes (e.g. sqlx's .fetch()), applying the page size as it goes. Pagination of the wire contract is non-negotiable regardless of which the data layer uses. Use offset/limit pagination on the wire:
    • Query params page (1-based) and perPage (camelCase on the wire). The boundary maps them to limit = perPage, offset = (page - 1) * perPage for the data layer.
    • Enforce a default and a hard maximum perPage (e.g. default 50, max 100): clamp/validate at the DTO layer so a client can never request an unbounded page. Missing params fall back to the defaults.
    • Return a paginated envelope, not a bare array: { "items": [...], "page": 1, "perPage": 50, "total": 1234 } (total being the number of rows matching the request's filters, across all pages) so clients can compute the page count.
    • Offset/limit is the default; reach for cursor/keyset pagination only when a specific endpoint has deep-pagination or stable-ordering needs that offset can't meet, and say why.

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.