跳到正文
cccskills
免费在 GitHub 公开中文介绍

rust-backend

在 Windmill 后端编写或修改 Rust 代码时,参考此指南处理错误、SQLx 查询、JSON 与 Serde、异步任务、可见性和 Axum 处理函数,并使用 rust-analyzer LSP 查看代码定义、引用和类型。

原文查看原文说明

Rust coding guidelines for the Windmill backend. MUST use when writing or modifying Rust code in the backend directory.

windmill-labs/windmill星标 18,314(GitHub 18,314 + cccskills 0)

实测评分 未实测

查看安装方法

适用场景

  • 新增 Rust API 端点
  • 修改 SQLx 查询
  • 确认异步处理方式
  • 查找后端代码的合适位置

中文介绍

功能

此技能为 Windmill 后端 Rust 代码的新增和修改提供规范指引。它说明如何使用统一的 Error 类型、避免库代码随意触发 panic,以及如何在 SQLx 查询中明确列出字段。内容还涵盖批量查询、事务、JSON 保存方式、Serde 属性、避免阻塞异步运行时的处理方式,以及 Mutex 和通道的选择。你可以据此确认代码应放在哪个 crate、如何设置可见性、Axum 处理函数的参数如何编写,并通过 rust-analyzer LSP 查看定义、引用和类型信息。

适用场景

在 Windmill 后端实现功能或修改现有 Rust 代码时,可以查阅此指南。新增 API 端点或数据库操作、让异步处理和 JSON 用法符合现有设计,以及确认功能使用情况遥测的登记方式时也适用。

使用示例

  • “请按照项目规范修改这段后端 Rust 代码。”
  • “请让这个 SQLx 查询和错误处理符合 Windmill 的模式。”
  • “请确认这个 Axum 处理函数应放在哪里,以及可见性如何设置。”

注意事项

代码导航使用 rust-analyzer LSP。

本介绍由 AI(OpenAI Codex)根据公开的 SKILL.md 撰写。准确的规格请查看下方原文。

文档检查

AI 根据 SKILL.md 的内容检查了需要注意的操作和使用前提。评分只依据实际运行的结果(实测对比)。

安全性发送数据、删除文件、执行命令等是否有说明
A良好资料未说明删除文件、对外发送或读取认证信息的操作。
安装难易度所需工具和 API 密钥是否少且有说明
B部分不足资料要求使用 rust-analyzer LSP 导航代码,但未提供安装步骤。

不计入评分。 由 AI(OpenAI Codex)于 2026年10月28日 评估。仅供参考,安装前请同时查看原文。

如果您认为评估有误,请申请复核

请写明哪一项有误以及原因。无需登录。我们会对照 SKILL.md 重新评估,并在此处更新结果。

此表单受 reCAPTCHA 保护,适用 Google 的隐私权政策和服务条款。

包含的文件(1)

  • SKILL.md3.4 KB

SKILL.md(原文)

安装前可以查看交给 AI 代理的指令内容。

Windmill Rust Patterns

Apply these Windmill-specific patterns when writing Rust code in backend/.

Error Handling

Use Error from windmill_common::error. Return Result<T, Error> or JsonResult<T>:

use windmill_common::error::{Error, Result};

pub async fn get_job(db: &DB, id: Uuid) -> Result<Job> {
    sqlx::query_as!(Job, "SELECT id, workspace_id FROM v2_job WHERE id = $1", id)
        .fetch_optional(db)
        .await?
        .ok_or_else(|| Error::NotFound("job not found".to_string()))?;
}

Never panic in library code. Reserve .unwrap() for compile-time guarantees.

SQLx Patterns

Never use SELECT * — always list columns explicitly. Critical for backwards compatibility when workers lag behind API version:

// Correct
sqlx::query_as!(Job, "SELECT id, workspace_id, path FROM v2_job WHERE id = $1", id)

// Wrong — breaks when columns are added
sqlx::query_as!(Job, "SELECT * FROM v2_job WHERE id = $1", id)

Use batch operations to avoid N+1:

// Preferred — single query with IN clause
sqlx::query!("SELECT ... WHERE id = ANY($1)", &ids[..]).fetch_all(db).await?

Use transactions for multi-step operations. Parameterize all queries.

JSON Handling

Prefer Box<serde_json::value::RawValue> over serde_json::Value when storing/passing JSON without inspection:

pub struct Job {
    pub args: Option<Box<serde_json::value::RawValue>>,
}

Only use serde_json::Value when you need to inspect or modify the JSON.

Serde Optimizations

