api-contract-first
Skill24 starsChanged 24 days agoMITView on GitHub
Hard gate before implementing any API endpoint or service interface. Requires a written, reviewed contract (OpenAPI 3.x, protobuf, or GraphQL schema) before any implementation code is written. Prevents breaking changes, misaligned clients, and undocumented behaviour.
3 other projects use a version of this.
Adopted by
Most recently taken up by
- robisson/build-like-amazon-agent-skillstheir own version, first seen Oct 5, 2026
- novatic-cu/nova-skillstheir own version, first seen Sep 20, 2026
- dhslegen/digital-delivery-teamtheir own version, first seen Apr 27, 2026
Other versions3 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 3
- robisson/build-like-amazon-agent-skills★ 16same name
- dhslegen/digital-delivery-team★ 1same name
- novatic-cu/nova-skills★ 1same 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 repository22 other files it gives its agents.
- AGENTS.mdAGENTS.md
- .claude/rules/agents.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- architecture-auditSkill
- brainstormingSkill
- data-migrationSkill
- dispatching-parallel-agentsSkill
- executing-plansSkill
- finishing-a-development-branchSkill
- five-whysSkill
- incident-responseSkill
- performance-auditSkill
- skill-duplication-auditSkill
- smart-initSkill
- subagent-driven-developmentSkill
- systematic-debuggingSkill
- test-driven-developmentSkill
- using-a-teamSkill
- using-git-worktreesSkill
- verification-before-completionSkill
- writing-plansSkill
- writing-skillsSkill
The file
We split this skill into the rules it gives an agent
7 rules. About 0 are common, 7 are distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈7
Distinctive · estimate
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 18
Use this skill before writing ANY of these:
- Distinctive: line 87
Before implementation begins, verify the contract satisfies all of these:
- Distinctive: line 123
If the implementation reveals that the contract needs to change:
- Distinctive: line 124
Update the contract first
- Distinctive: line 128
Never silently diverge from the contract.
- Distinctive: line 132
Write at least one contract test per endpoint that validates the actual response against the OpenAPI schema:
- Distinctive: line 154
All of these precede the same outcome: a client built on undocumented assumptions, followed by a breaking change that neither team sees …
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
API Contract First
The Law
NO API IMPLEMENTATION WITHOUT A REVIEWED CONTRACT.
Writing endpoints before the contract is building to a spec that doesn't exist.
The contract IS the spec. Code that matches it is correct. Code that doesn't is wrong.When to Use
Use this skill before writing ANY of these:
- A new REST endpoint
- A new gRPC/protobuf service method
- A new GraphQL query, mutation, or subscription
- A new event schema (Kafka, SQS, webhooks)
- A new inter-service interface
The Contract Process
Step 1: Write the Contract
Choose the format that matches the project's stack:
REST → OpenAPI 3.x
# docs/api/openapi.yaml
paths:
/orders:
post:
summary: Create a new order
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/CreateOrderRequest'
responses:
'201':
description: Order created
content:
application/json:
schema:
$ref: '#/components/schemas/Order'
'400':
$ref: '#/components/responses/ValidationError'
'401':
$ref: '#/components/responses/Unauthorized'
components:
schemas:
CreateOrderRequest:
type: object
required: [userId, items]
properties:
userId:
type: string
format: uuid
items:
type: array
minItems: 1
items:
$ref: '#/components/schemas/OrderItem'Events / Async → AsyncAPI or JSON Schema
# docs/events/order-created.yaml
name: order.created
version: 1.0.0
payload:
type: object
required: [orderId, userId, createdAt]
properties:
orderId: { type: string, format: uuid }
userId: { type: string, format: uuid }
createdAt: { type: string, format: date-time }Step 2: Contract Review Checklist
Before implementation begins, verify the contract satisfies all of these:
Naming & Consistency
- Resource names are nouns, plural (
/ordersnot/createOrder) - Consistent casing throughout (snake_case for JSON fields, kebab-case for URL segments)
- New names consistent with existing API vocabulary (don't introduce synonyms for existing concepts)
Completeness
- All error responses documented (at minimum: 400, 401, 403, 404, 422, 500)
- All required vs optional fields explicitly marked
- Field types, formats, and constraints defined (min/max, pattern, enum values)
- Pagination documented if the endpoint returns a collection
Versioning
- Breaking changes introduce a new version (
/v2/) — never modify/v1/in a breaking way - A change is breaking if it: removes a field, changes a field type, makes an optional field required, changes status code semantics
Security
- Authentication requirement stated (which scheme: Bearer, API Key, session)
- Authorisation scope documented (who can call this: any user, admin only, service-to-service)
- Rate limits noted if applicable
Consumer Perspective
- The contract was designed for how clients need to use it — not how it's easiest to implement
- A new team member could implement a client from this contract alone
Step 3: Get Contract Approved
Save the contract file to docs/api/ or docs/events/. The contract is reviewed before implementation begins — not after.
Approval gate: the planner agent must reference the approved contract file in the implementation plan. If no contract file is referenced, the plan is not complete.
Step 4: Implement Against the Contract
Implementation is correct when it matches the contract exactly. The contract is the source of truth — not the implementation.
If the implementation reveals that the contract needs to change:
- Update the contract first
- Re-review the changed section
- Then update the implementation
Never silently diverge from the contract. Every divergence is a breaking change waiting to happen.
Step 5: Contract Tests
Write at least one contract test per endpoint that validates the actual response against the OpenAPI schema:
// [VALID] — tests the real implementation against the contract
import { validate } from 'openapi-validator'
import { spec } from '../docs/api/openapi.yaml'
test('POST /orders response matches contract', async () => {
const response = await request(app).post('/orders').send(validPayload)
const errors = validate(spec, '/orders', 'post', response)
expect(errors).toHaveLength(0)
})Rationalization Red Flags
These mean you are about to skip the contract step:
- "The endpoint is simple, I'll document it after"
- "The client team knows what they're getting"
- "We'll sort out the contract in the PR description"
- "It's an internal API, nobody will break"
All of these precede the same outcome: a client built on undocumented assumptions, followed by a breaking change that neither team sees coming.
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.

