name: breaking-change-detection
description: OpenAPI diff tools, schema comparison, and migration guide templates for detecting breaking changes in APIs, databases, and contracts. Use when analyzing API changes, comparing OpenAPI specs, detecting breaking changes, validating backward compatibility, creating migration guides, analyzing database schema changes, or when user mentions breaking changes, API diff, schema comparison, migration guide, backward compatibility, contract validation, or API versioning.
allowed-tools: Bash, Read, Write, Edit
Breaking Change Detection
Comprehensive patterns, scripts, and templates for detecting and documenting breaking changes across APIs, databases, and contracts during version bumps.
Overview
This skill provides functional tools for detecting breaking changes in:
- OpenAPI/REST APIs: Endpoint changes, request/response schema modifications
- Database schemas: Table structure, column types, constraints
- GraphQL schemas: Type changes, field modifications, directive updates
- gRPC/Protobuf: Message structure, field number changes
- Library contracts: Public API changes, function signatures
All scripts include proper error handling, diff algorithms, and detailed reporting.
Instructions
1. Detecting API Breaking Changes
Analyze OpenAPI Specification Changes:
- Use
scripts/openapi-diff.sh to compare two OpenAPI spec versions
- Identifies removed endpoints, changed response codes, modified schemas
- Generates detailed diff with breaking/non-breaking classifications
- Use
templates/breaking-change-report.md for documentation
Common Breaking Changes Detected:
- Removed endpoints or operations
- Changed HTTP methods
- Removed or renamed request/response properties
- Changed property types (string to number, etc.)
- Added required fields without defaults
- Changed authentication requirements
- Modified error response formats
2. Database Schema Comparison
Detect Database Migration Issues:
- Use
scripts/schema-compare.sh to compare database schemas
- Identifies table drops, column removals, type changes
- Detects constraint modifications (foreign keys, unique constraints)
- Flags backward-incompatible changes
Breaking Changes in Databases:
- Dropped tables or views
- Removed columns
- Changed column types (especially narrowing: int to smallint)
- Added NOT NULL constraints to existing columns
- Removed or modified foreign key relationships
- Changed primary key structure
3. Comprehensive Breaking Change Analysis
Analyze All Changes Across Systems:
- Use
scripts/analyze-breaking.sh as orchestrator script
- Runs all detection scripts (API, schema, contract)
- Aggregates results into unified report
- Assigns severity levels (CRITICAL, HIGH, MEDIUM, LOW)
- Generates migration guide template
Analysis Process:
# Run comprehensive analysis
bash scripts/analyze-breaking.sh \
--old-api old-spec.yaml \
--new-api new-spec.yaml \
--old-schema old-schema.sql \
--new-schema new-schema.sql \
--output breaking-changes-report.md
4. Creating Migration Guides
Document Breaking Changes for Users:
- Use
templates/migration-guide.md as starting template
- Use
templates/migration-guide-api.md for API-specific changes
- Use
templates/migration-guide-database.md for schema changes
- Include before/after code examples
- Provide step-by-step migration instructions
- Document workarounds and alternatives
Migration Guide Structure:
- Summary: Overview of breaking changes
- Impact: Who is affected and how
- Migration Steps: Step-by-step instructions
- Code Examples: Before and after
- Timeline: Deprecation schedule if applicable
- Support: Where to get help
5. Automated Detection in CI/CD
Integrate Breaking Change Detection:
- Use
templates/ci-cd-breaking-check.yaml for GitHub Actions/GitLab CI
- Run detection on every PR that modifies API specs or schemas
- Fail builds if breaking changes detected without proper versioning
- Generate automated migration guide drafts
- Post results as PR comments
CI/CD Integration Pattern:
# Detect breaking changes before merge
- name: Check for breaking changes
run: bash scripts/analyze-breaking.sh --old $BASE_BRANCH --new $HEAD_BRANCH
- name: Fail if breaking changes without major version bump
if: breaking_detected && !major_version_bump
run: exit 1
6. Severity Classification
Classify Breaking Changes by Impact:
CRITICAL (Immediate user impact):
- Removed API endpoints
- Dropped database tables
- Changed authentication requirements
HIGH (Requires code changes):
- Renamed fields/properties
- Changed data types
- Added required parameters
MEDIUM (Behavior changes):
- Modified validation rules
- Changed default values
- Updated error messages
LOW (Documentation updates):
- Deprecated but still functional
- Added optional fields
- Changed response ordering
7. Backward Compatibility Strategies
Minimize Breaking Changes:
- Add new fields instead of modifying existing
- Deprecate before removing (gradual migration)
- Support multiple versions simultaneously
- Use feature flags for behavioral changes
- Provide adapter/shim layers
- Document deprecation timelines clearly
Non-Breaking Alternatives:
- Add new v2 endpoints instead of modifying v1
- Add optional fields instead of required
- Expand types instead of narrowing (accept more)
- Add database columns as nullable
Available Scripts
-
openapi-diff.sh: Compare two OpenAPI/Swagger specifications and identify breaking changes
- Detects endpoint changes, schema modifications, authentication changes
- Classifies changes as breaking/non-breaking
- Generates detailed diff report with examples
-
schema-compare.sh: Compare database schemas (SQL, migrations, Prisma, etc.)
- Identifies table/column drops, type changes, constraint modifications
- Works with PostgreSQL, MySQL, SQLite schemas
- Detects data migration requirements
-
analyze-breaking.sh: Orchestrator script that runs all detection tools
- Unified interface for comprehensive analysis
- Aggregates results across API, database, and contract changes
- Generates prioritized action items
- Creates migration guide template
-
graphql-diff.sh: Compare GraphQL schemas for breaking changes
- Type changes, field removals, directive modifications
- Argument type changes, nullability changes
-
proto-diff.sh: Compare Protobuf definitions for gRPC services
- Field number changes, message structure modifications
- Service method signature changes
Available Templates
- breaking-change-report.md: Comprehensive report template with sections for each change type
- migration-guide.md: General migration guide template with step-by-step structure
- migration-guide-api.md: API-specific migration guide with code examples
- migration-guide-database.md: Database migration guide with SQL snippets
- ci-cd-breaking-check.yaml: GitHub Actions/GitLab CI workflow template
- deprecation-notice.md: Deprecation announcement template for gradual migrations
Available Examples
- api-contract-analysis.md: Real-world example of OpenAPI diff analysis with breaking changes identified
- database-migration-detection.md: Database schema comparison example with migration steps
- graphql-schema-changes.md: GraphQL type evolution example with client impact analysis
- versioning-strategy.md: Complete versioning strategy example integrating breaking change detection
- ci-cd-integration.md: Full CI/CD pipeline integration with automated detection and reporting
Requirements
Core Requirements:
jq - JSON parsing and manipulation
yq - YAML parsing (for OpenAPI specs)
diff - File comparison utility
git - Version control for diff context
Optional Requirements:
openapi-diff - Enhanced OpenAPI comparison (npm package)
oasdiff - Alternative OpenAPI diff tool
schemacrawler - Database schema analysis
protoc - Protocol buffer compiler (for gRPC)
rover - GraphQL schema tooling (Apollo)
Installation Commands:
# Core tools (usually pre-installed)
apt-get install jq diffutils git
# YAML parsing
pip install yq
# Optional OpenAPI tools
npm install -g openapi-diff oasdiff
# Database tools
brew install schemacrawler # macOS
apt-get install schemacrawler # Linux
Exit Codes
All scripts follow standard exit code conventions:
0 - No breaking changes detected
1 - Breaking changes detected (see report)
2 - Invalid arguments or missing dependencies
3 - File read/parse errors
4 - Comparison failed (incompatible formats)
Best Practices
- Run detection on every PR - Catch breaking changes before merge
- Version appropriately - Breaking changes require major version bump
- Document thoroughly - Create comprehensive migration guides
- Test migrations - Validate migration steps in staging environment
- Communicate early - Announce breaking changes well in advance
- Provide alternatives - Document workarounds and migration paths
- Support multiple versions - Allow gradual migration when possible
- Use deprecation periods - Give users time to adapt
- Automate detection - Integrate into CI/CD pipelines
- Archive breaking changes - Keep historical record for reference
Integration with Versioning Commands
This skill is used by versioning plugin commands:
- /versioning:bump - Runs breaking change detection before version bump
- /versioning:info - Shows breaking changes in current version
- /versioning:validate - Validates breaking changes match version bump type
Progressive Disclosure
For additional reference material:
- Read
examples/api-contract-analysis.md for OpenAPI diff examples
- Read
examples/database-migration-detection.md for schema change patterns
- Read
examples/ci-cd-integration.md for pipeline integration
- Read
examples/versioning-strategy.md for complete workflow
Skill Location: plugins/versioning/skills/breaking-change-detection/SKILL.md
Version: 1.0.0