CLI Reference
CLI Reference
The blixt CLI scaffolds projects, generates code, runs the development server, and manages database migrations.
blixt <COMMAND>
blixt new
Create a new Blixt project.
blixt new <NAME> [--db <BACKEND>] [--auth]
| Argument | Required | Description |
|---|---|---|
NAME | yes | Project name (used as directory name and crate name) |
--db <BACKEND> | no | Database backend: postgres (alias pg) or sqlite. Prompts interactively if omitted. |
--auth | no | Include authentication scaffold (users, sessions, login/register/password reset) |
The command creates a full project directory with:
Cargo.tomlconfigured with the chosen database featuresrc/with controllers, models, and route setuptemplates/with layouts, pages, fragments, components, and email directoriesmigrations/directorystatic/with CSS and Datastar JS.envfile with development defaults
Examples:
blixt new my_app --db postgres
blixt new blog --db sqlite
blixt new my_app --auth # includes auth scaffold with routes pre-wired
blixt new my_app # interactive database prompt
If no TTY is detected (e.g. CI), the --db flag is required.
blixt dev
Start the development server with file watching and Tailwind CSS hot reload.
blixt dev
This command:
- Verifies you are in a Blixt project directory (checks for
Cargo.toml) - Downloads the Tailwind CSS binary if not already present
- Starts Tailwind in watch mode for live CSS recompilation
- Starts
cargo runfor the application - Watches for file changes in
src/andtemplates/and restarts the application automatically
When the application exits with a non-zero status, the dev server waits for file changes before restarting. Press Ctrl+C to shut down.
blixt build
Build the project for production deployment.
blixt build
This command:
- Verifies you are in a Blixt project directory
- Compiles Tailwind CSS with
--minify - Runs
cargo build --release - Reports the output binary path and file size
blixt generate
Generate scaffolding code. All generators validate the name argument against Rust reserved keywords and naming rules.
blixt generate controller
Generate a controller with Askama template views.
blixt generate controller <NAME>
Creates:
src/controllers/<name>.rswith index and show handler functionstemplates/pages/<name>/index.htmltemplatetemplates/pages/<name>/show.htmltemplate- Updates
src/controllers/mod.rsto include the new module
After generation, the CLI prints a route hint showing how to wire the controller into your router.
Example:
blixt generate controller posts
blixt generate model
Generate a model with a database migration.
blixt generate model <NAME> [FIELDS...]
Fields use name:type format. Supported types:
| Type | Aliases | Rust type | PostgreSQL | SQLite |
|---|---|---|---|---|
string | text | String | TEXT NOT NULL | TEXT NOT NULL |
int | integer | i64 | BIGINT NOT NULL DEFAULT 0 | INTEGER NOT NULL DEFAULT 0 |
bool | boolean | bool | BOOLEAN NOT NULL DEFAULT FALSE | BOOLEAN NOT NULL DEFAULT 0 |
float | f64 | DOUBLE PRECISION NOT NULL DEFAULT 0 | REAL NOT NULL DEFAULT 0 |
Creates:
src/models/<name>.rswith a struct derivingFromRowandSerialize- A timestamped SQL migration file in
migrations/ - Updates
src/models/mod.rsto include the new module
The id, created_at, and updated_at fields are generated automatically and cannot be specified manually. SQL reserved words and Rust keywords are rejected as field names.
Examples:
blixt generate model post title:string body:text published:bool
blixt generate model product name:string price:float active:boolean
blixt generate scaffold
Generate a full CRUD scaffold: controller, model, views, and list fragment.
blixt generate scaffold <NAME> [FIELDS...]
Combines controller and model generation, then adds a Datastar-ready list fragment template for streaming updates. Field syntax is the same as blixt generate model.
If no fields are specified, a single name:string field is created by default.
Examples:
blixt generate scaffold task title:string priority:int completed:bool
blixt generate scaffold item # defaults to name:string
blixt generate auth
Generate a complete authentication scaffold.
blixt generate auth
Creates:
migrations/*_create_users.sqlwith email, password_hash, role, reset token columnsmigrations/*_create_sessions.sqlwith token_hash and expirysrc/models/user.rswith registration, login, password reset methodssrc/models/session.rswith create, revoke, cleanup methodssrc/controllers/auth.rswith 9 handlers (register, login, logout, forgot/reset password)templates/pages/auth/with register, login, forgot password, reset password pagestemplates/emails/reset_password.htmlfor password reset emails- Updates
src/models/mod.rsandsrc/controllers/mod.rs
After generation, the CLI prints the routes to add to your src/main.rs.
Password reset emails are sent via the Mailer when SMTP is configured. Without SMTP variables, reset links are logged to stdout for local development.
Example:
blixt generate auth
blixt generate docker
Generate Docker deployment files.
blixt generate docker
Creates:
Dockerfile— multi-stage build withcargo-cheffor dependency caching, Tailwind CSS compilation, and a minimaldebian:bookworm-slimruntime imagedocker-compose.yml— app service with health check, PostgreSQL 17, and optional Redis 7.dockerignore— excludestarget/,.git/,.envfiles (keeps.env.example)
The command auto-detects Redis usage from your Cargo.toml features or .env.example:
$ blixt generate docker
detected PostgreSQL database
detected Redis cache
created Dockerfile
created docker-compose.yml
created .dockerignore
Fails if any of the files already exist — delete them first to regenerate.
blixt db
Database migration commands. All subcommands read DATABASE_URL from the environment (or .env file) and connect using SQLx's AnyPool, which supports both PostgreSQL and SQLite URLs.
blixt db migrate
Run all pending migrations.
blixt db migrate
Applies every unapplied migration from the ./migrations directory in order. Reports the number of migrations applied.
blixt db rollback
Revert the most recently applied migration.
blixt db rollback
Rolls back exactly one migration. Run multiple times to revert further.
blixt db status
Display a table of all migrations and their applied/pending status.
blixt db status
Output shows each migration's version number, status (applied or pending), and description.
Field type reference
When specifying fields for generate model and generate scaffold, use these types:
title:string # or title:text
count:int # or count:integer
active:bool # or active:boolean
score:float
Validation rules:
- Field names must be valid Rust identifiers in
snake_case - Reserved names (
id,created_at,updated_at) are rejected - SQL reserved words (
select,order,table,index, etc.) are rejected - Rust keywords (
type,fn,struct, etc.) are rejected - Duplicate field names within a single command are rejected