← スキル一覧に戻る

remote-functions
by spences10
My blog made with SvelteKit and MDSveX
⭐ 56🍴 11📅 2026年1月23日
SKILL.md
name: remote-functions
IMPORTANT: Keep description on ONE line for Claude Code compatibility
prettier-ignore
description: Use when building, auditing, or reviewing SvelteKit remote functions for validation, batching, and optimistic UI patterns allowed-tools: Read, Write, Edit, Glob
Remote Functions
Quick Start
/// file: src/routes/counter/count.remote.ts
import * as v from 'valibot'
import { query, command } from '$app/server'
let count = 0
export const getCount = query(async () => count)
export const increment = command(
v.object({ delta: v.optional(v.number(), 1) }),
async ({ delta = 1 }) => {
count += delta
getCount().set(count) // keep cached query in sync without extra fetch
},
)
Trigger optimistic single-flight updates via
increment({ delta: 1 }).updates(getCount().withOverride((n = 0) => n + 1))
inside the component.
Core Principles
- Validate every argument with a Standard Schema; use
getRequestEventfor auth/cookies but never treatroute/params/urlas an authorization boundary. - Queries are cached promises — refresh,
set, orwithOverridethem explicitly from commands/forms to prevent stale UI and redundant roundtrips.
Common Patterns
Single-flight optimistic mutations
Pair a command/form with its sibling query: perform the
mutation, then call query.refresh()/set() or
.updates(query.withOverride(...)) so the UI updates once per
request, even with high latency.
Reference Files
For detailed documentation, see:
Notes
- Prefer
formfor progressive enhancement; reservecommandfor imperative or cross-component workflows. - Use
query.batchfor n+1 scenarios (e.g., weather demo) andprerender({ inputs, dynamic })for data that should be cached at build time yet remain opt-in for runtime refreshes.
スコア
総合スコア
60/100
リポジトリの品質指標に基づく評価
✓SKILL.md
SKILL.mdファイルが含まれている
+20
○LICENSE
ライセンスが設定されている
0/10
○説明文
100文字以上の説明がある
0/10
○人気
GitHub Stars 100以上
0/15
✓最近の活動
1ヶ月以内に更新
+10
✓フォーク
10回以上フォークされている
+5
✓Issue管理
オープンIssueが50未満
+5
✓言語
プログラミング言語が設定されている
+5
✓タグ
1つ以上のタグが設定されている
+5
レビュー
💬
レビュー機能は近日公開予定です

