Skip to main content

CLI Reference

forge new

Create a new project.

forge new [project-name] --demo|--minimal [options]
OptionDescription
--demoFull demo project with User CRUD, jobs, crons, workflows, webhooks
--minimalClean scaffolding with empty directories and commented examples
--output, -o <dir>Output directory (defaults to project name)
--no-lockSkip generating bun.lock before initial commit

One of --demo or --minimal is required.

# Demo project with working examples
forge new my-app --demo

# Clean slate for experienced developers
forge new my-app --minimal

# Custom output directory
forge new my-app --demo --output /path/to/projects/my-app

forge dev

Start the development environment.

forge dev [action] [options]
OptionDescription
--dockerRun with Docker Compose instead of cargo/bun
--no-openSkip automatic browser open

Actions

ActionDescription
(none)Start backend + frontend + embedded PostgreSQL
downStop the development environment
down --clearStop and remove target/ and pg_data/ directories
# Start development (embedded postgres, hot reload)
forge dev

# Start without opening browser
forge dev --no-open

# Run with Docker Compose
forge dev --docker

# Stop environment
forge dev down

# Stop and clean build artifacts
forge dev down --clear

Services

When running, the following services are available:

ServiceURL
Frontendhttp://localhost:5173
Backendhttp://localhost:8080

Requirements (bare metal)

ToolMinimum Version
cargo1.92+
cargo-watchany
bun1.3+

forge check

Validate project configuration and dependencies.

forge check [options]
OptionDescription
--config, -c <path>Path to forge.toml (default: ./forge.toml)
--no-dbSkip database connectivity check

Checks Performed

  • forge.toml validity and required sections
  • Cargo.toml and forge dependency
  • Directory structure (src/, src/schema/, src/functions/, migrations/)
  • Migration file naming and -- @up markers
  • Function files with forge macros
  • Schema files with #[forge::model]
  • Rust linting (cargo fmt, clippy)
  • Environment variables and DATABASE_URL
  • Database connectivity
  • Frontend configuration (if present)
  • Frontend linting (ESLint, Prettier)
# Full project check
forge check

# Skip database check (offline validation)
forge check --no-db

# Custom config location
forge check --config ./config/forge.toml

forge add

Add a new component to the project.

forge add [component] [name]

Components

ComponentDescriptionOutput File
modelDatabase model with #[forge::model]src/schema/[name].rs
queryRead-only query functionsrc/functions/[name].rs
mutationWrite operation functionsrc/functions/[name].rs
jobBackground job with retry logicsrc/functions/[name]_job.rs
cronScheduled tasksrc/functions/[name]_cron.rs
workflowMulti-step durable workflowsrc/functions/[name]_workflow.rs

Names are normalized: UserProfile becomes user_profile (snake_case for files/functions) and UserProfile (PascalCase for structs).

# Add a model
forge add model User

# Add a query
forge add query get_active_users

# Add a mutation
forge add mutation create_order

# Add a background job
forge add job send_email

# Add a scheduled task
forge add cron cleanup_expired

# Add a workflow
forge add workflow user_onboarding

forge generate

Generate TypeScript client code from Rust schema.

forge generate [options]
OptionDescription
--forceForce regeneration even if files exist
--output, -o <dir>Output directory (default: frontend/src/lib/forge)
--src, -s <dir>Source directory to scan (default: src)
--skip-runtimeOnly regenerate types, skip runtime update
--yes, -yAuto-accept prompts (useful for CI)

Generated Files

FileDescription
types.tsTypeScript interfaces from Rust models
api.tsFunction bindings (queries, mutations)
stores.tsSvelte store exports
runes.svelte.tsSvelte 5 runes helpers
index.tsRe-exports all modules
.forge/svelte/Runtime package (@forge/svelte)
# Generate all TypeScript code
forge generate

# Force regenerate everything
forge generate --force

# Only update types (keep runtime)
forge generate --skip-runtime

# CI mode (no prompts)
forge generate -y

# Custom directories
forge generate --src ./backend/src --output ./web/src/lib/forge

forge migrate

Manage database migrations.

forge migrate [action] [options]
OptionDescription
--config, -c <path>Configuration file path (default: forge.toml)
--migrations-dir, -m <dir>Migrations directory (default: migrations)

Actions

ActionDescription
upRun all pending migrations
down [count]Rollback the last N migrations (default: 1)
statusShow migration status
# Run pending migrations
forge migrate up

# Rollback last migration
forge migrate down

# Rollback last 3 migrations
forge migrate down 3

# Check migration status
forge migrate status

# Use custom paths
forge migrate up --config ./config/forge.toml --migrations-dir ./db/migrations

Migration File Format

Migration files must be named NNNN_name.sql (e.g., 0001_initial.sql) and contain -- @up marker.

-- @up
CREATE TABLE users (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
email TEXT UNIQUE NOT NULL,
created_at TIMESTAMPTZ DEFAULT now()
);

-- @down
DROP TABLE users;

Environment Variables

VariableDescriptionUsed By
DATABASE_URLPostgreSQL connection stringAll commands
RUST_LOGLog level (e.g., info, debug, trace)forge dev
HOSTBackend host (default: 0.0.0.0)forge dev
PORTBackend port (default: 8080)forge dev

Exit Codes

CodeDescription
0Success
1Error (configuration, validation, or runtime failure)