api-contract-design
Skill0 starsChanged 2 months agoMITView on GitHub
Design frontend-backend contracts that age well — resource modeling, pagination, error envelopes, idempotency, versioning — for REST or tRPC. Use when adding endpoints, integrating an API, or fixing client-server misunderstandings.
6 other projects use a version of this.
Adopted by
Most recently taken up by
- OugeX/dsh-web-dev-modetheir own version, first seen Nov 1, 2026
- chadixearth/graphylooptheir own version, first seen Oct 13, 2026
- dathuynh1108/agent-skillstheir own version, first seen Oct 11, 2026
- hemapriyan-rk/claude-rigor-skillstheir own version, first seen Sep 26, 2026
- 05-deepak-patidar/claude-skillstheir own version, first seen Jul 7, 2026
- MohOneX/claude-opus-skillstheir own version, first seen Jun 6, 2026
Used with
Projects with it also use testing-strategy.
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.
BlockSkilltesting-strategy
Guidelines for writing effective tests in this project
Also in 3 projects that use this
Other versions6 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 6
- 05-deepak-patidar/claude-skills★ 4same name
- dathuynh1108/agent-skills★ 4same name
- chadixearth/graphyloop★ 3same name
- hemapriyan-rk/claude-rigor-skills★ 1same name
- MohOneX/claude-opus-skills★ 0same name
- OugeX/dsh-web-dev-mode★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository11 other files it gives its agents.
- browser-debuggingSkill
- component-reviewSkill
- css-architectureSkill
- frontend-testing-strategySkill
- nextjs-performanceSkill
- performance-budgetSkill
- react-hooks-disciplineSkill
- state-managementSkill
- typescript-strictnessSkill
- vue3-compositionSkill
- web-a11ySkill
The file
We split this skill into the rules it gives an agent
3 rules. 0 are common, 2 are distinctive, and 1 is very specific to this project.
0
Common
Most of the 4 edited versions we read keep these.
2
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
- Very specific: line 21
Default to cursor pagination: ?cursor=<opaque>&limit=50, response carries nextCursor.
- Distinctive: line 22
Every list response states its shape explicitly:
- Distinctive: line 57
Every endpoint states its auth requirement in the schema.
“Common” is measured: kept by at least 6 in 10 of the 4 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.
Files
API contract design (frontend ↔ backend)
Contract first
The schema (OpenAPI/GraphQL/tRPC types) is the source of truth, generated into the client. Hand-typed interfaces that "roughly match" the API rot within weeks.
Resource modeling
- Nouns not verbs:
POST /orders, notPOST /createOrder. - Relationships in paths:
GET /users/:id/orders?status=paid. - One resource, one shape. If the mobile app needs less, that's field selection/projection — not a second endpoint with mystery fields.
Pagination: offset is a trap
- Offset (
page=3) breaks under inserts/deletes and degrades on deep pages. - Default to cursor pagination:
?cursor=<opaque>&limit=50, response carriesnextCursor. Opaque cursors also prevent clients from hand-crafting queries. - Every list response states its shape explicitly:
{ "items": [...], "nextCursor": "eyJpZCI6...", "hasMore": true }Errors: one envelope, machine-readable
{
"error": {
"code": "VALIDATION_FAILED",
"message": "email is not a valid address",
"details": [{ "field": "email", "rule": "format" }],
"requestId": "req_9f2c"
}
}- HTTP status classes stay correct (4xx client, 5xx server) but the code string is what clients branch on — never parse
message. requestIdon every error; it's the join key to server logs when a user reports "it didn't work".
Idempotency & retries
- Non-GET from clients that retry (network flake, double-click) carries
Idempotency-Key: <uuid>; server dedupes. - Client retries: exponential backoff + jitter, only on idempotent requests or with a key; timeouts on everything.
Versioning
- Version at the URL or header (
/v1/), never at field names (nameV2). - Additive changes only within a version; breaking changes bump.
- Deprecation is a process: announce → dual-write window → remove. Clients see a
Deprecation/Sunsetheader before the break.
Auth & multi-tenancy
- Every endpoint states its auth requirement in the schema; the client's generated types force the token flow.
- Tenant scoping is server-side on every query — "my orders" means
where userId = caller, enforced once in the data layer, not per endpoint.
Definition of done (agent checklist)
- Schema is generated/consumed, not hand-mirrored
- Lists: cursor pagination + explicit envelope
- Errors: code + details + requestId, statuses correct
- Mutations: idempotency keys where retries possible
- Breaking changes versioned; deprecation headers wired
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
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.

