Overview
Build high-performance web apps with Svelte 5 (runes reactivity) and SvelteKit (SSR, routing, form actions, streaming).
Capabilities
- Svelte 5 runes ($state, $derived, $effect)
- Stores and reactive state
- SvelteKit file-based routing
- Server-side rendering and streaming
- Form actions for mutations
- Load functions for data fetching
- Adapter-based deployment (Vercel, Node, Cloudflare)
When to Use
Trigger phrases:
"svelte framework"
"Svelte and SvelteKit development — runes, stores, server-side rendering, form ac"
"svelte patterns"
Building fast, lightweight web applications
Building reactive UIs with minimal boilerplate
SSR/SSG with minimal JavaScript
Form-heavy applications with progressive enhancement
Real-time apps with efficient reactivity
Edge-deployed applications
When NOT to Use
- Task is about deployment, not development (use deploy skills)
- Task is about code review, not writing (use review skills)
- You need to understand existing code first (use research skills)
- Task is about testing only (use test skills)
- Requirements are unclear (clarify first)
- Task is trivially simple (single line fix)
Pseudo Code
The svelte-framework workflow follows a standard pipeline pattern.
Core flow:
# svelte-framework primary flow
input = prepare(raw_data)
result = process(input, config={actions, development, form, framework, rendering})
validate(result)
deliver(result)
Error handling:
on error:
log(error_details)
retry_with_backoff(max=3)
if still_failing: alert_and_escalate()
Svelte 5 Component with Runes
<script>
let count = $state(0)
let doubled = $derived(count * 2)
$effect(() => {
console.log(`Count changed to ${count}`)
})
function increment() {
count++
}
</script>
<button (doubled: {doubled})</button>
SvelteKit Load Function
// src/routes/users/[id]/+page.server.ts
import type { PageServerLoad } from './$types'
export const load: PageServerLoad = async ({ params, fetch }) => {
const response = await fetch(`/api/users/${params.id}`)
const user = await response.json()
return { user }
}
SvelteKit Form Action
// src/routes/todos/+page.server.ts
import type { Actions } from './$types'
export const actions: Actions = {
create: async ({ request, locals }) => {
const data = await request.formData()
const title = data.get('title') as string
await locals.db.todos.create({ data: { title, userId: locals.user.id } })
return { success: true }
},
delete: async ({ request, locals }) => {
const data = await request.formData()
await locals.db.todos.delete({ where: { id: data.get('id') } })
},
}
<!-- src/routes/todos/+page.svelte -->
<script>
let { data } = $props()
</script>
{#each data.todos as todo}
<form method="POST" action="?/delete">
<span>{todo.title}</span>
<input type="hidden" name="id" value={todo.id} />
<button>Delete</button>
</form>
{/each}
<form method="POST" action="?/create">
<input name="title" required />
<button>Add</button>
</form>
Streaming
// Slow data streams to client as it resolves
export const load = async ({ fetch }) => {
return {
streamed: {
analytics: fetch('/api/analytics').then(r => r.json()),
},
}
}
{#await data.streamed.analytics}
<p>Loading analytics...</p>
{:then analytics}
<Dashboard data={analytics} />
{/await}
Component with Children Slots
<!-- Card.svelte -->
<script>
let { title, children } = $props();
</script>
<div class="card">
<h2>{title}</h2>
<div class="content">
{@render children()}
</div>
</div>
Common Patterns
- Form actions: Progressive enhancement, works without JS
- Streaming: Stream slow data to avoid blocking page load
- Runes: Fine-grained reactivity without virtual DOM overhead
- Adapter deployment: Swap adapters for different hosts
- Layout groups: Shared layouts with
(group)directories - $state.raw: Non-deep-reactive state for large arrays/objects
- $effect.cleanup: Cleanup side effects when component unmounts
- Hooks:
handlefor middleware,handleErrorfor error reporting
How to Use
- Understand the requirement and existing codebase patterns
- Design the solution with error handling and testability in mind
- Implement incrementally with tests for each change
- Verify against expected outcomes (manual and automated)
- Document usage, edge cases, and integration points
- Review with team before merging to shared branches
Red Flags
- Skipping tests to ship faster: Untested code breaks in production when you least expect it
- No error handling in production code: Unhandled errors crash services and lose user data
- Hardcoded configuration values: Hardcoded values prevent environment switching and leak secrets
- Ignoring security implications: Missing input validation, auth bypasses, and injection vulnerabilities
- Over-engineering simple solutions: Premature abstraction adds complexity without proportional benefit
Verification
- Skill output matches expected behavior
Process
- Analyze the task requirements
- Apply domain expertise
- Verify output quality
Anti-Rationalization Table
| Rationalization | Reality |
|---|---|
| "Tests slow me down" | Bugs slow you down 10x more. Tests are speed, not overhead. |
| "I will refactor later" | Technical debt compounds. Refactor as you go. |
| "It works on my machine" | If it is not in CI, it does not work. Ship proof, not claims. |