Windmillに新しいTriggerCrud型のトリガーを追加する際、バックエンドからCLI、画面、同期やキャプチャ機能まで必要な変更箇所を確認できる開発チェックリストです。
- 新しい外部サービスのトリガーを追加したいとき
- 実装箇所の抜け漏れを点検したいとき
- トリガー追加のPR前に検証したいとき
WindmillのバックエンドRustコードを、エラー処理やSQLx、非同期処理、モジュール構成などの規約に沿って実装・修正するためのガイドです。
Rust coding guidelines for the Windmill backend. MUST use when writing or modifying Rust code in the backend directory.
実行スコア 未検証
インストール方法を見るWindmillのバックエンドにRustコードを追加・修正するときの実装規約を案内します。エラーは共通のError型で扱い、ライブラリコードで不用意にパニックさせない方針や、SQLxで列を明示してクエリを書く方法を示します。複数件の取得ではまとめて問い合わせ、複数段階の更新にはトランザクションを使うなど、互換性や効率を保つための指針も含みます。JSONの保持方法、Serdeの属性、非同期ランタイムを止めない処理、Mutexやチャネルの選び方、可視性と配置先、Axumハンドラーの引数の書き方も確認できます。コードの定義や参照、型情報はrust-analyzer LSPで調べる方針です。
WindmillのバックエンドでRustの機能を実装するときや、既存コードを変更するときに役立ちます。APIエンドポイントやデータベース処理を追加する場合、非同期処理やJSONの扱いを既存の設計に合わせたい場合、機能利用テレメトリーの計測登録を確認する場合にも参照できます。
コードナビゲーションにはrust-analyzer LSPを使う方針です。
この紹介文は、公開されている SKILL.md をもとに AI(OpenAI Codex)が作成しました。正確な仕様は下の原文を確認してください。
インストールする前に、エージェントに与えられる指示の中身を確認できます。
Apply these Windmill-specific patterns when writing Rust code in backend/.
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.
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.
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.
#[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,
}
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.
pub(crate) instead of pub when possiblewindmill-api/src/ organized by domainwindmill-common/src/Always use rust-analyzer LSP for go-to-definition, find-references, and type info. Do not guess at module paths.
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.
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>> { ... }
まだレビューはありません。使ってみた感想をお寄せください。
ログインなしで書き込めます。使ってみた感想、質問、動かなかった環境などを気軽にどうぞ。
まだコメントはありません。最初のコメントを書いてみませんか。
Windmillに新しいTriggerCrud型のトリガーを追加する際、バックエンドからCLI、画面、同期やキャプチャ機能まで必要な変更箇所を確認できる開発チェックリストです。
WindmillのAIチャットを変更するときに、ツールやプロンプト、結果の返し方、コンテキスト量を整理し、評価で変更前後の挙動を比べるための指針です。
WindmillのAI生成モード向けに、実際の利用要求に沿ったベンチマークケースを作成・実行します。生成結果を決定的な検証とLLM評価で確認し、AIチャットやcopilotの変更前後を比較できます。
Windmill CLIのコマンドを使い、スクリプトやフローなどの管理、ジョブの実行履歴確認、失敗原因の調査を進めるためのリファレンスです。
モジュールのインターフェースを小さく保ちながら、内部に複雑な処理をまとめる設計を支援します。テストしやすさや変更のしやすさを考え、処理の境目を整理できます。
変更内容を確認し、対象ファイルだけを選んで、形式や長さの規則に沿ったConventional Commits形式のGitコミットを作成するスキルです。