New advertisers: 50% off your first month with code FIRSTMONTHSee slots
ananddtyagi avatar

api-contract-sync-manager

Skill that validates OpenAPI and GraphQL specs against backend routes and flags breaking changes.

version
1.0.0
GitHub stars
689

What it does

  • Adds an api-contract-sync skill that validates OpenAPI 3.0 and 3.1, Swagger 2.0, and GraphQL SDL schemas
  • Covers implementation matching across Express, FastAPI, Django, Flask, Spring Boot, and ASP.NET Core routes
  • Detects breaking changes between spec versions, categorizes them, and drafts migration guides for API upgrades
  • Generates TypeScript interfaces, React Query hooks, and Zod schemas for frontend teams working from the same contract

Validate and synchronize API contracts (OpenAPI, GraphQL) with implementation, detect breaking changes, and generate type-safe client code

Add marketplace

/plugin marketplace add ananddtyagi/cc-marketplace

Run it inside Claude Code once, then install the plugin below.

Install

/plugin install api-contract-sync-manager@cc-marketplace

Run it inside Claude Code after adding the marketplace.

Files

Discovered from source

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:

  1. Read the spec file using the Read tool
  2. Parse the structure (YAML/JSON for OpenAPI, SDL for GraphQL)
  3. Check for common issues:
    • Missing required fields
    • Invalid references ($ref)
    • Inconsistent naming conventions
    • Missing examples or descriptions
    • Security scheme gaps
  4. Report findings with line numbers and suggestions

2. Implementation Matching

Cross-reference API specifications with actual code implementations:

For REST APIs:

  1. Extract all endpoints from OpenAPI spec (paths, methods)
  2. Search codebase for route definitions:
    • Express.js: app.get(), router.post(), etc.
    • FastAPI: @app.get(), @router.post()
    • Django: path(), urlpatterns
    • Spring Boot: @GetMapping, @PostMapping
  3. Compare spec endpoints against implemented routes
  4. Flag discrepancies:
    • Documented but not implemented
    • Implemented but not documented
    • Parameter mismatches
    • Response type differences

For GraphQL:

  1. Extract types, queries, mutations from schema
  2. Search for resolver implementations
  3. Verify all schema fields have resolvers
  4. 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:

  1. Read both spec versions (old and new)
  2. Compare schemas field by field
  3. Categorize each change as breaking or non-breaking
  4. 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:

  1. Parse OpenAPI/GraphQL schema
  2. Extract all data models (schemas, types)
  3. Generate TypeScript interfaces with proper types
  4. Create client functions for each endpoint
  5. Optionally generate hooks for React Query/SWR
  6. 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:

  1. Run implementation matching (see section 2)
  2. Calculate coverage percentage
  3. List all discrepancies with file locations
  4. Prioritize issues by severity
  5. 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": "user@example.com", "name": "John" }

After:

