# CLI (/docs/reference/cli)





The Flowlib CLI (`flowlib-cli`) manages project initialisation, schema generation, and database migrations. It's the recommended way to set up and manage your Flowlib project.

```bash
npx flowlib-cli <command> [options]
```

<Callout type="info">
  You can also use your package manager's equivalent: `pnpm dlx flowlib-cli`, `yarn dlx
    flowlib-cli`, or `bunx flowlib-cli`.
</Callout>

All commands accept `--debug` for detailed error output and stack traces.

***

## `init` [#init]

Interactive setup wizard. Detects framework, installs dependencies, creates config, generates schemas, runs initial migration. &#x2A;*This is the recommended way to get started.**

```bash
npx flowlib-cli init
```

| Flag                     | Description                                                    |
| ------------------------ | -------------------------------------------------------------- |
| `--framework <name>`     | Skip framework detection (`express`, `nestjs`, `nextjs`).      |
| `--database <type>`      | Skip database selection (`sqlite`, `postgresql`, `mysql`).     |
| `--package-manager <pm>` | Skip package manager detection (`npm`, `pnpm`, `yarn`, `bun`). |

**Example: non-interactive setup**

```bash
npx flowlib-cli init --framework express --database sqlite --package-manager pnpm
```

***

## `generate` [#generate]

Generate Drizzle schema files from core + plugin schemas.

```bash
npx flowlib-cli generate
```

| Flag                | Description                                                 |
| ------------------- | ----------------------------------------------------------- |
| `--config <path>`   | Path to config file (default: auto-discovery).              |
| `--dialects <list>` | Comma-separated dialects (`sqlite`, `postgresql`, `mysql`). |
| `--out-dir <dir>`   | Output directory for generated files.                       |
| `--adapter <name>`  | Schema adapter (`drizzle` or `prisma`).                     |
| `--schema-only`     | Generate schema files without migration files.              |
| `-y, --yes`         | Skip confirmation prompts.                                  |

The CLI reads `flowlib.config.ts`, discovers plugins, merges schemas, and generates dialect-specific Drizzle files. Unchanged files are skipped.

**Run this after adding or updating plugins with database tables.**

***

## `migrate` [#migrate]

Apply database schema changes.

```bash
# Production: generate + apply migration files
npx flowlib-cli migrate

# Development: push schema directly (fast, no migration files)
npx flowlib-cli migrate --push
```

| Flag              | Description                                        |
| ----------------- | -------------------------------------------------- |
| `--config <path>` | Path to config file.                               |
| `--push`          | Use `drizzle-kit push` (fast, no migration files). |
| `-y, --yes`       | Skip confirmation prompts.                         |

***

## `info` [#info]

Display diagnostic information about your setup.

```bash
npx flowlib-cli info
```

| Flag              | Description          |
| ----------------- | -------------------- |
| `--config <path>` | Path to config file. |
| `--json`          | Output as JSON.      |

Shows system info, detected framework, database type, config location, installed packages, and registered plugins.

***

## `secret` [#secret]

Generate a cryptographically secure 32-byte base64 encryption key for `FLOWLIB_ENCRYPTION_KEY`.

```bash
npx flowlib-cli secret
```

Copy the output into your `.env` file or secrets manager.

***

## `mcp` [#mcp]

Start a Model Context Protocol (MCP) server over stdio. Connects to a running Flowlib instance and exposes flow building/execution tools to AI assistants like Claude, Copilot, or Cursor.

```bash
npx flowlib-cli mcp --url http://localhost:3000/flowlib
```

| Flag              | Description                                                                |
| ----------------- | -------------------------------------------------------------------------- |
| `--url <url>`     | URL of the running Flowlib API (default: `http://localhost:3000/flowlib`). |
| `--api-key <key>` | API key for authenticated access.                                          |
| `--print-config`  | Output ready-to-paste MCP client config (e.g., for Claude Desktop).        |

**Example: generate config for Claude Desktop**

```bash
npx flowlib-cli mcp --print-config
```

***

## Common workflows [#common-workflows]

### Initial setup [#initial-setup]

```bash
npx flowlib-cli init
```

### After adding a plugin with database tables [#after-adding-a-plugin-with-database-tables]

```bash
npx flowlib-cli generate
npx flowlib-cli migrate --push
```

### Production database migration [#production-database-migration]

```bash
npx flowlib-cli generate
npx flowlib-cli migrate
```

### Generate encryption key [#generate-encryption-key]

```bash
npx flowlib-cli secret
```
