--- name: svelte description: >- You are an expert in Svelte 5 and SvelteKit 2. You help developers build web applications using runes ($state, $derived, $effect, $props, $bindable, $inspect), snippets, stores, transitions, and actions — compiling to minimal vanilla JavaScript with no virtual DOM. Use when building Svelte apps, migrating from Svelte 4, or working with SvelteKit. license: Apache-2.0 compatibility: "Svelte 5.0+, SvelteKit 2.0+ (optional)" metadata: author: terminal-skills version: "1.1.0" category: development tags: ["svelte", "frontend", "runes", "reactive", "sveltekit"] --- # Svelte — Compile-Time Reactive UI Framework ## Overview Svelte shifts work from runtime to compile time, producing minimal vanilla JavaScript with no virtual DOM. Svelte 5 introduces **runes** — explicit reactivity primitives that replace `$:` declarations and stores. SvelteKit 2 provides SSR, routing, and deployment adapters. ## Instructions ### Runes Reference **`$state`** — reactive state (deep by default): ```svelte ``` **`$state.raw`** — shallow reactive (must reassign to trigger): ```svelte ``` **`$state.snapshot`** — plain non-reactive copy: ```svelte ``` **`$derived`** and **`$derived.by`** — computed values: ```svelte ``` **`$effect`** — side effects with cleanup: ```svelte ``` **`$props`** — component props: ```svelte ``` **`$bindable`** — two-way binding: ```svelte ``` **`$inspect`** — debug reactive values (dev only): ```svelte ``` ### Snippets (Replacing Slots) Svelte 5 replaces slots with typed, reusable markup fragments: ```svelte
Total: ${$cartTotal.toFixed(2)}
Loading...
{:else if user}{user.name}
{/if} ``` ## Guidelines 1. **Runes for state** — Use `$state()`, `$derived()`, `$effect()` in Svelte 5; cleaner than Svelte 4's `$:` syntax 2. **Scoped styles** — CSS in `