api-contract-sync-manager
Ensures API documentation remains synchronized with code by validating schemas and detecting breaking contract changes.
Install
mkdir -p .claude/skills/api-contract-sync-manager && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/3876" && unzip -o skill.zip -d .claude/skills/api-contract-sync-manager && rm skill.zipInstalls to .claude/skills/api-contract-sync-manager
Activation
This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.
Validate OpenAPI, Swagger, and GraphQL schemas match backend implementation. Detect breaking changes, generate TypeScript clients, and ensure API documentation stays synchronized. Use when working with API spec files (.yaml, .json, .graphql), reviewing API changes, generating frontend types, or validating endpoint implementations.Key capabilities
- →Validate OpenAPI and GraphQL specification files
- →Compare API specifications with code implementations
- →Detect breaking and non-breaking changes between API spec versions
- →Generate TypeScript interfaces and client functions from API schemas
- →Identify undocumented API endpoints in the codebase
- →Generate coverage reports for API implementation
How it works
The skill reads API specification files, parses their structure, and performs validation, comparison with code, and client code generation based on the defined schemas.
Inputs & outputs
When to use api-contract-sync-manager
- →Validate OpenAPI spec files
- →Detect API breaking changes
- →Generate TypeScript client types
- →Sync GraphQL schemas with resolvers
About this skill
API Contract Sync Manager
Maintain synchronization between API specifications and their implementations, detect breaking changes, and generate client code to ensure contracts stay reliable across frontend and backend teams.
When to Use This Skill
Use this skill when:
- Working with OpenAPI/Swagger specification files (
.yaml,.json) - Managing GraphQL schemas (
.graphql,.gql) - Reviewing API changes in pull requests
- Generating TypeScript types or client code from specs
- Validating that implementations match documented APIs
- Detecting breaking vs. non-breaking API changes
- Creating API versioning strategies
- Onboarding new developers to an API-driven codebase
Core Capabilities
1. Spec Validation
Validate API specification files for correctness and completeness:
OpenAPI/Swagger Validation:
- Check schema syntax and structure
- Validate against OpenAPI 3.0/3.1 standards
- Ensure all endpoints have proper descriptions
- Verify request/response schemas are complete
- Check for required security definitions
- Validate parameter types and constraints
GraphQL Validation:
- Parse and validate SDL (Schema Definition Language)
- Check for schema stitching issues
- Validate resolver coverage
- Detect circular dependencies
- Verify input/output type consistency
Validation Approach:
- Read the spec file using the Read tool
- Parse the structure (YAML/JSON for OpenAPI, SDL for GraphQL)
- Check for common issues:
- Missing required fields
- Invalid references (
$ref) - Inconsistent naming conventions
- Missing examples or descriptions
- Security scheme gaps
- Report findings with line numbers and suggestions
2. Implementation Matching
Cross-reference API specifications with actual code implementations:
For REST APIs:
- Extract all endpoints from OpenAPI spec (paths, methods)
- Search codebase for route definitions:
- Express.js:
app.get(),router.post(), etc. - FastAPI:
@app.get(),@router.post() - Django:
path(),urlpatterns - Spring Boot:
@GetMapping,@PostMapping
- Express.js:
- Compare spec endpoints against implemented routes
- Flag discrepancies:
- Documented but not implemented
- Implemented but not documented
- Parameter mismatches
- Response type differences
For GraphQL:
- Extract types, queries, mutations from schema
- Search for resolver implementations
- Verify all schema fields have resolvers
- Check resolver signatures match schema types
Implementation Matching Steps:
1. Parse spec → extract endpoints/operations
2. Use Grep to find route handlers in codebase
3. Compare and categorize:
- ✓ Matched: spec and implementation align
- ⚠ Drift: partial match with differences
- ✗ Missing: documented but not implemented
- ⚠ Undocumented: implemented but not in spec
4. Generate coverage report
3. Breaking Change Detection
Compare two versions of an API spec to detect breaking vs. non-breaking changes:
Breaking Changes (require version bump):
- Removed endpoints or operations
- Removed required request parameters
- Changed parameter types (e.g., string → number)
- Made optional parameters required
- Removed response properties that clients depend on
- Changed response status codes
- Renamed endpoints, parameters, or fields
- Stricter validation rules (e.g., regex patterns)
Non-Breaking Changes (safe to deploy):
- Added new endpoints
- Added optional parameters
- Made required parameters optional
- Added new response properties
- Expanded enum values
- Improved descriptions/examples
- Added deprecation warnings
Change Detection Process:
- Read both spec versions (old and new)
- Compare schemas field by field
- Categorize each change as breaking or non-breaking
- Generate migration guide with:
- Summary of breaking changes
- Impact on existing clients
- Required client updates
- Recommended versioning strategy
4. Client Code Generation
Generate type-safe client code from API specifications:
TypeScript Interfaces:
// From OpenAPI schema
interface User {
id: string;
email: string;
name?: string;
createdAt: Date;
}
interface CreateUserRequest {
email: string;
name?: string;
}
interface CreateUserResponse {
user: User;
token: string;
}
API Client Functions:
// HTTP client with proper typing
async function createUser(
data: CreateUserRequest
): Promise<CreateUserResponse> {
const response = await fetch('/api/users', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(data)
});
return response.json();
}
React Query Hooks:
// Auto-generated hooks for data fetching
function useUser(userId: string) {
return useQuery(['user', userId], () =>
fetch(`/api/users/${userId}`).then(r => r.json())
);
}
function useCreateUser() {
return useMutation((data: CreateUserRequest) =>
fetch('/api/users', {
method: 'POST',
body: JSON.stringify(data)
}).then(r => r.json())
);
}
Generation Steps:
- Parse OpenAPI/GraphQL schema
- Extract all data models (schemas, types)
- Generate TypeScript interfaces with proper types
- Create client functions for each endpoint
- Optionally generate hooks for React Query/SWR
- Add JSDoc comments from spec descriptions
5. Coverage Analysis
Identify gaps between documentation and implementation:
Analysis Report Structure:
API Coverage Report
==================
Documented Endpoints: 45
Implemented Endpoints: 42
Coverage: 93%
Missing Implementations:
- DELETE /api/users/{id} (documented but not found)
- POST /api/users/{id}/suspend (documented but not found)
Undocumented Endpoints:
- GET /api/internal/health (found in code, not in spec)
- POST /api/debug/reset (found in code, not in spec)
Mismatched Signatures:
- POST /api/users
Spec expects: { email, name, role }
Code accepts: { email, name } (missing 'role')
Coverage Analysis Process:
- Run implementation matching (see section 2)
- Calculate coverage percentage
- List all discrepancies with file locations
- Prioritize issues by severity
- Suggest next steps to achieve 100% coverage
6. Migration Guides
Create upgrade guides when API versions change:
Migration Guide Template:
# API v2.0 Migration Guide
## Breaking Changes
### 1. User Creation Endpoint
**Change**: Required `role` field added to POST /api/users
**Impact**: All user creation calls will fail without this field
**Action Required**:
- Update all POST /api/users calls to include `role`
- Default to 'member' if no specific role needed
Before:
```json
{ "email": "[email protected]", "name": "John" }
After:
{ "email": "[email protected]", "name": "John", "role": "member" }
2. Authentication Token Format
Change: JWT tokens now use RS256 instead of HS256 Impact: Token validation must be updated Action Required:
- Update JWT verification libraries
- Fetch new public key from /.well-known/jwks.json
**Guide Generation Steps**:
1. Detect all breaking changes (see section 3)
2. Group changes by endpoint or feature
3. For each change, document:
- What changed and why
- Impact on existing clients
- Required code updates with before/after examples
- Timeline for deprecation
4. Add general upgrade instructions
## Best Practices
### For OpenAPI Specs
1. **Use $ref liberally**: Define schemas once, reference everywhere
2. **Version your APIs**: Use `/v1/`, `/v2/` prefixes or version headers
3. **Add examples**: Include request/response examples in spec
4. **Document errors**: Define all possible error responses
5. **Security first**: Always specify security requirements
### For GraphQL Schemas
1. **Use descriptions**: Document all types, fields, and arguments
2. **Deprecate, don't remove**: Use `@deprecated` directive
3. **Input validation**: Use custom scalars for validated types
4. **Pagination patterns**: Use connection/edge patterns consistently
5. **Error handling**: Define custom error types
### For Breaking Changes
1. **Version bump**: Major version for breaking changes
2. **Deprecation period**: Maintain old version for transition
3. **Clear communication**: Document changes prominently
4. **Backward compatibility**: Provide adapters when possible
5. **Client coordination**: Ensure clients can update before removal
## Common Workflows
### Workflow 1: Validate Existing Spec
- User: "Validate the OpenAPI spec"
- Read the spec file (usually openapi.yaml or swagger.json)
- Parse and validate structure
- Report any issues with suggestions
### Workflow 2: Check Implementation Match
- User: "Does our API implementation match the spec?"
- Read spec file
- Extract all endpoints
- Search codebase for route handlers
- Compare and generate coverage report
### Workflow 3: Detect Breaking Changes
- User: "Compare API v1 and v2 specs"
- Read both spec files
- Diff schemas systematically
- Categorize changes as breaking/non-breaking
- Generate migration guide
### Workflow 4: Generate TypeScript Types
- User: "Generate TypeScript types from the API spec"
- Read OpenAPI/GraphQL schema
- Extract all data models
- Generate TypeScript interfaces
- Create client functions or hooks if requested
### Workflow 5: Find Coverage Gaps
- User: "What endpoints are missing in our spec?"
- Run implementation matching
- Identify undocumented endpoints
- Suggest adding them to spec with proper schemas
## Tools and Commands
### Validation Tools
When validation tools are available, use them:
- **OpenAPI**: `npx @stoplight/spectral-cli lint openapi.yaml`
- **GraphQL**: `npx graphql-inspector validate schema.graphql`
### Comparison Tools
For advanced diff analysis:
- **OpenAPI**: `npx openapi-diff old.yaml new.yaml`
- **GraphQL**: `npx graphql-inspector diff old.graphql new.graphql`
### Code Generation
Recomm
---
*Content truncated.*
Prerequisites
Limitations
- →Requires API spec files to be present in the codebase
- →Requires structured routing in the backend code for implementation matching
How it compares
This skill automates the validation, synchronization, and client code generation for API contracts, which is more efficient than manual review and type definition.
Compared to similar skills
api-contract-sync-manager side by side with the closest alternatives in the catalog.
| Skill | Installs | Updated | Safety | Difficulty |
|---|---|---|---|---|
| api-contract-sync-manager (this skill) | 1 | 10mo | No flags | Intermediate |
| nodejs-backend-patterns | 12 | 2mo | No flags | Intermediate |
| graphql-schema | 1 | 7mo | Review | Intermediate |
| create-react-component | 0 | 3mo | No flags | Intermediate |
Try saying
Example prompts that trigger this skill in your AI assistant.
More by ananddtyagi
View all by ananddtyagi →You might also like
nodejs-backend-patterns
wshobson
Build production-ready Node.js backend services with Express/Fastify, implementing middleware patterns, error handling, authentication, database integration, and API design best practices. Use when creating Node.js servers, REST APIs, GraphQL backends, or microservices architectures.
graphql-schema
ChrisWiles
GraphQL queries, mutations, and code generation patterns. Use when creating GraphQL operations, working with Apollo Client, or generating types.
create-react-component
OpenCTI-Platform
Use when: creating a new Relay-connected React component, defining a GraphQL fragment, or wiring a component to a query
exa-upgrade-migration
jeremylongshore
Analyze, plan, and execute Exa SDK upgrades with breaking change detection. Use when upgrading Exa SDK versions, detecting deprecations, or migrating to new API versions. Trigger with phrases like "upgrade exa", "exa migration", "exa breaking changes", "update exa SDK", "analyze exa version".
obsidian-upgrade-migration
jeremylongshore
Migrate Obsidian plugins between API versions and handle breaking changes. Use when upgrading to new Obsidian versions, handling API deprecations, or migrating plugin code to new patterns. Trigger with phrases like "obsidian upgrade", "obsidian migration", "obsidian API changes", "update obsidian plugin".
instantly-sdk-patterns
jeremylongshore
Apply production-ready Instantly SDK patterns for TypeScript and Python. Use when implementing Instantly integrations, refactoring SDK usage, or establishing team coding standards for Instantly. Trigger with phrases like "instantly SDK patterns", "instantly best practices", "instantly code patterns", "idiomatic instantly".