Coming from Optic
Move from Optic's diff, lint and changelog to contractdiff: diff for breaking changes, lint with forwards-only adoption through --since, the changelog as diff output, and what Optic did that contractdiff does not, such as capturing traffic into a spec.
Optic checked OpenAPI changes in pull requests: optic diff reported breaking changes against a
base branch, optic lint applied API standards, and its standards could be applied only to the
operations a change touched, so a team could adopt a rule without fixing the whole spec first. Its
repository was archived on 2026-01-12, as .sdlc/intents/contractdiff/intent.md records.
contractdiff covers the diff, the lint and the forwards-only adoption, from npm.
How the names map
| Optic | contractdiff |
|---|---|
optic diff openapi.yaml --base main --check | git show main:openapi.yaml > base.yaml, then contractdiff diff base.yaml openapi.yaml |
| breaking-change standard | the default diff check; exit 1 on a breaking change |
optic lint openapi.yaml | contractdiff lint openapi.yaml |
standards in optic.yml | lint in contractdiff.config.json: extends, per-rule levels; see Lint |
| rules applied only to added or changed operations | lint --since <ref>, with lint.legacy for the rules that still run everywhere |
| the changelog in a PR comment | diff output, every change with its verdict; --json for a bot to render |
optic ci | the steps in CI gate |
Migrating
npm install -D contractdiffand remove Optic from the project.- Move the standards you relied on into
contractdiff.config.json. The built-inrecommendedset covers ids, descriptions, tags, success responses, references and examples; a Spectral ruleset youroptic.ymlpointed at can be named inlint.extendsas it is. - Replace
optic diff --checkwith adiffstep against the base branch, andoptic lintwithlint --since merge-baseif you adopted rules forwards-only. - If a bot posted Optic's changelog on pull requests, feed it
contractdiff diff --jsoninstead.
A local check of the change in getting started, with the decision check on:
breaking: 1 breaking, 0 unknown, 1 non-breaking (--mode backward --side caller)
getPet #/paths/~1pets~1{id}/get
breaking new-required-request-parameter param:query:fields - -> {"type":"string"}
fix: keep accepting at getPet param:query:fields what the old contract accepted, or release this as a major version
non-breaking response-optional-property-removed response:200:application/json /properties/tag {"type":"string"} -> -
decisions: 1 (--decisions warn)
warn ac-decision-missing getPet param:query:fields - -> {"type":"string"}
fix: breaking change (`new-required-request-parameter`) at getPet param:query:fields with no decision: add `x-change: <the decision>` to getPet param:query:fields, or an ancestor or its operation, naming who decided it; or revert the changeWhat is different on purpose
- The diff states its question, mode and side, on its first line, and can ask it for the server as well as for callers.
- Decisions are in the contract. Where an Optic workflow relied on a reviewer approving a
breaking change, contractdiff asks for an
x-changebeside the member, read back on every run. - Beyond OpenAPI. AsyncAPI, JSON Schema, MCP tool lists and protobuf go through the same
diffandlint. - Code from the contract.
genwrites types, validators, clients, mocks and servers; Optic did not generate code.
What is not built
- Capturing traffic into a spec (
optic capture). There is no traffic recorder;extractwrites a contract from code instead, for the sources Code generation lists. - Reading the base from git by itself. The 1.0.0 bin refuses
git:<ref>:<path>; write the base out withgit showfirst, as above. - A hosted changelog or API catalog. contractdiff is a local CLI with text,
--jsonand SARIF output. - Reading
optic.yml. Move its standards by hand; the Spectral and Redocly readers are for those two formats only.
Coming from oasdiff
Move a breaking-change check from oasdiff to contractdiff diff: the same rule ids for HTTP changes, a compatibility question you choose instead of a fixed one, AsyncAPI, JSON Schema and MCP on the same engine, and what oasdiff has that contractdiff does not.
CI gate
A GitHub Actions job that fails a pull request on a breaking contract change, a lint rule at error or generated code that is out of date, and uploads the findings as SARIF to code scanning.