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

# CLI

> Complete reference for all Mori CLI commands and configuration.

## Setup

### `mori init`

Interactive setup. Walks you through engine selection, provider, and credentials.

```bash theme={null}
mori init
```

<Info>
  Some of these flows might not be optimal since there's so many combinations. If the interactive flow isn't working for you, try using the direct connection string method.

  In the meantime, you can open an issue for the way you were trying to connect.
</Info>

Non-interactive init with a connection string:

```bash theme={null}
mori init --from "postgres://user:pass@host:5432/mydb?sslmode=require"
```

> More information at [Configuration > Providers](/docs/configuration/providers)

Use a custom Docker image for the Shadow container (e.g., for PostgreSQL with pre-installed extensions):

```bash theme={null}
mori init --image myregistry/postgres-custom:16
```

| Flag      | Description                                                                                                                                                                                                       |
| --------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `--from`  | Connection string for non-interactive mode                                                                                                                                                                        |
| `--image` | Custom Docker image for the Shadow container. Persisted in `mori.yaml` and used by `mori start`. Useful when extensions cannot be auto-installed via `apt-get` (e.g., distroless images, proprietary extensions). |

<Info>
  For PostgreSQL, Mori automatically attempts to install extensions via `apt-get` inside the Shadow container when `CREATE EXTENSION` fails. The `--image` flag is an escape hatch for cases where auto-install does not work.
</Info>

## Running

### `mori start`

Start the proxy. On first run, creates the Shadow database.

```bash theme={null}
mori start                    # Start with default connection
mori start my-connection      # Start a specific connection
mori start --port 5433        # Start on a custom port
mori start --verbose          # Log all queries and routing decisions
mori start --mcp              # Enable MCP server for AI agents
mori start --mcp-port 9000    # Set MCP server port
```

| Flag         | Description                             | Default         |
| ------------ | --------------------------------------- | --------------- |
| `--port`     | Proxy listen port                       | Auto-assign     |
| `--verbose`  | Log all queries and routing decisions   | `false`         |
| `--mcp`      | Enable MCP server                       | `false`         |
| `--mcp-port` | MCP HTTP server port                    | `9000`          |
| `--max-rows` | Max rows to hydrate from prod per query | `0` (unlimited) |

### `mori stop`

Graceful shutdown. Persists all state (Delta Map, Tombstone Set, Schema Registry).

```bash theme={null}
mori stop
```

## State Management

### `mori reset`

Wipe all local state — Shadow data, Delta Map, Tombstone Set, Schema Registry. Use this for quick resets between runs.

```bash theme={null}
mori reset            # Wipe local state
```

<Warning>
  `mori reset` is irreversible. The local shadow persists, but all local mutations are permanently deleted.
</Warning>

### `mori reinit`

Wipe all local state and delete the shadow container. Use this when the production schema has changed since the last init.

```bash theme={null}
mori reinit            # Wipe local state and delete the shadow container
```

<Warning>
  `mori reinit` is irreversible. The local shadow and all local mutations are permanently deleted.
</Warning>

### `mori status`

Display current state: delta rows, tombstones, schema diffs, sequence offsets.

```bash theme={null}
mori status
```

### `mori inspect`

Detailed state for a specific table: delta count, tombstone count, schema divergence, PK type.

```bash theme={null}
mori inspect users
```

## Logging

### `mori log`

Stream the proxy activity log.

```bash theme={null}
mori log              # Stream live
mori log --tail 50    # Show last 50 entries
```

### `mori dash`

Launch the [TUI dashboard](/docs/usage/tui) — real-time query stream, delta/tombstone stats, table breakdown, live charts.

```bash theme={null}
mori dash
```

## Connection Management

### `mori ls`

List all configured connections.

```bash theme={null}
mori ls
```

### `mori rm`

Remove a connection and its associated state.

```bash theme={null}
mori rm my-connection
```

### `mori config`

View or edit configuration.

```bash theme={null}
mori config
```

## Configuration Files

Mori stores all state in a `.mori/` directory at your project root, created by `mori init`. See [Components](/docs/concepts/components#state-persistence) for details on each state file.

```
.mori/
  mori.yaml             # Connection config (engine, addresses, ports)
  shadow/               # Shadow container metadata
  state/
    delta.json           # Delta Map (locally modified rows)
    tombstones.json      # Tombstone Set (locally deleted rows)
    schema_registry.json # Schema divergence tracking
    tables.json          # Table metadata (PKs, types)
    sequences.json       # Sequence offsets
  log/                   # Query and routing logs
```

<Tip>
  You may want to check `mori.yaml` into version control (with secrets excluded) so teammates can share the same connection setup.
</Tip>
