Contract Management
Overview
API contracts are the source of truth for how services communicate. Every API change must be reflected in the contracts file before downstream work begins.
Core principle: Code follows contracts. Contracts follow code. They must never diverge.
When to Use
- After modifying any service's API endpoint
- Before implementing a downstream consumer of a changed API
- When onboarding to a multi-service project (read contracts first)
- During code review of cross-service changes
Contract Files
Cascade looks for contracts in this order:
cascade.yaml→contracts:fieldcontracts/api-contracts.yamlcontracts/dependency-map.md- Any
ENGINE_INTERFACES.mdor similar architecture docs
Versioning
| Change Type | Version Bump | Example | |------------|-------------|---------| | New field added | Minor (1.2.0 → 1.3.0) | Added phone to User | | New endpoint | Minor | Added /api/v1/users/search | | Field renamed | Major (1.2.0 → 2.0.0) | role → account_type | | Field removed | Major | Removed legacy_id | | Type changed | Major | price: string → price: float | | Bug fix | Patch (1.2.0 → 1.2.1) | Fixed typo in contract |
The Rule
After EVERY service API change:
- Update the contract to match the actual code
- Bump the version
- Commit the contract change
- THEN move to downstream services