Skip to content

CLI Reference

The Cloudwerk CLI provides commands for development, building, and deployment.

The CLI is included with @cloudwerk/cli:

Terminal window
pnpm add -D @cloudwerk/cli

Start the development server with hot reload.

Terminal window
cloudwerk dev [options]

Options:

OptionDescriptionDefault
--port, -pPort number8787
--hostHost to bindlocalhost
--httpsEnable HTTPSfalse
--open, -oOpen browserfalse

Examples:

Terminal window
# Start dev server
cloudwerk dev
# Custom port
cloudwerk dev --port 3000
# Open browser
cloudwerk dev --open
# All interfaces
cloudwerk dev --host 0.0.0.0

Build the application for production.

Terminal window
cloudwerk build [options]

Options:

OptionDescriptionDefault
--sourcemapGenerate sourcemapstrue
--minifyMinify outputtrue
--analyzeBundle analysisfalse

Examples:

Terminal window
# Production build
cloudwerk build
# With bundle analysis
cloudwerk build --analyze
# Development build
cloudwerk build --no-minify

Deploy to Cloudflare Workers.

Terminal window
cloudwerk deploy [options]

Options:

OptionDescriptionDefault
--env, -eEnvironmentproduction
--dry-runPreview without deployingfalse

Examples:

Terminal window
# Deploy to production
cloudwerk deploy
# Deploy to staging
cloudwerk deploy --env staging
# Preview deployment
cloudwerk deploy --dry-run

Generate boilerplate files.

Terminal window
cloudwerk generate <type> <name> [options]

Types:

TypeDescription
pageCreate a new page
layoutCreate a new layout
routeCreate an API route
middlewareCreate middleware
componentCreate a component

Examples:

Terminal window
# Generate a page
cloudwerk generate page users/profile
# Generate an API route
cloudwerk generate route api/users
# Generate middleware
cloudwerk generate middleware auth
# Generate with loader
cloudwerk generate page products --loader

Run database migrations.

Terminal window
cloudwerk migrate <command> [options]

Commands:

CommandDescription
create <name>Create new migration
upRun pending migrations
downRollback last migration
statusShow migration status
resetReset all migrations

Options:

OptionDescriptionDefault
--localApply to local DBtrue
--remoteApply to remote DBfalse

Examples:

Terminal window
# Create migration
cloudwerk migrate create add_users_table
# Run local migrations
cloudwerk migrate up
# Run remote migrations
cloudwerk migrate up --remote
# Check status
cloudwerk migrate status
# Rollback
cloudwerk migrate down

Display route information.

Terminal window
cloudwerk routes [options]

Options:

OptionDescription
--jsonOutput as JSON
--verboseShow detailed info

Examples:

Terminal window
# List all routes
cloudwerk routes
# JSON output
cloudwerk routes --json
# Detailed info
cloudwerk routes --verbose

Output:

Routes:
GET / app/page.tsx
GET /about app/about/page.tsx
GET /users app/users/page.tsx
GET /users/:id app/users/[id]/page.tsx
GET /api/health app/api/health/route.ts
POST /api/users app/api/users/route.ts
GET /api/users/:id app/api/users/[id]/route.ts
PUT /api/users/:id app/api/users/[id]/route.ts
DELETE /api/users/:id app/api/users/[id]/route.ts

Run TypeScript type checking.

Terminal window
cloudwerk typecheck [options]

Options:

OptionDescription
--watchWatch mode
--strictStrict mode

Examples:

Terminal window
# Type check
cloudwerk typecheck
# Watch mode
cloudwerk typecheck --watch

Run ESLint on the codebase.

Terminal window
cloudwerk lint [options]

Options:

OptionDescription
--fixAuto-fix issues
--formatOutput format

Examples:

Terminal window
# Check for issues
cloudwerk lint
# Auto-fix
cloudwerk lint --fix

Run tests.

Terminal window
cloudwerk test [options] [files]

Options:

OptionDescription
--watchWatch mode
--coverageCoverage report
--uiOpen Vitest UI

Examples:

Terminal window
# Run all tests
cloudwerk test
# Watch mode
cloudwerk test --watch
# Specific file
cloudwerk test app/users/page.test.ts
# Coverage
cloudwerk test --coverage

These options work with all commands:

OptionDescription
--config, -cConfig file path
--help, -hShow help
--version, -vShow version
--verboseVerbose output
--quiet, -qMinimal output

Commands read from cloudwerk.config.ts by default. Override with --config:

Terminal window
cloudwerk dev --config cloudwerk.production.ts
CodeDescription
0Success
1General error
2Configuration error
3Build error
4Deployment error