mcpField
S
svelte

svelte

github.com/oakossDevelopment21112 installsUpdated 12w ago
Repository

About svelte

Svelte is a compiler-based UI framework that moves work to build time and uses runes for reactivity in Svelte 5. SvelteKit adds routing, rendering, and deployment options for full-stack web projects.

Key features

  1. 01Compile-time UI framework
  2. 02Svelte 5 rune reactivity
  3. 03SvelteKit file-based routing
  4. 04Server-side rendering and prerendering
  5. 05Form actions and API routes

Use cases

  1. 01Building full-stack web apps
  2. 02Creating static sites
  3. 03Migrating projects from Svelte 4 to 5

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/oakoss/agent-skills --skill svelte

After installing, type/sveltein Claude Code to confirm it loaded.

Bundled files

References and scripts installed along with SKILL.md.

references/
adapters-deployment.md
component-patterns.md
form-actions.md
hooks-errors.md
migration-guide.md
runes-reactivity.md
sveltekit-routing.md

Details

From the project README

Svelte

Overview

Svelte is a compiler-based UI framework that shifts work from runtime to build time, producing minimal JavaScript with no virtual DOM. Svelte 5 introduces runes for explicit, fine-grained reactivity. SvelteKit is the full-stack framework built on Svelte, providing file-based routing, server-side rendering, and deployment adapters.

When to use: Full-stack web apps, static sites, progressive enhancement, SSR/SSG, projects needing small bundle sizes, migration from Svelte 4 to 5.

When NOT to use: React/Vue ecosystem lock-in, projects requiring extensive third-party component libraries only available for other frameworks, teams with no Svelte experience on tight deadlines.

Quick Reference

PatternAPI / SyntaxKey Points
Reactive statelet count = $state(0)Replaces let reactivity from Svelte 4
Derived stateconst double = $derived(count * 2)Replaces $: reactive declarations
Complex derivationconst value = $derived.by(() => { ... })Multi-statement derived computations
Side effects$effect(() => { ... })Runs after DOM update, auto-tracks dependencies
Component propslet { name, age = 25 } = $props()Replaces export let, supports defaults
Bindable propslet { value = $bindable() } = $props()Two-way binding with bind:value
Debug inspection$inspect(value)Dev-only logging, stripped in production
Snippets{#snippet name(params)}...{/snippet}Replaces slots, reusable template blocks
Render snippet{@render name(args)}Invoke a snippet with arguments
Event handling<button onclick={handler}>Properties replace on:click directive
Each blocks{#each items as item (item.id)}...{/each}Keyed iteration for efficient updates
Await blocks{#await promise}...{:then}...{:catch}...Inline async rendering
Server loadexport function load({ params }) in +page.server.tsRuns server-side only, accesses DB/secrets
Universal loadexport function load({ fetch }) in +page.tsRuns on server and client
Form actionsexport const actions in +page.server.tsProgressive enhancement with use:enhance
Layout+layout.svelte / +layout.server.tsShared UI and data across child routes
Server hookshandle() in src/hooks.server.tsRequest middleware, auth, redirects
Error page+error.sveltePer-route error boundaries
Adaptersadapter-auto, adapter-node, adapter-staticDeploy to Vercel, Node, static hosting
API routes+server.ts with GET, POST, etc.Standalone endpoints, not tied to pages
Page optionsexport const prerender = truePer-route SSR, CSR, prerender control
Shared state$state() in .svelte.ts modulesReplaces writable stores for cross-component state
Raw state$state.raw(data)Opts out of deep proxying for large datasets

Svelte 4 to 5 Migration

Svelte 4 (Legacy)Svelte 5 (Current)
let count = 0 (reactive)let count = $state(0)
$: double = count * 2const double = $derived(count * 2)
$: { sideEffect() }$effect(() => { sideEffect() })
export let namelet { name } = $props()
<slot />{#snippet children()}{/snippet} + {@render}
on:click={handler}onclick={handler}
createEventDispatcher()Callback props: let { onclick } = $props()
import { writable } from 'svelte/store'$state() in .svelte.ts modules
$store auto-subscriptionDirect value access from rune-based state

Common Mistakes

MistakeCorrect Pattern
Using $state on non-primitives without care$state deeply proxies objects; use $state.raw() for large read-only data
Destructuring $props() loses reactivityDestructure at declaration only: let { x } = $props()
Reading $effect dependencies conditionallyEnsure all tracked reads happen unconditionally
Returning cleanup from $effect incorrectlyReturn a function: $effect(() => { return () => cleanup() })
Mixing on:click and onclick in Svelte 5Use onclick exclusively in Svelte 5 components
Using stores in new Svelte 5 codeUse $state() in .svelte.ts modules for shared state
Forgetting (key) in {#each} blocksAlways key: {#each items as item (item.id)}
Exporting load from .svelte filesLoad functions belong in +page.ts or +page.server.ts
Not awaiting parent load in layoutsUse await parent() when child load depends on layout
Using goto() in server load functionsUse redirect(303, '/path') from @sveltejs/kit

Delegation

  • Pattern discovery: Use Explore agent
  • Code review: Delegate to code-reviewer agent
  • Build configuration: Delegate to Task agent

If the tailwind skill is available, delegate Tailwind CSS utility class patterns and configuration to it. If the vitest-testing skill is available, delegate Svelte component unit testing patterns to it. If the playwright skill is available, delegate end-to-end testing of SvelteKit routes and form actions to it. If the drizzle-orm skill is available, delegate database schema and query patterns used in SvelteKit server load functions to it. If the vite skill is available, delegate Vite build configuration and plugin setup to it.

References

Comments

Markdown supported