write-script-rust

Writes Windmill Rust scripts with cargo dependencies, typed main functions, and CLI preview commands.

Updated May 28, 2026
One-click install
npx skills add https://github.com/kma-core/windmill --skill write-script-rust-kma-core
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: write-script-rust
Source: https://github.com/kma-core/windmill/tree/main/system_prompts/auto-generated/skills/write-script-rust
Command: npx skills add https://github.com/kma-core/windmill --skill write-script-rust-kma-core

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Writing Rust scripts for Windmill requires knowing the platform's specific conventions: a typed main function, inline cargo dependency blocks, serializable return types, and the correct wmill CLI commands for previewing versus deploying. This Skill encodes those rules so generated scripts compile and run correctly on the first attempt. ## Core Features & Use Cases - Rust Script Structure: Enforces the required main function signature with owned argument types, anyhow::Result<T> returns, and #[derive(Serialize)] output structs. - Dependency Management: Shows how to declare crates via an inline partial cargo.toml block, including async setups with tokio and reqwest. - CLI Workflow Guidance: Distinguishes wmill script preview for local iteration from wmill script run and wmill sync push for deployed versions, preventing accidental deploys during testing. - Use Case: A developer asks for a script that fetches JSON from an API. The Skill produces a Rust script with the correct cargo header, a sync main wrapping a tokio runtime, and then runs wmill script preview with sample arguments to validate it. ## Quick Start Write a Windmill Rust script that fetches a URL and returns the response body, then preview it locally with sample arguments.

Frequently Asked Questions about write-script-rust

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write a Rust script for Windmill?

Define a function called main with owned argument types that returns anyhow::Result<T>, where T derives Serialize. Declare dependencies in an inline cargo block at the top of the file, then test locally with wmill script preview.

How do I add dependencies to a Windmill Rust script?

Add a partial cargo.toml block at the top of the script using doc-comment lines starting with //!. List crates under [dependencies], for example reqwest or tokio. Serde is already included and does not need to be declared.

Can I use async code like tokio in a Windmill Rust script?

Yes, but the main function must stay synchronous. Create a tokio runtime inside main with tokio::runtime::Runtime::new() and use block_on to execute the async code, such as reqwest HTTP calls.

What is the difference between wmill script preview and script run?

wmill script preview executes the local script file without deploying, which is the default for iterating on edits. wmill script run executes the version already deployed in the workspace and should only be used when no local changes exist.

Why does my Windmill Rust script fail to return a value?

The return type must be wrapped in anyhow::Result and the inner type must derive Serialize so Windmill can serialize the output. Returning a non-serializable type or a plain value instead of Result causes failures.