brick.ts

brick CLI Overview

Command-line developer and build tooling for Brick-TS applications.

llms.txt

The brick CLI ships with @brickkit/cli to provide development live reload, production servers, ahead-of-time compilation, and code generation tooling.

Installation

Install @brickkit/cli alongside @brickkit/core:

bun add @brickkit/cli @brickkit/core

Run commands with bunx brick or add them to your package.json scripts:

package.json
{
  "scripts": {
    "dev": "brick dev src/server.ts --port 4000",
    "start": "brick start src/server.ts",
    "build": "brick build src/server.ts --outdir dist/brick",
    "gen:openapi": "brick gen openapi src/server.ts --output openapi.json",
    "gen:client": "brick gen client src/server.ts --output src/_brick/contract.ts",
    "info": "brick info src/server.ts"
  }
}

Command Summary

CommandArguments & FlagsDescription
brick dev[entry] [--port <number>] [--dashboard-port <number>] [--history-days <number>] [--no-dashboard] [--client <file>] [--frontend <command>]Start local development server with file watching, live reload, and a local dashboard.
brick start[entry] [--port <number>]Start production server without file watchers.
brick build<entry> [--outdir <dir>] [--port <number>] [--no-aot]Compile a default-exported BrickApp into a standalone Bun server bundle.
brick gen openapi<entry> [--output <file>]Generate OpenAPI 3.1 JSON specification from services.
brick gen client<entry> [--output <file>]Generate typed browser client contract file (_brick/contract.ts).
brick gen manifest[--config <path>]Write _brick/services.gen.ts, which imports every definition file.
brick db generate[entry] [--out <dir>] [--name <name>]Write a SQL migration for every database's schema changes (Database Schema).
brick db migrate[entry] [--out <dir>]Apply the migrations that have not run yet.
brick db push[entry] [--force]Change a development database to match the schema, without migration files.
brick schedules[entry] [--run <name>]List the app's schedules with their next run, or make one due now.
brick lint[entry] [--config <path>]Check the project against the Brick lint file and app rules.
brick info / brick services<entry>Export the complete runtime architecture JSON schema (ArchitectureSchema).

Every command takes --config <path>. With a brick.config.ts, the entry and most flags come from the config file, so the scripts become brick dev, brick build, brick gen and brick lint.

Port Resolution Rules

For dev and start, the listening port is resolved in strict precedence order:

  1. CLI Flag: --port <number> (e.g. brick dev --port 5000)
  2. Environment Variable: PORT (e.g. PORT=3000 brick dev)
  3. Config file: dev.port in brick.config.ts (brick dev only)
  4. Default: 4000

Port values must be valid integers between 1 and 65535. Out-of-range values or non-numeric strings cause the CLI to exit immediately with an error.

To generate contracts before frontend startup, see coordinated development. For typed query and mutation options, see TanStack Query.