> ## Documentation Index
> Fetch the complete documentation index at: https://supaschema.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# contracts

> Export and diff JSON schema contracts for cross-repository drift checks.

Use `contracts` when one repository publishes the database shape another repository consumes.

The commands export and diff JSON contracts locally. Store or transfer the resulting JSON with the repository and artifact systems your teams already use.

## Run it

```bash theme={null}
npx supaschema contracts export --out schema-contract.json
npx supaschema contracts diff --from schema-contract.json
```

## Subcommands

<ParamField path="export" type="command">
  Build a JSON schema contract from `--from`, defaulting to the configured
  schema tree.
</ParamField>

<ParamField path="diff" type="command">
  Compare `--from <file>` with `--to <source>`, defaulting `--to` to the
  configured schema tree.
</ParamField>

## Flags

<ParamField path="--from" type="source">
  Schema source used by `export`.
</ParamField>

<ParamField path="--to" type="source">
  Candidate source used by `diff`. Defaults to the configured schema tree.
</ParamField>

<ParamField path="--out" type="file | stdout">
  Output destination for `export`. Defaults to `stdout`.
</ParamField>

## Boundaries

Contract JSON contains modeled schema metadata, not database URLs, migration files, table rows, or live database credentials. Review it before committing or transferring it when object names or comments are sensitive.

## Exit codes

| Code | Meaning                                        |
| ---- | ---------------------------------------------- |
| 0    | Contract command completed.                    |
| 2    | `diff` found error-severity drift diagnostics. |
