# Designs from the CLI

> Publish, pull, check and change Dockito database designs from a terminal and in CI.

The `dockito` CLI keeps a design and a repo's schema file in step, both ways. [Install it](/help/cli/install) first. Every command is also on [CLI commands](/help/cli/commands).

## Publish

A `.dbml` or `.sql` file becomes a design. Publishing it again makes the next version, and History shows what changed.

```sh
dockito publish schema.dbml --to book-club
dockito publish db/schema.sql --to book-club
```

From an ORM, through its own tool in your project (`prisma migrate diff`, `drizzle-kit export`, or the migrations it wrote). Only the SQL is sent:

```sh
dockito publish --from prisma     # prisma/schema.prisma as a design
dockito publish --from drizzle
```

## Pull

`pull` writes a design to a file your repo keeps, exactly as stored, so publishing it back changes nothing. `--sql` writes `CREATE` statements instead.

```sh
dockito pull <design>                              # schema.dbml
dockito pull <design> db/schema.sql --sql postgres
```

`db pull` reads a live PostgreSQL or MySQL database's schema into a `.dbml` file. It runs one read-only catalog query through the database's own client (`psql`, `mysql`), so the connection and its password never leave your machine.

```sh
dockito db pull postgres://me@localhost:5432/bookclub
dockito db query mysql             # print the query, to run in any client
dockito db pull --catalog answer.json
```

## Check

`check` lists every problem in a design, or in a local file without sending it, errors first, each with its fix. It exits 1 on errors.

```sh
dockito check schema.dbml
dockito check <design> --tables orders,payments --level warning
dockito check <design> --rules fk-no-index --ignored
```

`--doc` compares a file with a design too, and exits 2 when they differ.

## Change

`edit-db` changes a design with ops at the version you read, as your AI does. Read it first with `dockito get <design>`.

```sh
dockito get <design> --outline
echo '[{"op": "index", "table": "payments", "cols": ["invoice_id"]}]' | dockito edit-db <design> - --base 14
```

`changes` gives what changed since a version, a line a table, then the migration SQL. Review it before you run it.

```sh
dockito changes <design> --since 12 --sql postgres
```

## In CI

So a pull request can't break the schema or let it drift from the design. This GitHub Actions step fails on errors (exit 1) and when the file differs from the design (exit 2):

```yaml
- run: npm install -g dockito
- run: dockito check schema.dbml --doc <design>
  env:
    DOCKITO_TOKEN: ${{ secrets.DOCKITO_TOKEN }}
```

Without `--doc` no token is needed: the file is checked on the runner. Make the token in [Tokens](/help/agents/tokens) with View access.
