← Back to list

sveltekit-patterns
by spences10
⭐ 6🍴 0📅 Jan 21, 2026
SKILL.md
name: sveltekit-patterns
prettier-ignore
description: SvelteKit patterns for devhub-crm. Use for remote functions (query, form, command), routing, and server-side logic.
SvelteKit Patterns
Quick Start
// Query: Read data
export const get_contacts = query(() =>
db.prepare('SELECT * FROM contacts').all(),
);
// Form: Validated mutation with redirect
export const create = form(
v.object({ name: v.string() }),
async ({ name }) => {
db.prepare('INSERT INTO contacts ...').run(id, name);
redirect(303, '/contacts');
},
);
// Command: Mutation with refresh
export const delete_contact = command(v.string(), async (id) => {
db.prepare('DELETE FROM contacts WHERE id = ?').run(id);
await get_contacts().refresh();
return { success: true };
});
Core Principles
- Types:
query(read),form(mutations + redirects),command(mutations only) - Validation: Use valibot schemas for all inputs
- Security: Always include
user_idin WHERE clauses - Batching: Use
query.batch()for N+1 prevention - Refresh: Call
.refresh()in form/command handlers - Use
.current: Store queries in variables, check.current === undefinedfor initial load - No manual keys: Never use
refresh_key++or{#key}blocks - Return values: Commands must return
{ success: true }
Reference Files
- remote-functions.md - Complete remote functions API
- routing.md - File-based routing patterns
- database-patterns.md - Advanced database queries
Score
Total Score
50/100
Based on repository quality metrics
✓SKILL.md
SKILL.mdファイルが含まれている
+20
○LICENSE
ライセンスが設定されている
0/10
○説明文
100文字以上の説明がある
0/10
○人気
GitHub Stars 100以上
0/15
○最近の活動
3ヶ月以内に更新がある
0/10
○フォーク
10回以上フォークされている
0/5
✓Issue管理
オープンIssueが50未満
+5
✓言語
プログラミング言語が設定されている
+5
○タグ
1つ以上のタグが設定されている
0/5
Reviews
💬
Reviews coming soon