Directory
‹ Back to apps

SvelteKit 2 & Svelte 5 (Runes)

SvelteKit 2 + Svelte 5 (Runes) rules for Cursor. Pinned to svelte ^5.55.7, @sveltejs/kit ^2.60.1, vite ^8.0.13, typescript ^6.0.3, vitest ^4.1.6, @testing-library/svelte ^5.3.1, @playwright/test ^1.60.0, tailwindcss ^4.3.0, bits-ui ^2.18.1, @lucide/svelte ^1.16.0, sveltekit-superforms ^2.30.1, formsnap ^2.0.1, zod ^4.4.3, @sveltejs/enhanced-img ^0.10.4, mode-watcher ^1.1.0, runed ^0.37.1. Leads with the Svelte 5 Runes that LLMs trained on Svelte 4 do not know ($state, $derived, $effect, $props, $bindable, $host, $inspect, $props.id()), the snippets-replace-slots model, callback-prop event handling that replaces createEventDispatcher, .svelte.ts state modules that replace writable() stores, the SvelteKit 2 no-throw error/redirect API, mandatory cookies path, and the $app/state replacement for $app/stores in 2.12+. Catches 40 LLM regressions including let count = 0 without $state, $: reactive statements in runes mode, export let, on:click event directives, event modifiers, createEventDispatcher, <slot>, new App({ target }), bind:this to non-state, destructured $state losing reactivity, $effect setting state to derive, $effect infinite loops, $state for huge arrays without $state.raw, throw error/redirect in SvelteKit 2, cookies.set without path, top-level unawaited promises in load, goto external, $page from $app/stores, resolvePath, use:enhance form/data renamed to formElement/formData, missing enctype on file forms, paths.relative default flip, $env/dynamic during prerender, writable() for component state, lucide-svelte instead of @lucide/svelte, melt-ui instead of bits-ui, Felte forms, raw <img> over <enhanced:img>, CustomEvent typed payloads, withDefaults-style prop defaults, manual ARIA IDs over $props.id(), {@render children} with <slot>, mutating non-$bindable props, +page.ts without satisfies PageLoad, mount(App) for tests.

What’s inside

5 skills
  • Skillsvelte-new-componentScaffold a Svelte 5 single-file component using <script lang='ts'> with runes ($state, $derived, $props, $bindable), $props.id() for SSR-safe ARIA IDs, callback props for events (no createEventDispatcher), snippets for slots ({@render children?.()} for default, named snippet props for named), and a matching @testing-library/svelte test using render() (NOT mount or new App). Refuses on:click, $:, export let, <slot>, createEventDispatcher, withDefaults, CustomEvent typed handlers. Pairs with the svelte-5-runes, svelte-5-events-and-snippets, and sveltekit-anti-patterns rules.
  • Skillsveltekit-migrate-to-runesStage-by-stage migration from Svelte 4 + SvelteKit 1 to Svelte 5 (Runes) + SvelteKit 2: bump pins (svelte ^5.55.7, @sveltejs/kit ^2.60.1, vite ^8.0.13, typescript ^6.0.3, vitest ^4.1.6), enable runes mode, replace let with $state, $: with $derived, export let with $props, on:click with onclick, event modifiers with function-body handling, createEventDispatcher with callback props, <slot> with {@render children?.()}, new App({ target }) with mount(), drop throw on error/redirect, add path: '/' to cookies calls, await top-level promises in load (Promise.all), goto external -> window.location.href, $page from $app/stores -> page from $app/state, resolvePath -> resolveRoute, use:enhance form/data -> formElement/formData, add enctype on file forms, declare paths.relative: true, swap lucide-svelte for @lucide/svelte, swap melt-ui for bits-ui, swap Felte for sveltekit-superforms + formsnap + zod, swap <img> for <enhanced:img>, swap mount(App) tests for @testing-library/svelte render(), set vitest pool: 'forks'. Pairs with the sveltekit-anti-patterns rule (40 entries by number).
  • Skillsveltekit-new-form-actionScaffold a SvelteKit 2 form action using sveltekit-superforms ^2.30 + formsnap ^2.0 + zod ^4.4 - one Zod schema; superValidate(zod(schema)) on the server load and the action; superForm(data.form, { validators: zodClient(schema) }) on the client; <Field> / <Control> / <Label> / <FieldErrors> from formsnap; use:enhance from $app/forms with the v2 callback args (formElement / formData NOT form / data); enctype='multipart/form-data' on file-input forms; fail(400, { form }) for validation failures; redirect / error called without throw; cookies with path: '/'. Refuses Felte, throw redirect, missing enctype, plain object returns from actions on validation failure. Pairs with the sveltekit-forms-and-actions and sveltekit-anti-patterns rules.
  • Skillsveltekit-new-routeScaffold a SvelteKit 2 route directory with +page.svelte (Svelte 5 runes consuming the data prop typed as PageData), +page.ts (universal load typed satisfies PageLoad with explicit awaits, no top-level unawaited promises), and +page.server.ts (server-only load + actions, error() / redirect() called without throw, cookies with explicit path: '/'). Refuses throw error / throw redirect / cookies without path / top-level unawaited promises in load. Pairs with the sveltekit-2-core, sveltekit-routing-and-load, and sveltekit-anti-patterns rules.
  • Skillsveltekit-validateRun the SvelteKit 2 + Svelte 5 plugin validation suite: tests/validation/validate-plugin.sh checks plugin manifest + rule frontmatter + skill frontmatter + correct-sample is free of banned Svelte 4 / SvelteKit 1 patterns + anti-pattern-sample contains the expected violations. Then run svelte-check (or pnpm svelte-check) for type errors, vitest for unit tests (pool: 'forks' default in v4), and playwright for E2E. Greps for tracked anti-patterns the type checker won't catch (on:click, $:, export let, <slot>, createEventDispatcher, throw redirect, throw error, cookies without path, $page from $app/stores, lucide-svelte, mount(App) in tests). Pairs with the sveltekit-anti-patterns rule and the sveltekit-reviewer agent.