sveltekit
Use when the user asks about SvelteKit load functions and form actions, +page.server.ts, +server.ts endpoints, hooks, use:enhance, adapters, SSR/prerendering…
от j4flmao★ 47 звёзд на GitHub
Установить sveltekit в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Об этом скилле
SvelteKit
Purpose
Define and enforce SvelteKit application architecture with routing conventions, data loading, form handling, and deployment patterns.
Agent Protocol
Trigger
User request includes: svelte, sveltekit, svelte app, svelte routing, svelte load, svelte server, svelte form, svelte kit.
Input Context
- SvelteKit version (2.x)
- Rendering mode (SSR, SPA, static)
- Data fetching requirements
- Auth strategy
Output Artifact
No file output. Produces route structure, load functions, form actions, and deployment config as text.
Response Format
Route structure with file tree. Load and action code examples. Deployment config.
No preamble. No postamble. No explanations. No filler/hedging/transitions.
Max Response Length
4096 tokens
Component Architecture / Decision Trees
Architecture Options
| Approach | Trade-off | When to Use |
|---|---|---|
| Server load functions (+page.server.ts) | DB access, secrets, SSR | Private/personalized data |
| Universal load functions (+page.ts) | Runs on server + client | Public API data, cached |
| Form actions | Server mutations, progressive enhancement | All form submissions |
| API endpoints (+server.ts) | REST/JSON endpoints | External API consumption |
| Hooks (handle) | Per-request processing | Auth, logging, redirects |
Decision Tree: Load Function
Is the data user-specific?
├── Yes -> +page.server.ts or +layout.server.ts
└── No -> Is the API public?
├── Yes -> +page.ts (universal load)
└── No -> +page.server.ts
Decision Tree: SSR vs SPA vs Static
How should this route render?
├── Needs SEO + fast initial load -> SSR (default)
├── Fully static content -> export const prerender = true
├── Authenticated dashboard -> SSR + trailing slash
└── No SSR needed -> export const ssr = false
Component Design Patterns
Server Load with Auth
// src/routes/dashboard/+page.server.ts
import type { PageServerLoad } from './$types'
export const load: PageServerLoad = async ({ locals, url }) => {
if (!locals.user) throw redirect(302, '/login')
const page = Number(url.searchParams.get('page')) || 1
const [orders, total, notifications] = await Promise.all([
db.order.findMany({ where: { userId: locals.user.id }, skip: (page-1)*20, take: 20 }),
db.order.count({ where: { userId: locals.user.id } }),
db.notification.findMany({ where: { userId: locals.user.id, read: false } }),
])
return { user: locals.user, orders, total, page, notifications }
}
Universal Load with Caching
// src/routes/products/+page.ts
import type { PageLoad } from './$types'
export const load: PageLoad = async ({ fetch, url }) => {
const res = await fetch(`/api/products?${url.searchParams}`)
const products = await res.json()
return {
products,
/** Cache on CDN for 5 minutes, stale-while-revalidate for 1 hour */
headers: { 'Cache-Control': 'public, max-age=300, s-maxage=3600' },
}
}
Form Action with Validation
// src/routes/settings/+page.server.ts
import type { Actions } from './$types'
import { fail, redirect } from '@sveltejs/kit'
import { z } from 'zod'
const schema = z.object({ name: z.string().min(2), email: z.string().email() })
export const actions: Actions = {
default: async ({ request, locals }) => {
const data = Object.fromEntries(await request.formData())
const result = schema.safeParse(data)
if (!result.success) return fail(400, { errors: result.error.flatten().fieldErrors, values: data })
await db.user.update({ where: { id: locals.user.id }, data: result.data })
return { success: true }
},
delete: async ({ locals }) => {
await db.user.delete({ where: { id: locals.user.id } })
throw redirect(302, '/goodbye')
},
}
API Endpoint
// src/routes/api/orders/+server.ts
import { json } from '@sveltejs/kit'
import type { RequestHandler } from './$types'
export const GET: RequestHandler = async ({ locals, url }) => {
const orders = await db.order.findMany({ where: { userId: locals.user.id } })
return json(orders)
}
export const POST: RequestHandler = async ({ request, locals }) => {
const body = await request.json()
const order = await db.order.create({ data: { ...body, userId: locals.user.id } })
return json(order, { status: 201 })
}
State Management Patterns
Loader Data as State (Primary)
<script>
let { data } = $props()
// data.orders, data.user from load function
</script>
Form State with use:enhance
<script>
import { enhance } from '$app/forms'
let { form, data } = $props()
</script>
<form method="POST" use:enhance>
<input name="name" bind:value={form?.name} />
<button type="submit">Save</button>
</form>
Client State with Stores
// src/lib/stores/cart.svelte.ts
import { writable } from 'svelte/store'
export cons
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
- references/endpoints-loading.md
- references/stores-context.md
- references/sveltekit-auth.md
- references/sveltekit-data.md
- references/sveltekit-deployment-adapters.md
- references/sveltekit-deployment.md
- references/sveltekit-form-actions.md
- references/sveltekit-routing.md
FAQ
Что делает скилл sveltekit?
Use when the user asks about SvelteKit load functions and form actions, +page.server.ts, +server.ts endpoints, hooks, use:enhance, adapters, SSR/prerendering or SvelteKit deployment. Produces SvelteKit routes, server loads, validated actions and adapter config. Not for Svelte component and rune design (use frontend-svelte-architecture).
Как установить скилл sveltekit?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл sveltekit запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
AnthropicGuide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
claude-api
AnthropicReference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
algorithmic-art
AnthropicCreating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
mcp-integration
AnthropicThis skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…