contract-first-designer
Contract-First Designer Protocol
This skill enforces API design before implementation. It breaks the habit of writing controller code and auto-generating the spec from it. By designing the OpenAPI/AsyncAPI contract first, backend and frontend teams can work in parallel.
Core assumption: Code is cheap, contracts are expensive to change. A well-designed API contract prevents endless integration meetings.
1. Specification Generation (Static)
Analyze the business requirements to output a standard API documentation format.
REST APIs (OpenAPI 3.x)
- Define all endpoints, methods (
GET,POST, etc.). - Explicitly define standard HTTP status codes (
200 OK,201 Created,400 Bad Request,401 Unauthorized,404 Not Found,500 Internal Server Error). - Define strict Request/Response JSON schemas using
$refcomponents. - Include pagination parameters (
limit,cursor/offset) for all collection endpoints.
Event-Driven / WebSockets (AsyncAPI)
- Define Channels and Messages.
- Specify headers, payload shape, and correlation IDs.
2. Contract Testing (Pact / Schema Validation)
Instead of relying only on E2E tests, generate the scenarios required to prove the provider (backend) and consumer (frontend) honor the contract.
- Describe the expected state.
- Define what the mock provider should return.
3. Output Generation
Required Outputs (Must write BOTH to docs/api-report/):
- Human-Readable Markdown (
docs/api-report/contract-designer-report.md)
### ๐ Contract-First Design
- **Protocol:** HTTP REST
- **Specification:** OpenAPI 3.1
- **Focus Area:** User Orders
#### ๐ OpenAPI Specification (Snippet)
```yaml
openapi: 3.1.0
info:
title: Order API
version: 1.0.0
paths:
/orders:
post:
summary: Create a new order
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/OrderCreatePayload'
responses:
'201':
description: Order created
# ...
๐ก๏ธ Contract Testing Scenarios (Pact)
- State: "User is authenticated and has $50 balance"
- Request:
POST /orderswith valid payload. - Expected Response:
201 Createdwithorder_idstring.
2. **Machine-Readable JSON (`docs/api-report/contract-designer-output.json`)**
```json
{
"skill": "contract-first-designer",
"protocol": "REST",
"endpoints": [
{"method": "POST", "path": "/orders", "request_schema": "OrderCreatePayload", "responses": [201, 400, 401]}
],
"pact_states": ["User is authenticated and has $50 balance"]
}
Guardrails
- No Ambiguous Types: Avoid
AnyorObjecttypes in definitions. Require strict typing (e.g.,stringwithformat: uuid). - Standardized Errors: Use RFC 7807 Problem Details for HTTP APIs instead of custom random error schemas.
- Security Definitions: Ensure Authorization headers/schemes (
Bearer,ApiKey) are explicitly defined in the spec components.
๐ Next Steps & Handoffs
If you are executing the OpenAPI-First Design Flow as defined in the API ECOSYSTEM guide, and the contract has been successfully generated, the next mandatory skill in the sequence is:
@api-mock-designer(to generate mock servers and fake data responses based on this contract)
More from fatih-developer/fth-skills
task-decomposer
Break down large, complex, or ambiguous tasks into independent subtasks with dependency maps, execution order, and success criteria. Plan first, then execute step by step. Triggers on 'how should I do this', 'where do I start', 'plan the project', 'break it down', 'implement' or whenever a task involves multiple phases.
24context-compressor
Compress long conversation histories, large code files, research results, and documents by 70% without losing critical information. Triggers when context window fills up, when summarizing previous steps in multi-step tasks, before loading large files into context, or on 'summarize', 'compress', 'reduce context', 'save tokens'.
17multi-brain-debate
Two-round debate protocol where perspectives challenge each other before consensus. Round 1 presents independent positions, Round 2 allows counter-arguments and rebuttals. Produces battle-tested decisions for high-stakes choices.
17multi-brain-score
Confidence scoring overlay for multi-brain decisions. Each perspective rates its own confidence (1-10) with justification. Consensus uses scores as weights, flags low-confidence areas, and surfaces uncertainty explicitly.
15checkpoint-guardian
Automatic risk assessment before every critical action in agentic workflows. Detects irreversible operations (file deletion, database writes, deployments, payments), classifies risk level, and requires confirmation before proceeding. Triggers on destructive keywords like deploy, delete, send, publish, update database, process payment.
14parallel-planner
Analyze multi-step tasks to identify which steps can run in parallel, build dependency graphs, detect conflicts (write-write, read-write, resource contention), and produce optimized execution plans. Triggers on 3+ independent steps, 'speed up', 'run simultaneously', 'parallelize', 'optimize' or any task where sequential execution wastes time.
14