Back to Skills

validating-database-integrity

jeremylongshore
Updated Today
21 views
712
74
712
View on GitHub
Metaaidata

About

This skill performs comprehensive database data validation, checking data types, ranges, formats, referential integrity, and business rules. Use it when you need to enforce data integrity constraints or implement validation rules within your database. It provides tools to analyze requirements and apply validation through direct database operations.

Quick Install

Claude Code

Recommended
Plugin CommandRecommended
/plugin add https://github.com/jeremylongshore/claude-code-plugins-plus
Git CloneAlternative
git clone https://github.com/jeremylongshore/claude-code-plugins-plus.git ~/.claude/skills/validating-database-integrity

Copy and paste this command in Claude Code to install this skill

Documentation

Prerequisites

Before using this skill, ensure:

  • Database connection credentials are available
  • Appropriate database permissions for schema modifications
  • Backup of production databases before applying constraints
  • Understanding of existing data that may violate new constraints
  • Access to database documentation for column specifications

Instructions

Step 1: Analyze Validation Requirements

  1. Review database schema and identify columns requiring validation
  2. Determine validation types needed (data type, range, format, referential)
  3. Document existing data patterns that may conflict with new rules
  4. Prioritize validation rules by business criticality

Step 2: Define Validation Rules

  1. Create validation rule definitions for each column
  2. Specify data types, constraints, and acceptable ranges
  3. Define regular expressions for format validation
  4. Map foreign key relationships for referential integrity
  5. Document business rule logic for complex validations

Step 3: Implement Database Constraints

  1. Generate SQL constraints for data type validation
  2. Add CHECK constraints for range and format validation
  3. Create foreign key constraints for referential integrity
  4. Implement triggers for complex business rule validation
  5. Test constraints with valid and invalid sample data

Step 4: Validate Existing Data

  1. Query existing data to identify constraint violations
  2. Generate reports of data that would fail new constraints
  3. Create data cleanup scripts to fix violations
  4. Execute cleanup scripts in staging environment first
  5. Re-validate cleaned data before applying constraints

Step 5: Apply Validation Rules

  1. Apply constraints to staging database first
  2. Monitor for any application errors or failures
  3. Validate that legitimate operations still function
  4. Apply constraints to production database during maintenance window
  5. Monitor database logs for constraint violation attempts

Output

This skill produces:

Database Constraints: SQL DDL statements with CHECK, FOREIGN KEY, and NOT NULL constraints

Validation Reports: Analysis of existing data showing constraint violations with counts and examples

Data Cleanup Scripts: SQL UPDATE/DELETE statements to fix existing data that violates new constraints

Test Results: Documentation of constraint testing with valid/invalid data samples and outcomes

Implementation Log: Timestamped record of constraint application with success/failure status

Error Handling

Constraint Violation Errors:

  • Review existing data that violates the constraint
  • Create data cleanup scripts to fix violations
  • Re-run constraint application after cleanup
  • Document exceptions that require manual review

Permission Errors:

  • Verify database user has ALTER TABLE privileges
  • Request elevated permissions from database administrator
  • Use separate admin connection for schema changes
  • Document permission requirements for future deployments

Circular Dependency Errors:

  • Map all foreign key relationships before implementation
  • Apply constraints in dependency order (referenced tables first)
  • Use ALTER TABLE ADD CONSTRAINT for deferred constraint creation
  • Consider disabling foreign key checks temporarily during bulk operations

Performance Degradation:

  • Analyze constraint checking overhead with EXPLAIN ANALYZE
  • Add appropriate indexes to support constraint validation
  • Consider batch validation for large data updates
  • Monitor query performance after constraint implementation

Resources

Database-Specific Constraint Syntax:

  • PostgreSQL: {baseDir}/docs/postgresql-constraints.md
  • MySQL: {baseDir}/docs/mysql-constraints.md
  • SQL Server: {baseDir}/docs/sqlserver-constraints.md

Validation Rule Templates: {baseDir}/templates/validation-rules/

  • Email format validation
  • Phone number validation
  • Date range validation
  • Numeric range validation
  • Custom business rules

Testing Guidelines: {baseDir}/docs/validation-testing.md Constraint Performance Analysis: {baseDir}/docs/constraint-performance.md Data Cleanup Procedures: {baseDir}/docs/data-cleanup-procedures.md

GitHub Repository

jeremylongshore/claude-code-plugins-plus
Path: plugins/database/data-validation-engine/skills/data-validation-engine
aiautomationclaude-codedevopsmarketplacemcp

Related Skills

sglang

Meta

SGLang is a high-performance LLM serving framework that specializes in fast, structured generation for JSON, regex, and agentic workflows using its RadixAttention prefix caching. It delivers significantly faster inference, especially for tasks with repeated prefixes, making it ideal for complex, structured outputs and multi-turn conversations. Choose SGLang over alternatives like vLLM when you need constrained decoding or are building applications with extensive prefix sharing.

View skill

evaluating-llms-harness

Testing

This Claude Skill runs the lm-evaluation-harness to benchmark LLMs across 60+ standardized academic tasks like MMLU and GSM8K. It's designed for developers to compare model quality, track training progress, or report academic results. The tool supports various backends including HuggingFace and vLLM models.

View skill

llamaguard

Other

LlamaGuard is Meta's 7-8B parameter model for moderating LLM inputs and outputs across six safety categories like violence and hate speech. It offers 94-95% accuracy and can be deployed using vLLM, Hugging Face, or Amazon SageMaker. Use this skill to easily integrate content filtering and safety guardrails into your AI applications.

View skill

langchain

Meta

LangChain is a framework for building LLM applications using agents, chains, and RAG pipelines. It supports multiple LLM providers, offers 500+ integrations, and includes features like tool calling and memory management. Use it for rapid prototyping and deploying production systems like chatbots, autonomous agents, and question-answering services.

View skill