#[derive(Serialize, Deserialize)]
pub struct Job {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub parent_job: Option<Uuid>,
    #[serde(skip_serializing_if = "Vec::is_empty")]
    pub tags: Vec<String>,
    #[serde(default)]
    pub priority: i32,
}

Async & Concurrency

Never block the async runtime. Use spawn_blocking for CPU-intensive work:

let result = tokio::task::spawn_blocking(move || expensive_computation(&data)).await?;

Mutex selection: Prefer std::sync::Mutex (or parking_lot::Mutex) for data protection. Only use tokio::sync::Mutex when holding locks across .await points.

Use tokio::sync::mpsc (bounded) for channels. Avoid std::thread::sleep in async contexts.

Module Structure & Visibility

  • Use pub(crate) instead of pub when possible
  • Place new code in the appropriate crate based on functionality
  • API endpoints go in windmill-api/src/ organized by domain
  • Shared functionality goes in windmill-common/src/

Code Navigation

Always use rust-analyzer LSP for go-to-definition, find-references, and type info. Do not guess at module paths.

Feature Telemetry

FEATURE_USAGE_KINDS in windmill-api-workspaces/src/workspaces.rs is an allowlist: a (feature, kind) pair missing from it is dropped by valid_feature_usage_event with a bare continue — no error, and the route still returns 204. Adding a counter on the frontend without registering it here records nothing. See docs/feature-telemetry.md.

Axum Handlers

Destructure extractors directly in function signatures:

async fn process_job(
    Extension(db): Extension<DB>,
    Path((workspace, job_id)): Path<(String, Uuid)>,
    Query(pagination): Query<Pagination>,
) -> Result<Json<Job>> { ... }

评价

还没有评价。欢迎分享你的使用感受。

评论

无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。

还没有评论。来写第一条吧。

提交后会立即公开。请勿填写邮箱、电话等个人信息。URL 最多 2 个。

0 / 1000 字

此表单受 reCAPTCHA 保护,适用 Google 的隐私权政策和服务条款。

同一仓库的技能

Plan the code changes needed to add a TriggerCrud-based trigger to Windmill. The checklist covers backend, database, API, CLI, frontend, capture, and validation work so the new trigger can be managed across the product.

中文简介正在准备中。当前显示英语简介。

  • Add a Kafka, GCP, or Azure style trigger to Windmill
  • Find all product areas affected by a new trigger kind
  • Review implementation and validation steps before a trigger PR
windmill-labs/windmill1.8万2026年10月29日 更新

agents

免费有简介

在 Windmill 中定义可复用的 AI 智能体,为其配置指令、提供方、模型、对话记忆和工具。保存后可从页面运行、供流程步骤调用,或分享到 Slack 频道。

  • 创建可复用的客服智能体
  • 在流程中调用已保存的智能体
  • 将智能体分享到 Slack 频道
windmill-labs/windmill1.8万2026年10月29日 更新

ai-chat

免费有简介

改进 Windmill AI 聊天时,可梳理工具、提示词、结果格式和上下文用量。指南说明如何放置共享指令、减少重复消耗,并通过 A/B 评估比较改动前后的行为。

  • 调整聊天工具及其结果格式
  • 检查提示词的放置位置
  • 减少上下文窗口用量
windmill-labs/windmill1.8万2026年10月29日 更新

ai-evals

免费有简介

为 Windmill 的 AI 生成模式创建并运行黑盒基准测试,覆盖流程、应用、脚本、CLI 和全局请求。案例经过实际生成路径、硬性检查和大语言模型评判,可比较修改前后的面向用户表现。

  • 为 AI 生成模式添加评估案例
  • 比较 AI 聊天修改前后的表现
  • 检查 copilot 生成质量
windmill-labs/windmill1.8万2026年10月29日 更新

cli-commands

免费有简介

这份参考资料介绍如何用 Windmill CLI 管理脚本、流程、数据表和工作区设置,并查看作业历史、详情、日志与结果,排查失败及重新运行作业。

  • 排查作业失败原因
  • 查看运行历史和作业日志
  • 通过 CLI 管理脚本和流程
windmill-labs/windmill1.8万2026年10月29日 更新

codebase-design

免费有简介

帮助设计接口简洁、内部承载较多处理逻辑的模块,梳理模块边缘与复杂度,减少调用方需要了解的内容,让代码更易测试和维护。

  • 设计模块接口
  • 梳理复杂的现有模块
  • 确定可替换处理的位置
windmill-labs/windmill1.8万2026年10月29日 更新

查看 windmill-labs 的全部技能

报告此技能的问题