api-contract-design
Skill0 starsChanged 5 months agoMITView on GitHub
Designs and reviews API contracts (REST, RPC, GraphQL, library interfaces) for evolvability, backward compatibility, and failure semantics. Use when defining new endpoints/interfaces, versioning an API, reviewing a schema, or deciding how breaking changes propagate to clients.
We split this skill into the rules it gives an agent
2 rules. 0 are common, 2 are distinctive, and 0 are 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.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 14
Failure: every error the caller must distinguish, retriability, partial-success behavior.
- Distinctive: line 24
Default values are part of the contract.
“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
An API is a promise enforced by other people's code. The cost of a bad contract is paid forever by every caller; design for the version you cannot recall.
Model the contract as four coupled surfaces
- Shape: types, required vs optional fields, nullability, enums (open vs closed).
- Semantics: what each call means, idempotency, ordering guarantees, side effects, consistency level.
- Failure: every error the caller must distinguish, retriability, partial-success behavior.
- Evolution: what can change without breaking callers, and how clients discover capabilities.
A change is "compatible" only if it is safe across all four — a field that is shape-compatible can still be semantically breaking.
Compatibility rules that actually hold
- Adding an optional field: safe. Making an optional field required: breaking.
- Widening an accepted input: safe. Narrowing output guarantees: breaking.
- Closed enums break when you add a variant clients must handle; prefer open enums + documented "unknown" handling.
- Default values are part of the contract. Changing a default is a silent breaking change.
- Tightening validation breaks existing valid-but-sloppy callers. Loosen freely, tighten via new version.
Failure semantics (the part most designs skip)
- Make idempotency explicit: which calls are safe to retry, and is there an idempotency key?
- Distinguish retryable (5xx, timeout) from terminal (4xx) at the type level so clients don't retry into duplication.
- Define partial success precisely — batch endpoints must say which items succeeded, not just "200 OK".
- Errors are an API. Stable codes + machine-readable detail beat prose messages clients will regex.
Adversarial validation
- A hostile client sends nulls, unknown enum values, huge payloads, out-of-order calls, and double-submits. Does the contract still have defined behavior?
- A future you adds a feature. Does the schema have room, or does it force a v2?
- Two clients on different versions hit the same backend. Does data written by one corrupt the view of the other?
- Network dies mid-request. Can the client tell whether the write happened?
Non-obvious tradeoffs
- Versioning strategy (URL vs header vs field-level) trades discoverability against routing complexity; field-level evolution usually beats hard version cuts.
- Rich, nested responses reduce round-trips but couple clients to internal structure — every field you expose is a future migration constraint.
- Strong typing at the edge (codegen) catches shape breaks but can mask semantic breaks that look type-identical.
Output structure
Deliver: the contract (typed schema), an explicit compatibility statement (what's frozen vs evolvable), the full error taxonomy with retriability, and a migration path for the next likely breaking change.
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
- LeonxLJX/web-engineer-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.
Used alongsideProjects 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
In this repository29 other files it gives its agents.
- adversarial-code-reviewSkill
- attack-surface-mappingSkill
- authn-authz-design-reviewSkill
- benchmark-designSkill
- capacity-scalability-planningSkill
- concurrency-race-analysisSkill
- data-consistency-modelingSkill
- data-exfiltration-analysisSkill
- distributed-consensus-designSkill
- error-handling-architectureSkill
- event-driven-architectureSkill
- experiment-designSkill
- hypothesis-falsificationSkill
- incident-rca-postmortemSkill
- legacy-refactoring-strategySkill
- literature-synthesisSkill
- metrics-designSkill
- multi-layer-caching-strategySkill
- mvp-scope-cuttingSkill
- performance-profilingSkill
- rate-limiting-designSkill
- requirements-disambiguationSkill
- secrets-management-auditSkill
- statistical-validity-analysisSkill
- supply-chain-risk-analysisSkill
- system-decomposition-synthesisSkill
- threat-modelingSkill
- tradeoff-decision-frameworkSkill
- user-failure-mode-mappingSkill
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.

