Skip to content

diff

Show all changes between current specs and their last versioned snapshots, classified by severity. Unlike breaking, this command always exits 0 and is meant for understanding changes, not gating CI.

Terminal window
contractual diff [--contract <name>] [--format <fmt>] [--severity <level>] [--verbose]

contractual diff runs the same structural comparison as breaking. It compares each registered contract against its last versioned snapshot and classifies every change as:

  • breaking: would require a major version bump
  • non-breaking: would require a minor version bump
  • patch: backward-compatible fix

The key difference: diff reports all changes and always exits 0. It’s informational, not a gate.

CommandShowsExit code
diffAll changesAlways 0
breakingAll changes1 if breaking found

FlagDescriptionDefault
--contract <name>Diff only the named contract. Repeat for multiple.All contracts
--format <fmt>Output format: text or jsontext
--severity <level>Filter changes: all, breaking, non-breaking, patchall
--verboseShow JSON Pointer paths for each changeOff

terminal
$ contractual diff

orders-api: 3 changes (2 breaking, 1 non-breaking) — suggested bump: major

BREAKING     Removed endpoint GET /orders/{id}/details
BREAKING     Changed type of field 'amount': string → number
non-breaking  Added optional field 'tracking_url'

order-schema: no changes
terminal
$ contractual diff --severity breaking

orders-api: 2 breaking changes — suggested bump: major

BREAKING  Removed endpoint GET /orders/{id}/details
BREAKING  Changed type of field 'amount': string → number

order-schema: no changes
terminal
$ contractual diff --contract orders-api --verbose

orders-api: 3 changes (2 breaking, 1 non-breaking) — suggested bump: major

BREAKING     Removed endpoint GET /orders/{id}/details
             path: /paths/~1orders~1{id}~1details/get
BREAKING     Changed type of field 'amount': string → number
             path: /components/schemas/Order/properties/amount/type
non-breaking  Added optional field 'tracking_url'
             path: /components/schemas/Order/properties/tracking_url
terminal
$ contractual diff --format json

{
"results": [
  {
    "contract": "orders-api",
    "changes": [
      {
        "path": "/paths/~1orders~1{id}~1details/get",
        "severity": "breaking",
        "category": "endpoint-removed",
        "message": "Removed endpoint GET /orders/{id}/details"
      }
    ],
    "summary": {
      "breaking": 2,
      "nonBreaking": 1,
      "patch": 0
    },
    "suggestedBump": "major"
  }
]
}

CodeMeaning
0Success (regardless of changes found)
2Configuration error
3Tool execution error

ScenarioCommand
Exploring changes locallydiff
Understanding what will be in the changesetdiff
Debugging why something was classified as breakingdiff --verbose
CI check that blocks PRsbreaking
GitHub Action workflowbreaking (via Action)