> ## 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.

# Commands

> Choose the supaschema CLI command for migration generation, validation, verification, inspection, configuration, and diagnostics.

Use this page to choose the command by job.

Open the command page when you need exact flags or exit codes.

## Generate and prove

<CardGroup cols={2}>
  <Card title="diff" icon="file-diff" href="/docs/commands/diff">
    Generate a replay-safe migration from two schema sources.
  </Card>

  <Card title="stage" icon="git-branch-plus" href="/docs/commands/stage">
    Git-stage changed generated migration files.
  </Card>

  <Card title="apply" icon="database-zap" href="/docs/commands/apply">
    Apply already-generated pending migrations.
  </Card>

  <Card title="check" icon="shield-check" href="/docs/commands/check">
    Validate migration SQL for replay safety and hazards.
  </Card>
</CardGroup>

<CardGroup cols={2}>
  <Card title="verify" icon="repeat-2" href="/docs/commands/verify">
    Apply a migration twice in disposable databases.
  </Card>

  <Card title="types" icon="braces" href="/docs/commands/types">
    Generate TypeScript and Zod outputs from schema files.
  </Card>
</CardGroup>

<CardGroup cols={2}>
  <Card title="scan" icon="shield-alert" href="/docs/commands/scan">
    Score RLS, grant, hygiene, and generated-contract usage findings without a
    database.
  </Card>

  <Card title="type-contract" icon="file-warning" href="/docs/commands/type-contract">
    Gate breaking generated TypeScript/Zod contract changes.
  </Card>
</CardGroup>

## Operate

<CardGroup cols={3}>
  <Card title="migrations" icon="list-checks" href="/docs/commands/migrations">
    Reconcile files on disk with applied database history.
  </Card>

  <Card title="sync" icon="refresh-cw" href="/docs/commands/sync">
    Run the full diff, check, types, stage, apply, and reconcile workflow.
  </Card>

  <Card title="config validate" icon="settings" href="/docs/commands/config-validate">
    Check config paths, sources, and credential references.
  </Card>
</CardGroup>

<CardGroup cols={2}>
  <Card title="contracts" icon="archive" href="/docs/commands/contracts">
    Export and diff cross-repository schema contracts locally.
  </Card>
</CardGroup>

## Inspect

<CardGroup cols={2}>
  <Card title="plan" icon="list-tree" href="/docs/commands/plan">
    Print the object-level diff plan as JSON.
  </Card>

  <Card title="inspect" icon="scan-search" href="/docs/commands/inspect">
    Print the extracted schema model as JSON.
  </Card>

  <Card title="fingerprint" icon="fingerprint" href="/docs/commands/fingerprint">
    Print the canonical equality hash for a source.
  </Card>

  <Card title="audit" icon="clipboard-check" href="/docs/commands/audit">
    Report modeled and unsupported schema coverage.
  </Card>
</CardGroup>

## Utilities

<CardGroup cols={2}>
  <Card title="corpus" icon="database-zap" href="/docs/commands/corpus">
    Run the dirty-real regression oracle.
  </Card>

  <Card title="doctor" icon="stethoscope" href="/docs/commands/doctor">
    Diagnose local setup and database capability.
  </Card>

  <Card title="onboard" icon="map" href="/docs/commands/onboard">
    Detect incumbent migration tooling and print ordered remediation.
  </Card>

  <Card title="init" icon="sparkles" href="/docs/commands/init">
    Scaffold or repair the project setup bundle.
  </Card>
</CardGroup>

<CardGroup cols={2}>
  <Card title="explain" icon="message-circle-question" href="/docs/commands/explain">
    Decode a `SUPA_*` diagnostic code offline.
  </Card>
</CardGroup>

## Shell and engine

<CardGroup cols={2}>
  <Card title="completion" icon="terminal" href="/docs/commands/completion">
    Print shell completion scripts for bash, zsh, or fish.
  </Card>

  <Card title="selfcheck" icon="badge-check" href="/docs/commands/selfcheck">
    Compare live-catalog extraction with engine representation.
  </Card>
</CardGroup>

## Defaults

When you omit flags, supaschema reads `supaschema.config.json`.

| Area                 | Default                                                                                                                                                              |
| -------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `--from`             | `config.sources.from`; for generation, `"auto"` resolves valid `git:HEAD` as a candidate baseline, then generated migration lineage must match when migrations exist |
| `--to`               | `dir:<config.schemaPaths[0]>`                                                                                                                                        |
| Migration output     | `config.migrationsDir`                                                                                                                                               |
| `check` input        | every `.sql` file in `config.migrationsDir`; fails when none exist unless `--allow-empty` is passed                                                                  |
| `verify --migration` | newest `.sql` file in `config.migrationsDir`                                                                                                                         |

## Global flags

<ParamField path="--config" type="path">
  Use an explicit JSON config file instead of `supaschema.config.json`.
</ParamField>

<ParamField path="--env" type="string">
  Read the database URL from a named `environments` entry in config.
</ParamField>

<ParamField path="--quiet" type="boolean">
  Suppress non-essential diagnostic output.
</ParamField>

## Exit codes

| Code | Meaning                                                  |
| ---- | -------------------------------------------------------- |
| `0`  | Success                                                  |
| `1`  | Runtime error, bad arguments, unreadable input, or crash |
| `2`  | Diagnostics contained at least one error                 |
| `3`  | `diff --fail-on-diff` found operations                   |
