Windmill CLI
The Windmill CLI (`wmill`) is a command-line interface tool designed for direct interaction with Windmill instances, an open-source platform for building and running workflows and internal tools. It provides comprehensive capabilities for managing Windmill workspaces, including adding and switching between them, and syncing resources like scripts and flows. Developers can use `wmill` to run scripts and flows, passing inputs via JSON or files, and stream execution logs directly in the terminal. The CLI supports pushing and pulling entire workspaces or individual resources, with an upcoming default shift to YAML for synchronization. As of version 1.688.0, the package demonstrates a rapid release cadence, with frequent updates incorporating new features and bug fixes, often multiple times per week, indicating active development and continuous improvement. It also offers user management features and shell autocompletion for various shells like Bash, Fish, and Zsh.
Common errors
-
wmill: command not found
cause The `windmill-cli` package was not installed globally, or the global npm bin directory is not included in your system's PATH environment variable.fixEnsure `windmill-cli` is installed globally using `npm install -g windmill-cli` (or `pnpm add -g windmill-cli`, `yarn global add windmill-cli`). Verify your system's PATH configuration to include npm's global executable directory. -
Error: Failed to connect to Windmill instance. Check your API token and endpoint.
cause The CLI was unable to establish a connection or authenticate with the configured Windmill instance, typically due to incorrect endpoint URL, an expired API token, or network issues.fixRun `wmill workspace add` to create a new workspace configuration, providing the correct Windmill API endpoint and a valid API token. If a workspace is already configured, use `wmill workspace switch <name>` to ensure the active workspace settings are correct. -
Error: Invalid JSON input for --data. Expected valid JSON string or @<filename>.
cause The `--data` argument provided to a `wmill flow run` or `wmill script run` command contained malformed JSON, or the specified file (`@<filename>`) does not exist or contain valid JSON.fixVerify that the JSON string passed directly is syntactically correct and properly escaped. If using a file, ensure the file path is correct and its content is valid JSON. For reading from stdin, use `-d @-`. -
Error: PostgreSQL connection failed
cause When attempting to run local tests for `windmill-cli`, a PostgreSQL database instance is either not running or the `DATABASE_URL` environment variable is not correctly configured.fixEnsure a local PostgreSQL database is running (default connection string `postgres://postgres:changeme@localhost:5432`). Alternatively, set the `DATABASE_URL` environment variable to point to your PostgreSQL instance before executing test commands like `bun test test/`.
Warnings
- gotcha The `wmill sync push` and `wmill sync pull` commands will soon default to YAML format for resource synchronization, instead of JSON. Users currently relying on JSON output or input should be aware of this impending change.
- gotcha Customizing AI guidance bundles (e.g., for `wmill init`) currently relies on setting specific internal environment variables like `WMILL_INIT_AI_SKILLS_SOURCE`. This approach might be considered an internal interface and is subject to change without public API warnings.
- gotcha The Windmill CLI maintains a very rapid release cadence, often deploying multiple new versions (features and bug fixes) within days. This frequent update cycle, while beneficial for new features, can introduce minor behavioral changes not explicitly highlighted as 'breaking' in release notes.
Install
-
npm install windmill-cli -
yarn add windmill-cli -
pnpm add windmill-cli
Imports
- wmill
import { wmill } from 'windmill-cli'wmill <command>
- wmill workspace add
import { workspace } from 'windmill-cli'; workspace.add();wmill workspace add
- wmill script run
import { runScript } from 'windmill-cli'; runScript('u/username/path/to/script', { input: 'value' });wmill script run u/username/path/to/script --data '{"input": "value"}'
Quickstart
npm install -g windmill-cli
# Add a new workspace configuration (follow interactive prompts)
wmill workspace add
# Example: Running a simple script (replace 'u/your_user/hello_world' with an actual script path)
# Ensure 'hello_world' exists in your Windmill instance.
wmill script run u/your_user/hello_world --data '{"name": "Registry Expert"}'
# Alternatively, pass data from a file:
echo '{"greeting": "Hello from Registry!"}' > script-inputs.json
wmill script run u/your_user/another_script --data @script-inputs.json
# Synchronize and pull all workspace resources to your local directory in YAML format
wmill sync pull --yaml