Back to skills
SkillHub ClubResearch & OpsFull StackFrontendBackend

api-contract-validator

Validates type contracts between TypeScript interfaces and Pydantic models. Detects field mismatches and type inconsistencies. Related: frontend-backend-mapper for endpoint discovery.

Packaged view

This page reorganizes the original catalog entry around fit, installability, and workflow context first. The original raw source lives below.

Stars
1
Hot score
77
Updated
March 20, 2026
Overall rating
C2.6
Composite score
2.6
Best-practice grade
B84.0

Install command

npx @skill-hub/cli install okgoogle13-careercopilot-api-contract-validator

Repository

okgoogle13/careercopilot

Skill path: .claude/skills/api-contract-validator

Validates type contracts between TypeScript interfaces and Pydantic models. Detects field mismatches and type inconsistencies. Related: frontend-backend-mapper for endpoint discovery.

Open repository

Best for

Primary workflow: Research & Ops.

Technical facets: Full Stack, Frontend, Backend.

Target audience: everyone.

License: Unknown.

Original source

Catalog source: SkillHub Club.

Repository owner: okgoogle13.

This is still a mirrored public skill entry. Review the repository before installing into production workflows.

What it helps with

  • Install api-contract-validator into Claude Code, Codex CLI, Gemini CLI, or OpenCode workflows
  • Review https://github.com/okgoogle13/careercopilot before adding api-contract-validator to shared team environments
  • Use api-contract-validator for development workflows

Works across

Claude CodeCodex CLIGemini CLIOpenCode

Favorites: 0.

Sub-skills: 0.

Aggregator: No.

Original source / Raw SKILL.md

---
name: api-contract-validator
description: "Validates type contracts between TypeScript interfaces and Pydantic models. Detects field mismatches and type inconsistencies. Related: frontend-backend-mapper for endpoint discovery."
---

# API Contract Validator Workflow

This skill ensures type safety and consistency between frontend TypeScript interfaces and backend Pydantic models.

## Workflow Steps

1. **Scan TypeScript interfaces:**
   - Read frontend API service files (`frontend/src/api/*.ts`)
   - Extract TypeScript interfaces for requests/responses
   - Parse field types, optional fields, arrays, enums
   - Build TypeScript type inventory

2. **Scan Pydantic models:**
   - Read backend model files (`backend/app/models/*_schemas.py`)
   - Extract Pydantic BaseModel definitions
   - Parse field types, Optional types, Lists, Enums
   - Build Python type inventory

3. **Match and compare contracts:**
   - Match TypeScript interfaces to Pydantic models by name
   - Compare field names (check for camelCase vs snake_case)
   - Compare field types (string vs str, number vs int/float)
   - Check required vs optional field consistency
   - Validate enum values match

4. **Detect mismatches:**
   - **Field name differences**: `userId` vs `user_id`
   - **Type mismatches**: `string` vs `int`
   - **Missing fields**: Field in frontend but not backend (or vice versa)
   - **Optional inconsistencies**: Required in one but optional in another
   - **Enum value differences**: Different allowed values

5. **Generate validation report:**
   - Create `docs/API_CONTRACT_VALIDATION.md` with:
     - Contract health score
     - List of all validated contracts
     - Detailed mismatch reports
     - Recommended fixes (with code examples)
     - Breaking vs non-breaking changes

6. **Provide fix suggestions:**
   - Show exact code changes needed
   - Generate conversion utilities if needed
   - Suggest API versioning for breaking changes

## Validation Report Structure

````markdown
# API Contract Validation Report

Generated: 2025-01-06T12:00:00Z

## Summary

- Total Contracts Validated: 28
- βœ… Matching Contracts: 22 (78.6%)
- ⚠️ Mismatches Found: 6 (21.4%)
- πŸ”΄ Breaking Issues: 2
- 🟑 Non-Breaking Issues: 4

## Contract Health Score: 79/100

### βœ… VALID CONTRACTS (22)

| Contract Name     | Frontend          | Backend             | Status           |
| ----------------- | ----------------- | ------------------- | ---------------- |
| `ATSScoreRequest` | aiServices.ts     | analysis_schemas.py | βœ… Perfect match |
| `UserProfile`     | profileService.ts | schemas.py          | βœ… Perfect match |
| ...               |

### πŸ”΄ BREAKING MISMATCHES (2)

#### 1. NotificationPreferences

**Location:** `notificationService.ts` ↔ `notification_schemas.py`

**Issues:**

- Field type mismatch: `frequency` is `string` in TS but `int` in Python
- Missing required field: `user_id` required in backend but not sent from frontend

**Impact:** πŸ”΄ API calls will fail with 422 validation errors

**Fix (Frontend):**

```typescript
// notificationService.ts
interface NotificationPreferences {
  frequency: number; // Change from string to number
  user_id: string; // Add missing field
  // ... other fields
}
```
````

**Fix (Backend - Alternative):**

```python
# notification_schemas.py
class NotificationPreferencesRequest(BaseModel):
    frequency: str  # Change from int to str
    # Remove user_id from request, get from auth instead
```

### 🟑 NON-BREAKING WARNINGS (4)

#### 1. Casing Inconsistency

**Issue:** Frontend uses camelCase, backend uses snake_case
**Affected:** 15 contracts
**Impact:** 🟑 Works but inconsistent (Pydantic auto-converts)
**Recommendation:** Standardize on one casing style

**Example:**

```typescript
// Frontend (camelCase)
interface JobListing {
  jobTitle: string;
  companyName: string;
}

// Backend (snake_case)
class JobListingResponse(BaseModel):
    job_title: str
    company_name: str
```

**Recommendation:** Add Pydantic alias config:

```python
class JobListingResponse(BaseModel):
    job_title: str = Field(alias="jobTitle")
    company_name: str = Field(alias="companyName")

    class Config:
        populate_by_name = True
```

## Type Mapping Reference

| TypeScript  | Python (Pydantic) | Compatible             |
| ----------- | ----------------- | ---------------------- |
| `string`    | `str`             | βœ…                     |
| `number`    | `int`, `float`    | βœ…                     |
| `boolean`   | `bool`            | βœ…                     |
| `string[]`  | `List[str]`       | βœ…                     |
| `Date`      | `datetime`        | ⚠️ Needs serialization |
| `any`       | `Any`             | ⚠️ Avoid if possible   |
| `T \| null` | `Optional[T]`     | βœ…                     |

```

## Usage Tips

- Run validator before major releases
- Integrate into CI/CD pipeline
- Fix breaking issues immediately
- Schedule non-breaking fixes for next sprint
- Use validator output for API documentation
```
api-contract-validator | SkillHub