write-script-rust_skill

This skill guides you in writing Rust scripts with a serializable return type and proper main signature for Windmill automation.
  • HTML

15.8k

GitHub Stars

1

Bundled Files

2 months ago

Catalog Refreshed

4 months ago

First Indexed

Readme & install

Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.

Installation

Preview and clipboard use veilstrat where the catalogue uses aiagentskills.

npx veilstrat add skill windmill-labs/windmill --skill write-script-rust

  • SKILL.md1.9 KB

Overview

This skill provides a clear, opinionated template and checklist for writing Rust scripts that run on the platform. It enforces the required function signature, serialization rules, dependency embedding, and patterns for mixing sync and async code. Use it to produce scripts that deploy cleanly and interoperate with the runtime and resource tooling.

How this skill works

It inspects your script for a main function with owned argument types and a return of anyhow::Result<T> where T implements serde::Serialize. It requires a partial Cargo manifest embedded as a code fence at the top of the file so the runtime knows which crates to compile. For async work, it recommends creating a tokio runtime inside a synchronous main so the script stays compatible with the platform.

When to use it

  • When authoring any Rust script intended for deployment to the platform
  • When returning structured data that must be serialized for downstream steps or UI
  • When your code needs external crates—declare them in the embedded cargo block
  • When you need to call async APIs from a script but keep the main function sync
  • When preparing scripts for automated metadata generation and deployment

Best practices

  • Declare arguments as owned types (e.g., String, i32) to avoid lifetime issues
  • Return anyhow::Result<T> where T derives serde::Serialize for consistent serialization
  • Place a partial cargo.toml block at the top using the provided code-fence format
  • Keep the top-level main function synchronous; spawn a tokio runtime for async calls
  • Avoid re-declaring serde in dependencies; it is already provided by the platform

Example use cases

  • Return structured results from a data-transform script that populates a UI table
  • Call an external REST API in an async block and return the response as a serializable struct
  • Write a script that queries a PostgreSQL resource and returns aggregated counts
  • Create small automation hooks that accept input parameters, run logic, and return JSON-ready results
  • Bundle third-party crates by listing them in the embedded cargo section before the code

FAQ

main must accept owned arguments and return anyhow::Result<T>, where T derives serde::Serialize.

How do I use async code in a script?

Keep main synchronous and create a tokio runtime inside it, then block_on your async work.

Where do I declare dependencies?

Embed a partial [dependencies] Cargo manifest at the top of the script inside the specified code-fence format; serde is already included.

Built by
VeilStrat
AI signals for GTM teams
© 2026 VeilStrat. All rights reserved.All systems operational
write-script-rust skill by windmill-labs/windmill | VeilStrat