All Commands
The stew CLI provides all the commands necessary for development, compilation, code generation, and project maintenance.
Full Reference
stew init [module-name]
Initializes a new Stew project in the current folder. Creates all necessary scaffolding.
Actions: Runs go mod init, generates .stew.yaml, main.go, .gitignore, pages/ directory, copies wasm_exec.js, and runs stew install + stew compile + stew generate + go mod tidy.
stew compile [--watch / -w]
Recursively compiles all .stew files in the project into Go files. It also generates Wasm binaries for pages containing a <goscript client> block. All generated files are tracked in .stew/compiled.json.
Output: stew.page.go, stew.layout.go, Component.go, static/wasm/*.wasm.
Watch: In --watch mode, it monitors .stew file changes and recompiles automatically (100ms debounce). Deleted files will trigger the removal of their corresponding generated Go files.
stew generate [--watch / -w]
Analyzes the pages/ directory and regenerates stew_router_gen.go. This must be rerun after creating or deleting any page or layout.
Watch: Monitors the pages/ directory for Go file additions or removals.
stew run
Executes a custom script defined in the commands section of .stew.yaml. Automatically loads environment variables from env_files.
dev: Runs stew compile --watch, stew generate --watch, and air in parallel with colorized logs.
build: Sequentially runs compile → generate → go build.
stew clean
Cleans up all generated files in two phases:
- Phase 1: Reads
.stew/compiled.jsonand deletes exactly the tracked files (compiled Go files +.wasm). It then removes the.stew/directory. - Phase 2: Applies the patterns defined in the
clean:section of.stew.yaml.
stew install
Installs Go dependencies defined in the requires: section of .stew.yaml using go install. Skips if already installed.
stew check
Verifies that all dependencies declared in requires: are installed and available in the system $PATH.
stew env
Displays all environment variables loaded from the env_files specified in .stew.yaml.
stew exec --
Executes a one-off command with environment variables from .stew.yaml pre-loaded.
Example: stew exec -- go run . -port 9090
stew version
Displays the currently installed version of the Stew CLI.