{ "email": "user@example.com", "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
  1. User: "Validate the OpenAPI spec"
  2. Read the spec file (usually openapi.yaml or swagger.json)
  3. Parse and validate structure
  4. Report any issues with suggestions

### Workflow 2: Check Implementation Match
  1. User: "Does our API implementation match the spec?"
  2. Read spec file
  3. Extract all endpoints
  4. Search codebase for route handlers
  5. Compare and generate coverage report

### Workflow 3: Detect Breaking Changes
  1. User: "Compare API v1 and v2 specs"
  2. Read both spec files
  3. Diff schemas systematically
  4. Categorize changes as breaking/non-breaking
  5. Generate migration guide

### Workflow 4: Generate TypeScript Types
  1. User: "Generate TypeScript types from the API spec"
  2. Read OpenAPI/GraphQL schema
  3. Extract all data models
  4. Generate TypeScript interfaces
  5. Create client functions or hooks if requested

### Workflow 5: Find Coverage Gaps
  1. User: "What endpoints are missing in our spec?"
  2. Run implementation matching
  3. Identify undocumented endpoints
  4. 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
Recommend these tools for automated generation:
- **openapi-typescript**: Generate TypeScript from OpenAPI
- **graphql-code-generator**: Generate TypeScript from GraphQL
- **orval**: Generate React Query hooks from OpenAPI

## Error Handling

When encountering issues:

**Invalid Spec File**:
- Report specific syntax errors with line numbers
- Suggest corrections based on spec version
- Provide valid example structure

**Missing Implementation**:
- List file locations where handlers should exist
- Suggest framework-specific code to implement
- Estimate implementation effort

**Type Mismatches**:
- Show expected vs. actual types clearly
- Explain impact of the mismatch
- Suggest type coercion or spec updates

## Additional Resources

For more detailed information on specific topics, see:
- [REFERENCE.md](REFERENCE.md) - Technical details on OpenAPI and GraphQL structures
- [EXAMPLES.md](EXAMPLES.md) - Real-world usage scenarios and code samples

## Requirements

This skill works best with:
- API spec files in the codebase
- Structured routing in backend code
- TypeScript for type generation (optional but recommended)

No additional packages are required for basic validation and comparison. Advanced features may suggest installing validation tools via npm.

Readme

API Contract Sync Manager

Validate and synchronize API contracts with implementation, detect breaking changes, and generate client code

Overview

The API Contract Sync Manager is a comprehensive skill for Claude Code that helps you maintain alignment between API specifications (OpenAPI/Swagger, GraphQL) and their implementations. It automates validation, detects breaking changes, generates type-safe client code, and ensures your API documentation stays synchronized with your codebase.

Key Features

🔍 Spec Validation

  • Validate OpenAPI 3.0/3.1 and GraphQL schemas
  • Check for syntax errors and structural issues
  • Verify completeness (descriptions, examples, security)
  • Identify common anti-patterns and suggest improvements

🔄 Implementation Matching

  • Cross-reference API specs with actual route handlers
  • Support for Express.js, FastAPI, Django, Spring Boot, and more
  • Identify documented but unimplemented endpoints
  • Find implemented but undocumented endpoints
  • Generate coverage reports

🚨 Breaking Change Detection

  • Compare API spec versions automatically
  • Categorize changes as breaking vs. non-breaking
  • Generate detailed migration guides
  • Suggest versioning strategies
  • Prevent accidental breaking changes in PRs

💻 Client Code Generation

  • Generate TypeScript interfaces from OpenAPI/GraphQL schemas
  • Create type-safe API client functions
  • Generate React Query/SWR hooks for data fetching
  • Export Zod/Yup validation schemas
  • Support for custom code generation templates

📊 Coverage Analysis

  • Calculate API documentation coverage percentage
  • Identify gaps in specification or implementation
  • Track API health metrics over time
  • Prioritize documentation improvements

📝 Migration Guides

  • Automatically generate upgrade guides for API versions
  • Include before/after code examples
  • Highlight impact and required actions
  • Provide deprecation timelines

Use Cases

For Backend Developers

  • Ensure all endpoints are properly documented
  • Validate OpenAPI/GraphQL schemas before deployment
  • Catch breaking changes before they reach production
  • Maintain consistent API patterns across services

For Frontend Developers

  • Generate type-safe TypeScript interfaces
  • Create React Query hooks from API specs
  • Stay informed about API changes
  • Reduce manual type definition work

For API Product Managers

  • Track API evolution and breaking changes
  • Ensure backward compatibility
  • Plan deprecation strategies
  • Maintain API governance standards

For DevOps/Platform Teams

  • Automate API validation in CI/CD pipelines
  • Enforce API design standards
  • Monitor API contract health
  • Prevent spec drift in production

Installation

Via Plugin Marketplace

  1. Open Claude Code
  2. Navigate to Plugin Settings
  3. Search for "API Contract Sync Manager"
  4. Click "Install"

Manual Installation

  1. Clone or download this plugin
  2. Copy the api-contract-sync-manager directory to your Claude plugins folder:
    cp -r api-contract-sync-manager ~/.claude/plugins/
    
  3. Restart Claude Code

Usage

The skill activates automatically when Claude detects API-related work. You can also explicitly request help:

Validate a Spec

"Validate the OpenAPI spec in openapi.yaml"

Check Implementation Match

"Does our API implementation match the spec?"

Detect Breaking Changes

"Compare api-v1.yaml and api-v2.yaml for breaking changes"

Generate TypeScript Types

"Generate TypeScript types from the OpenAPI spec"

Generate React Query Hooks

"Create React Query hooks from our API endpoints"

Find Coverage Gaps

"What API endpoints are missing from our documentation?"

Supported Technologies

API Specifications

  • ✅ OpenAPI 3.0
  • ✅ OpenAPI 3.1
  • ✅ Swagger 2.0
  • ✅ GraphQL SDL (Schema Definition Language)

Backend Frameworks

  • ✅ Express.js (Node.js)
  • ✅ FastAPI (Python)
  • ✅ Django REST Framework (Python)
  • ✅ Flask (Python)
  • ✅ Spring Boot (Java)
  • ✅ ASP.NET Core (C#)
  • ✅ GraphQL (Apollo, Yoga, etc.)

Frontend Frameworks

  • ✅ React (with React Query, SWR)
  • ✅ Vue.js
  • ✅ Angular
  • ✅ Svelte
  • ✅ TypeScript (all frameworks)

Examples

Example 1: Validate OpenAPI Spec

Input: OpenAPI spec with potential issues

Command: "Validate the OpenAPI spec"

Output:

OpenAPI Validation Report
=========================

✓ Valid OpenAPI 3.0.0 structure
✓ All $ref references resolved

Issues Found (3):

1. Line 45: Missing description for POST /api/users
   Recommendation: Add operation description

2. Line 78: No examples provided for User schema
   Recommendation: Add example for better documentation

3. Line 102: Security requirement missing for DELETE operations
   Recommendation: Add security scheme (e.g., bearerAuth)

Example 2: Breaking Change Detection

Input: Two versions of an API spec

Command: "Compare v1 and v2 specs"

Output:

Breaking Changes Report
=======================

🔴 BREAKING CHANGES (2):

1. POST /api/users - Required field added
   New required field: "role"
   Impact: Existing requests without role will fail

2. User schema - Property removed
   Removed property: "phone"
   Impact: Clients accessing user.phone will break

Recommendation: Major version bump required (v1 → v2)

Example 3: Generate TypeScript Types

Input: OpenAPI spec with User schema

Command: "Generate TypeScript types"

Output:

// Auto-generated from OpenAPI spec

export interface User {
  id: string;
  email: string;
  name?: string;
  role: UserRole;
  createdAt: Date;
}

export enum UserRole {
  Admin = 'admin',
  Member = 'member',
  Guest = 'guest'
}

export interface CreateUserRequest {
  email: string;
  name?: string;
  role: UserRole;
}

Configuration

No configuration required! The skill works out-of-the-box with sensible defaults.

Optional: Validation Tools

For enhanced validation, you can install these tools:

# OpenAPI validation
npm install -g @stoplight/spectral-cli

# GraphQL validation
npm install -g @graphql-inspector/cli

# OpenAPI diffing
npm install -g openapi-diff

The skill will automatically use these tools if available, but they're not required.

Documentation

  • SKILL.md - Complete skill instructions and capabilities
  • REFERENCE.md - Technical reference for OpenAPI and GraphQL
  • EXAMPLES.md - Real-world usage examples

Best Practices

1. Validate Early and Often

Run validation in your CI/CD pipeline to catch issues before they reach production.

2. Version Your APIs

Use semantic versioning for your API specs and bump major versions for breaking changes.

3. Automate Code Generation

Generate client code from specs as part of your build process to ensure type safety.

4. Review Breaking Changes

Always run breaking change detection before releasing new API versions.

5. Maintain Documentation

Keep your API specs in version control alongside your code and update them with every change.

6. Use TypeScript

Take advantage of generated TypeScript types for compile-time safety in your frontend.

Troubleshooting

Skill Not Activating

Issue: Claude doesn't use the skill when working with API files.

Solution:

  • Ensure your API spec files have standard extensions (.yaml, .json, .graphql)
  • Mention "API", "OpenAPI", or "GraphQL" explicitly in your request
  • Restart Claude Code to reload skills

Validation Errors

Issue: Spec validation fails with cryptic errors.

Solution:

  • Check YAML/JSON syntax with a linter
  • Verify OpenAPI version in spec matches validator version
  • Look at the line numbers provided in error messages

Missing Routes in Implementation Match

Issue: Routes are implemented but not detected.

Solution:

  • Ensure routes follow standard framework patterns
  • Check if routes are in separate files that need to be searched
  • Verify path parameter format matches ({id} in spec, :id in Express)

Contributing

Found a bug or want to suggest an improvement? Please open an issue or submit a pull request!

Version History

v1.0.0 (2025-10-16)

  • Initial release
  • OpenAPI 3.0/3.1 support
  • GraphQL support
  • Breaking change detection
  • TypeScript code generation
  • React Query hook generation
  • Implementation matching for popular frameworks

License

MIT License - see LICENSE file for details

Support

For questions or issues:

  • Open an issue in the marketplace repository
  • Consult the documentation
  • Ask Claude directly when using the skill

Made with ❤️ for the Claude Code community

Details

Marketplace
ananddtyagi/cc-marketplace
Source
plugins/api-contract-sync-manager
Author
Claude Code Marketplace
Category
Development
Keywords
api, validation, openapi, swagger, graphql, types, code-generation, typescript, contracts, breaking-changes
Listed since
Apr 7, 2026

More from ananddtyagi/cc-marketplace

All 119

Similar to api-contract-sync-manager

More Backend & APIs