api-contract-first
Use BEFORE fanning out implementation on any feature/service with an HTTP API. Produces a frozen OpenAPI/Swagger contract (+ event schemas), generates the…
by FuzeOne★ 18 GitHub stars
Install api-contract-first in Claude Code & Claude Desktop
Sign up to install this skill
Create a free account to reveal the install command and save the skill to your library.
- Reveal the one-line install command
- Save skills to your synced library
- Get notified when skills update
About this skill
API contract-first
Freeze the contract before implementation fans out. The contract is the single synchronization point; everything else (UI, backend, tests, mock) derives from it, so contract drift becomes a compile error rather than an integration surprise.
When
Any feature/service with a real HTTP API and >1 consumer (UI + backend, or multiple services). Pairs with the contract-first SDLC in CLAUDE.md and feature-tech-planning.
Procedure
Author the OpenAPI 3.1 spec. Put it at
services/<svc>/openapi.yaml(orcontracts/<svc>.yaml). Cover every route the service exposes: paths, methods, params, request/response schemas (reusecomponents/schemas), auth (the JWT bearer scheme), error shapes. If the service already exists, derive the spec from the actual routes and verify it matches by reading the route handlers — the spec must describe reality, not aspiration.Add event schemas for any async surface (FuzeFront: the Kafka Zod schemas in
shared/— reference them; the contract isn't just HTTP).Lint it:
npx @stoplight/spectral-cli lint openapi.yaml(add a sensible ruleset). Fix warnings.Generate the shared typed client/types:
npx openapi-typescript openapi.yaml -o packages/<svc>-client/src/schema.ts, and expose typed request helpers. This IS the@fuzefront/<svc>-clientnpm package — privatepublishConfig(GitHub Packages,@fuzefront,access: restricted) +repository+ wired into the release/publish pipeline. UI, backend, and tests all import these generated types.Stand up a mock server from the contract (Prism:
npx @stoplight/prism-cli mock openapi.yaml, or MSW handlers generated from the schema) so the UI + test streams run before the backend exists.PR the contract on its own branch, containing the contract and NOTHING ELSE, and freeze/merge it FIRST. The only permitted content is the contract artifact set: the spec (
openapi.yaml/AsyncAPI) + event (Zod) schemas · the generated typed client (emitted byopenapi-typescript, never hand-written behind it) · the approved UI frames (design/frames/<feature>/**) + mock-server config · the contract's own version bump/changelog.Anything else makes it not a contract PR — no route handlers, business logic, migrations, feature UI, behaviour tests, Helm/Argo/CI, or unrelated drive-bys. A contract PR is a gate; a gate that also carries implementation cannot be reviewed as a gate — the interface gets waved through while implementation rides along unexamined, and every downstream stream then builds on something nobody actually agreed to. If you are adding a non-contract file, it belongs in the implementation PR that comes after the freeze.
Only once it is merged do the implementer streams start — all of them, gated only on the contract:
backend-engineer,database-engineer,frontend-engineer(against the mock),test-engineer,frontend-test-engineer,devops-engineer,mcp-engineer,cli-engineer,mobile-app-engineer,desktop-app-engineer,docs-maintainer. The MCP surface, CLI, mobile/desktop shells and consumer docs are projections of the same contract — building them from anything else is precisely how they drift from the API they claim to expose.Changing the contract later = amend the contract PR (deliberate ripple to all consumers), never diverge silently in an implementation.
Done checklist
-
openapi.yamldescribes every real route (verified against handlers) + error shapes + auth - event schemas referenced
- Spectral lint clean
-
@fuzefront/<svc>-clientgenerated from the spec, private publishConfig + repository, in the publish pipeline - mock server command documented
- contract is its own PR, containing ONLY the contract artifact set —
git diff --name-only origin/<default>...HEADshows no implementation/infra file - frozen (merged) before ANY implementer stream starts — incl. mcp / cli / mobile / desktop / docs, not just backend+UI
Allowed tools
Tools this skill is permitted to call.
No restriction — this skill can use any tool.
FAQ
What does the api-contract-first skill do?
Use BEFORE fanning out implementation on any feature/service with an HTTP API. Produces a frozen OpenAPI/Swagger contract (+ event schemas), generates the shared typed client, and sets up a mock server — so UI, backend, and tests can be built in parallel against one source of truth.
How do I install the api-contract-first skill?
Copy the skill folder into ~/.claude/skills (the Claude Code tab above does this in one command), or install it as a plugin.
Does the api-contract-first skill run scripts?
No, this skill is instructions only (SKILL.md) with no executable scripts.
Related skills
mcp-builder
AnthropicGuide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
claude-api
AnthropicReference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
algorithmic-art
AnthropicCreating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
mcp-integration
AnthropicThis skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…