write-script-rlang

Write R scripts for Windmill with main functions, typed parameters, and CLI preview workflows.

1|Updated Aug 3, 2026
One-click install
npx skills add https://github.com/vpzed-dev/smithy --skill write-script-rlang-vpzed-dev
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: write-script-rlang
Source: https://github.com/vpzed-dev/smithy/tree/main/windmill/local-dev/.agents/skills/write-script-rlang
Command: npx skills add https://github.com/vpzed-dev/smithy --skill write-script-rlang-vpzed-dev

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Writing R scripts for the Windmill platform requires knowing its conventions: a mandatory main function, type mappings between R and Windmill inputs, built-in helpers for resources and variables, and the correct CLI commands for previewing versus deploying. This Skill encodes all of those rules so generated scripts work on the first run. ## Core Features & Use Cases - Windmill-native R structure: Enforces the required main function pattern, correct R-to-Windmill type mappings (numeric, character, logical, list), and JSON-serializable return values. - CLI workflow guidance: Distinguishes wmill script preview for local iteration from wmill script run for deployed versions, and prevents accidental deploys when the user only wants to test. - Metadata synchronization: Keeps .lock files, .script.yaml input schemas, and wmill-lock.yaml content hashes in sync after edits via wmill generate-metadata. - Use Case: A data engineer asks for an R script that reads a PostgreSQL resource and returns aggregated results; the Skill produces a valid main function using get_resource, then previews it locally with sample arguments before any deploy. ## Quick Start Write a Windmill R script that fetches a resource and returns a JSON summary, then preview it locally with sample arguments.

Frequently Asked Questions about write-script-rlang

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

FAQPage Schema
How do I write an R script for Windmill?▼

Define a `main` function whose parameters become the script inputs, load packages with `library()`, and return a JSON-serializable value. Windmill resolves and installs declared packages automatically, and `jsonlite` is always available for argument parsing.

How do I test a Windmill R script locally without deploying?▼

Run `wmill script preview <script_path>` with sample arguments passed via `-d`. Preview executes the local file without deploying, so it is the correct choice when iterating on edits rather than pushing to the workspace.

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

`script preview` runs the local file without deploying, while `script run` executes the version already deployed in the workspace. Use preview when iterating on local edits and run only when explicitly testing the deployed version.

How do R types map to Windmill input types?▼

R `numeric` maps to float/int, `character` to string, `logical` to bool, `list` to object, and `NULL` to null. Default values in the `main` function signature are inferred as optional parameters with those defaults.

Why is my Windmill lock file out of sync after editing an R script?▼

Adding or removing imports or changing `main`'s arguments invalidates the content hash tracked in `wmill-lock.yaml`. Run `wmill generate-metadata` to regenerate the `.lock`, the `.script.yaml` input schema, and the hash entries so they match the code.

How do I access Windmill resources and variables from R?▼

Use the built-in helpers `get_variable("f/folder/name")` and `get_resource("f/folder/name")` directly in your script with no import needed. Resources return as R lists, so fields are accessed with the `$` operator.