api-contract-validation
API contract validation patterns for ensuring client-side models match backend JSON responses. Prevents decoding failures from schema mismatches. Tech-stack…
by CarlosDanielDev★ 31 GitHub stars
Install api-contract-validation 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 Validation Skill
Purpose
Prevent bugs where client-side models don't match backend API responses — causing silent decoding failures at runtime.
Contract Schema Location
All API contracts live in docs/api-contracts/ as JSON files.
Naming Convention
docs/api-contracts/{feature-area}-{endpoint-name}.json
Contract Schema Format
{
"$schema": "api-contract-v1",
"endpoint": "GET /api/items/list",
"description": "Fetch items for display",
"issue": "#38",
"lastVerified": "2026-03-10",
"request": {
"query": {
"count": { "type": "integer", "required": false, "default": 10 }
}
},
"response": {
"items": {
"type": "array",
"items": {
"id": { "type": "string", "required": true },
"name": { "type": "string", "required": true },
"score": { "type": "integer", "required": false }
}
},
"total": { "type": "integer", "required": true }
}
}
DOR (Definition of Ready)
An issue is NOT ready for implementation unless:
- API contract schema exists in
docs/api-contracts/ - All response fields documented with types and required/optional
- Schema verified against actual backend response
DOD (Definition of Done)
Implementation is NOT done unless:
- Client models match contract schema field-by-field
- Required fields are non-optional in client code
- Optional fields are properly nullable
- A decode test exists using example JSON from the contract
- No extra fields in client model that don't exist in contract
Common Mismatch Patterns
- Ghost fields: Client model has a field that doesn't exist in backend response
- Required mismatch: Backend returns field optionally, client declares it as required
- Type mismatch: Backend returns
number(float) but client declares integer - Naming mismatch: Backend uses
snake_case, client usescamelCasewithout mapping - Nested structure mismatch: Backend nests data differently than client expects
Validation Process
- Read contract schema from
docs/api-contracts/ - Read the corresponding client model file
- For each field in schema: verify exists, type matches, optionality matches
- For each field in client model: verify exists in schema (catch ghost fields)
- Report mismatches
Integration with Orchestrator Workflow
subagent-architect → Architecture Blueprint
│
▼
CONTRACT VALIDATION ← This skill
│
▼
subagent-qa → Test Blueprint (includes decode tests)
Allowed tools
Tools this skill is permitted to call.
- 01
Read - 02
Grep - 03
Glob - 04
WebSearch
FAQ
What does the api-contract-validation skill do?
API contract validation patterns for ensuring client-side models match backend JSON responses. Prevents decoding failures from schema mismatches. Tech-stack agnostic.
How do I install the api-contract-validation 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-validation 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…