home / skills / greyhaven-ai / claude-code-config / data-validation

This skill enforces robust API and database validation using Pydantic v2 models for schema alignment and data quality.

npx playbooks add skill greyhaven-ai/claude-code-config --skill data-validation

Review the files below or copy the command above to add this skill to your agents.

Files (8)
SKILL.md
1.2 KB
---
name: grey-haven-data-validation
description: "Comprehensive data validation using Pydantic v2 with data quality monitoring and schema alignment for PlanetScale PostgreSQL. Use when implementing API validation, database schema alignment, or data quality assurance. Triggers: 'validation', 'Pydantic', 'schema', 'data quality'."
# v2.0.43: Skills to auto-load for data validation work
skills:
  - grey-haven-code-style
  - grey-haven-api-design-standards
  - grey-haven-database-conventions
# v2.0.74: Tools for data validation work
allowed-tools:
  - Read
  - Write
  - MultiEdit
  - Bash
  - Grep
  - Glob
  - TodoWrite
---

# Data Validation Skill

Comprehensive data validation using Pydantic v2 with data quality monitoring and schema alignment for PlanetScale PostgreSQL.

## Description

Implement robust data validation, quality monitoring, and schema contracts using Pydantic v2 models.

## What's Included

- **Examples**: Pydantic v2 models, validation patterns
- **Reference**: Schema design, validation strategies
- **Templates**: Pydantic model templates

## Use When

- API request/response validation
- Database schema alignment
- Data quality assurance

## Related Agents

- `data-validator`

**Skill Version**: 1.0

Overview

This skill provides comprehensive data validation using Pydantic v2, combined with data quality monitoring and schema alignment tools for PlanetScale PostgreSQL. It centralizes model templates, validation patterns, and actionable checks to reduce runtime errors and ensure contract consistency between APIs and the database. Use it to enforce typed, documented schemas and to surface data quality regressions early.

How this skill works

The skill supplies Pydantic v2 model templates and validation patterns that you can plug into API request/response flows and ingestion pipelines. It compares model schemas to a target PlanetScale PostgreSQL schema, highlights mismatches, and generates recommendations for database alignment. Built-in quality checks and monitoring hooks detect anomalies, missing fields, type drift, and constraint violations so you can remediate data issues proactively.

When to use it

  • Validating incoming API requests and responses against strict contracts
  • Aligning application models with PlanetScale PostgreSQL schemas before migrations
  • Implementing automated data quality monitoring for pipelines and ETL jobs
  • Enforcing field types, ranges, and required constraints at the boundary
  • Detecting schema drift and notifying teams of breaking changes

Best practices

  • Define canonical Pydantic v2 models as the single source of truth for API and DB contracts
  • Run schema alignment checks as part of CI to catch mismatches before deployment
  • Add targeted data quality rules (null rates, value distributions, uniqueness) where business impact is high
  • Version model schemas and perform staged rollouts for breaking field changes
  • Instrument validation failures with clear error messages and example fixes for consumers

Example use cases

  • Validate and coerce API payloads into typed Pydantic models before business logic executes
  • Generate a diff report between Pydantic models and PlanetScale PostgreSQL schema to plan migrations
  • Fail fast on ingestion when critical fields violate schema constraints or quality thresholds
  • Continuously monitor production data for type drift and unexpected null spikes
  • Provide pre-commit hooks that run model-schema alignment checks and unit tests

FAQ

Does this require Pydantic v2 specifically?

Yes—templates and patterns target Pydantic v2 features and validators for best compatibility.

Can it detect schema drift against PlanetScale PostgreSQL?

Yes—the alignment tools compare schemas and surface mismatches and recommended changes.

Is this suitable for both API and batch pipelines?

Yes—it works for synchronous API validation and asynchronous pipeline checks with the same model definitions.