Configuration Validation & Migration System
July 2, 2025 ยท View on GitHub
The auto-claude-code project now includes advanced validation and migration capabilities to ensure your Claude Code configurations remain healthy and up-to-date.
Features Overview
๐ Configuration Validation
- CLAUDE.md Syntax Validator: Validates markdown structure and YAML references
- MCP Server Connectivity Tester: Checks server availability and configuration
- Template Compatibility Checker: Ensures configuration matches template standards
- Health Check Dashboard: Rich console interface with detailed reports
๐ Smart Migration System
- Version Detection: Automatic detection of configuration versions
- Smart Diff Engine: Intelligent comparison of configuration changes
- Backup & Restore: Automatic backups before migrations
- Upgrade Assistant: Guided upgrades with rollback capabilities
Quick Start
Health Check
Run a comprehensive health check on your current configuration:
python setup.py --health-check
Upgrade Check
Check for available upgrades and apply them:
python setup.py --upgrade
Validation Only
Run validation without upgrading:
python setup.py --validate
Validation Features
CLAUDE.md Validator
Checks for:
- Valid markdown structure
- Correct @include references
- Missing YAML files
- Malformed syntax
- Common configuration issues
MCP Server Validator
Validates:
- Server configuration syntax
- Command availability
- Connection testing
- Dependency checks
- Security settings
Template Validator
Ensures:
- Required files are present
- Directory structure is correct
- Framework-specific requirements
- Version compatibility
- Documentation completeness
Migration Features
Version Management
- Semantic versioning support
- Automatic version detection
- Configuration metadata tracking
- Checksum validation
Smart Diffing
- Intelligent change detection
- Impact assessment
- Auto-merge capability for safe changes
- Conflict identification
Backup System
- Automatic backups before changes
- Compressed backup storage
- Backup listing and management
- Import/export capabilities
Usage Examples
Programmatic Usage
from validation import HealthChecker, ClaudeConfigValidator
from migration import VersionManager, UpgradeAssistant
# Run health check
config_path = Path("/path/to/config")
health_checker = HealthChecker(config_path)
results = health_checker.run_health_check()
health_checker.display_health_report()
# Check version and upgrade
version_manager = VersionManager(config_path)
current_version = version_manager.detect_current_version()
upgrade_assistant = UpgradeAssistant(config_path)
latest_version = upgrade_assistant.check_for_upgrades()
if latest_version:
upgrade_assistant.perform_upgrade(latest_version)
Command Line Usage
# Setup with validation enabled (default in interactive mode)
python setup.py
# Run health check only
python setup.py --health-check
# Check for upgrades
python setup.py --upgrade
# Validate existing configuration
python setup.py --validate
# Setup new project with framework
python setup.py --framework fastapi --validate
Health Check Report
The health checker provides detailed reports including:
- Overall Health Score: 0-100% based on issues found
- Error Count: Critical issues that need immediate attention
- Warning Count: Issues that should be addressed
- Recommendations: Actionable suggestions for improvements
- Auto-fixable Issues: Problems that can be automatically resolved
Sample Health Report
๐ Configuration Health Check
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Status: โ
HEALTHY
Errors: 0
Warnings: 2
Info: 5
Checked: 2024-07-02 14:30:15
๐ ClaudeConfigValidator
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ ๏ธ Warnings:
โข Very long line (250 characters)
๐ก Consider breaking long lines for better readability
โข Recommended section 'Development' not found
๐ก Consider adding a 'Development' section for better organization
๐ MCPServerValidator
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โน๏ธ Information:
โข MCP server 'filesystem' started successfully
โข MCP server 'context7' started successfully
Migration Workflow
Automatic Upgrades
- Detection: System detects outdated configuration
- Preview: Shows what will change
- Backup: Creates automatic backup
- Migration: Applies changes safely
- Validation: Verifies result health
- Rollback: Available if issues occur
Manual Migration
- Check current version:
version_manager.detect_current_version() - List available upgrades:
upgrade_assistant.check_for_upgrades() - Preview changes:
upgrade_assistant.get_upgrade_preview(version) - Perform upgrade:
upgrade_assistant.perform_upgrade(version) - Verify result:
health_checker.run_health_check()
Configuration Files
The system creates several metadata files:
.version: Current configuration version.metadata.json: Detailed configuration metadata.claude/backups/: Backup storage directory.claude/.validation_cache: Validation cache (optional)
Error Handling
Validation Errors
- Critical: Configuration cannot be used
- Error: Major issues that should be fixed
- Warning: Minor issues that can wait
- Info: Informational messages
Migration Errors
- Failed: Migration could not complete
- Rollback Required: Changes need to be undone
- Partial: Some changes applied successfully
- Success: All changes applied correctly
Best Practices
For Validation
- Run health checks regularly
- Address errors before warnings
- Keep configurations up to date
- Use auto-fix for safe issues
- Review recommendations regularly
For Migration
- Always backup before major changes
- Test in development first
- Read upgrade previews carefully
- Have rollback plan ready
- Validate after migration
Troubleshooting
Common Issues
Health check fails to run
- Check if validation modules are installed
- Verify Python path includes tools directory
- Install dependencies:
pip install -r requirements.txt
Migration fails
- Check disk space for backups
- Verify write permissions
- Review error messages in output
- Use backup to restore if needed
Validation false positives
- Update validation rules if needed
- Report issues to project maintainers
- Use manual overrides cautiously
Debug Mode
Enable verbose output for troubleshooting:
python setup.py --health-check --verbose
Contributing
The validation and migration system is designed to be extensible:
- Add new validators by extending
BaseValidator - Create custom migration rules in
UpgradeAssistant - Improve health check reports in
HealthChecker - Add new diff algorithms to
SmartDiffEngine
API Reference
Validation Classes
BaseValidator: Base class for all validatorsClaudeConfigValidator: CLAUDE.md file validatorMCPServerValidator: MCP server configuration validatorTemplateValidator: Template structure validatorHealthChecker: Comprehensive health checking
Migration Classes
BaseMigrator: Base class for migration operationsVersionManager: Version detection and managementSmartDiffEngine: Configuration change analysisBackupManager: Backup and restore operationsUpgradeAssistant: Guided upgrade functionality
Result Classes
ValidationResult: Individual validation resultMigrationResult: Migration operation resultBackupInfo: Backup file informationConfigChange: Configuration change details
This system ensures your Claude Code configurations remain healthy, secure, and up-to-date with minimal manual intervention.