Commands
Complete reference for Velocity CLI commands. Learn how to create projects, run development servers, generate code, and manage database migrations.
Complete reference for all Velocity CLI commands.
Global Commands (velocity)
These commands are available globally after installing via Homebrew.
velocity new
Create a new Velocity project with full scaffolding.
velocity new <project-name> [flags]Arguments:
project-name- Name of the project directory to create
Flags:
| Flag | Default | Description |
|---|---|---|
--database | sqlite | Database driver: postgres, sqlite |
--cache | memory | Cache driver: redis, memory |
--api | false | Create an API-only project (no frontend) |
Examples:
# Create a basic project (SQLite by default)
velocity new myapp
# Create with PostgreSQL and Redis
velocity new myapp --database postgres --cache redis
# Create an API-only project
velocity new myapi --api
# API project with PostgreSQL
velocity new myapi --api --database postgresAfter creation, the CLI:
- Scaffolds the project
- Installs Go dependencies (and JS dependencies for full-stack projects)
- Runs database migrations
- Builds the
./velbinary - Starts development servers (Go on :4000, Vite on :5173 for full-stack)
API-Only Projects
Use the --api flag to create a lightweight API server without frontend dependencies:
velocity new myapi --apiWhat’s different:
- No Vite, Tailwind, or React
- No CSRF protection (stateless API)
- JSON-only responses
- API-focused middleware (returns 401 JSON instead of redirects)
- Uses
AUTH_GUARD=apiby default
Template endpoints:
| Method | Endpoint | Auth | Description |
|---|---|---|---|
| GET | /api/health | No | Health check |
| POST | /api/users | No | Create user |
| GET | /api/users | Yes | List users |
| GET | /api/users/:id | Yes | Get user |
| GET | /api/me | Yes | Current user |
Project structure:
myapi/
├── routes/api.go # API route definitions
├── internal/handlers/ # JSON handlers
├── internal/middleware/ # API middleware (auth returns JSON 401)
└── internal/models/ # Database modelsvelocity config
Manage CLI configuration. See Configuration for details.
velocity config set <key> <value>
velocity config get <key>
velocity config list
velocity config resetvelocity self-update
Update the velocity installer to the latest version.
velocity self-updateProject Commands (vel)
These commands run from within a Velocity project using ./vel or vel (with shell function).
vel serve
Start the development server with hot reload.
vel serve [flags]Flags:
| Flag | Short | Default | Description |
|---|---|---|---|
--port | -p | 4000 | Port to run the server on |
--env | -e | development | Environment mode |
--watch | -w | true | Enable hot reload |
--tags | Build tags to pass to go build |
Examples:
# Start with defaults (port 4000, hot reload enabled)
vel serve
# Custom port
vel serve --port 3000
# Production environment, no hot reload
vel serve --env production --watch=falseWhat happens:
- Starts Vite dev server (if
package.jsonexists) - Builds your Go application to
.vel/tmp/server - Watches all
.gofiles for changes - Automatically rebuilds and restarts on file changes
vel build
Build the application for production deployment.
vel build [flags]Flags:
| Flag | Short | Default | Description |
|---|---|---|---|
--output | -o | ./dist/app | Output path for binary |
--os | (current OS) | Target operating system | |
--arch | (current arch) | Target architecture | |
--optimize | true | Enable optimizations | |
--version | Version to embed in binary |
Examples:
# Default build
vel build
# Custom output path
vel build --output ./bin/myapp
# Cross-compile for Linux
vel build --os linux --arch amd64vel migrate
Run all pending database migrations.
vel migrateRequirements:
- Must be run from project root
- Database connection configured in
.env
Example output:
MIGRATE
✓ 20240115000001_create_users_table
✓ 20240115000002_create_posts_table
Donevel migrate:fresh
Drop all database tables and re-run all migrations from scratch.
vel migrate:freshvel make:handler
Generate a new HTTP handler.
vel make:handler <name> [flags]Arguments:
name- Handler name (automatically converts to snake_case)
Flags:
| Flag | Default | Description |
|---|---|---|
--resource | false | Generate CRUD methods |
--api | false | Generate API handler (JSON responses) |
Examples:
# Basic handler
vel make:handler User
# Resource handler with CRUD methods
vel make:handler Post --resource
# API handler
vel make:handler Product --api --resourceGenerated file: internal/handlers/<name>.go
vel key:generate
Generate a new 32-byte encryption key for your application.
vel key:generate [flags]Flags:
| Flag | Default | Description |
|---|---|---|
--show | false | Only display the key, don’t update .env |
Examples:
# Generate and save to .env
vel key:generate
# Just display the key
vel key:generate --showThe key is saved to the CRYPTO_KEY variable in your .env file.
