Cross-boundary contract intelligence for fullstack codebases.
contract-graph statically analyzes your repository to detect drift between backend contracts
(Pydantic/FastAPI) and frontend contracts (TypeScript interfaces/types) before runtime incidents happen.
uv sync --extra dev
uv run contract-graph init --preset fullstack
uv run contract-graph analyze
uv run contract-graph check --fail-on highExpected behavior:
- Exit code
0: no findings above threshold. - Exit code
1: findings matched the configured fail threshold. - Exit code
2: configuration or runtime input error.
contract-graph builds a directed graph from cross-boundary artifacts.
- Parse: discover models, routes, interfaces, and config readers.
- Discover: match provider contracts to consumer contracts.
- Compare: detect field/type/optionality mismatches.
- Policy: convert mismatches into CI-relevant findings.
- Report: output terminal, JSON, or Markdown reports.
Detected mismatch families:
- Missing field in consumer.
- Missing field in provider.
- Type incompatibility.
- Optionality mismatch.
- Phantom type.
contract-graph and drift are complementary:
contract-graphfocuses on static cross-boundary contract drift (v1: Pydantic ↔ TypeScript).driftcan consume structured findings for broader reliability workflows.
CLI Integration:
contract-graph analyze --format json | drift ingestFor complete integration guide, see docs/drift-integration.md.
Stable Output Contract:
All JSON output conforms to src/contract_graph/output_schema.json, ensuring reliable downstream tooling integration.
make install
make lint
make type-check
make test
make test-covAdditional docs:
- CONTRIBUTING.md
- DEVELOPER.md
- docs/MAINTAINER_RUNBOOK.md
- docs/REPOSITORY_GOVERNANCE.md
- ROADMAP.md
- SECURITY.md
MIT