CLI Reference
The Cloudwerk CLI provides commands for development, building, and deployment.
Installation
Section titled “Installation”The CLI is included with @cloudwerk/cli:
pnpm add -D @cloudwerk/cliCommands
Section titled “Commands”cloudwerk dev
Section titled “cloudwerk dev”Start the development server with hot reload.
cloudwerk dev [options]Options:
| Option | Description | Default |
|---|---|---|
--port, -p | Port number | 8787 |
--host | Host to bind | localhost |
--https | Enable HTTPS | false |
--open, -o | Open browser | false |
Examples:
# Start dev servercloudwerk dev
# Custom portcloudwerk dev --port 3000
# Open browsercloudwerk dev --open
# All interfacescloudwerk dev --host 0.0.0.0cloudwerk build
Section titled “cloudwerk build”Build the application for production.
cloudwerk build [options]Options:
| Option | Description | Default |
|---|---|---|
--sourcemap | Generate sourcemaps | true |
--minify | Minify output | true |
--analyze | Bundle analysis | false |
Examples:
# Production buildcloudwerk build
# With bundle analysiscloudwerk build --analyze
# Development buildcloudwerk build --no-minifycloudwerk deploy
Section titled “cloudwerk deploy”Deploy to Cloudflare Workers.
cloudwerk deploy [options]Options:
| Option | Description | Default |
|---|---|---|
--env, -e | Environment | production |
--dry-run | Preview without deploying | false |
Examples:
# Deploy to productioncloudwerk deploy
# Deploy to stagingcloudwerk deploy --env staging
# Preview deploymentcloudwerk deploy --dry-runcloudwerk generate
Section titled “cloudwerk generate”Generate boilerplate files.
cloudwerk generate <type> <name> [options]Types:
| Type | Description |
|---|---|
page | Create a new page |
layout | Create a new layout |
route | Create an API route |
middleware | Create middleware |
component | Create a component |
Examples:
# Generate a pagecloudwerk generate page users/profile
# Generate an API routecloudwerk generate route api/users
# Generate middlewarecloudwerk generate middleware auth
# Generate with loadercloudwerk generate page products --loadercloudwerk migrate
Section titled “cloudwerk migrate”Run database migrations.
cloudwerk migrate <command> [options]Commands:
| Command | Description |
|---|---|
create <name> | Create new migration |
up | Run pending migrations |
down | Rollback last migration |
status | Show migration status |
reset | Reset all migrations |
Options:
| Option | Description | Default |
|---|---|---|
--local | Apply to local DB | true |
--remote | Apply to remote DB | false |
Examples:
# Create migrationcloudwerk migrate create add_users_table
# Run local migrationscloudwerk migrate up
# Run remote migrationscloudwerk migrate up --remote
# Check statuscloudwerk migrate status
# Rollbackcloudwerk migrate downcloudwerk routes
Section titled “cloudwerk routes”Display route information.
cloudwerk routes [options]Options:
| Option | Description |
|---|---|
--json | Output as JSON |
--verbose | Show detailed info |
Examples:
# List all routescloudwerk routes
# JSON outputcloudwerk routes --json
# Detailed infocloudwerk routes --verboseOutput:
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.tscloudwerk typecheck
Section titled “cloudwerk typecheck”Run TypeScript type checking.
cloudwerk typecheck [options]Options:
| Option | Description |
|---|---|
--watch | Watch mode |
--strict | Strict mode |
Examples:
# Type checkcloudwerk typecheck
# Watch modecloudwerk typecheck --watchcloudwerk lint
Section titled “cloudwerk lint”Run ESLint on the codebase.
cloudwerk lint [options]Options:
| Option | Description |
|---|---|
--fix | Auto-fix issues |
--format | Output format |
Examples:
# Check for issuescloudwerk lint
# Auto-fixcloudwerk lint --fixcloudwerk test
Section titled “cloudwerk test”Run tests.
cloudwerk test [options] [files]Options:
| Option | Description |
|---|---|
--watch | Watch mode |
--coverage | Coverage report |
--ui | Open Vitest UI |
Examples:
# Run all testscloudwerk test
# Watch modecloudwerk test --watch
# Specific filecloudwerk test app/users/page.test.ts
# Coveragecloudwerk test --coverageGlobal Options
Section titled “Global Options”These options work with all commands:
| Option | Description |
|---|---|
--config, -c | Config file path |
--help, -h | Show help |
--version, -v | Show version |
--verbose | Verbose output |
--quiet, -q | Minimal output |
Configuration
Section titled “Configuration”Commands read from cloudwerk.config.ts by default. Override with --config:
cloudwerk dev --config cloudwerk.production.tsExit Codes
Section titled “Exit Codes”| Code | Description |
|---|---|
0 | Success |
1 | General error |
2 | Configuration error |
3 | Build error |
4 | Deployment error |
Next Steps
Section titled “Next Steps”- Configuration - Config file options
- Deployment Guide - Deploy your app
- Testing - Testing utilities