Home › SvelteKit › Svelte 5 runes Windsurf rules

Svelte 5 runes Windsurf rules

Windsurf rules for Svelte 5 components with runes ($state, $derived, $props) in SvelteKit 2 apps.

WindsurfSvelteKit

How to use

Save this as .windsurf/rules/svelte.md in your repository root, commit it, and your agent will pick it up automatically. Edit the commands to match your project.

.windsurf/rules/svelte.mdDownload  
---
trigger: glob
globs: src/**/*.svelte,src/**/*.svelte.ts
---

# Svelte 5 (runes)

- Use runes only: `let count = $state(0)`, `const doubled = $derived(count * 2)`, `$derived.by(() => ...)` for multi-line.
- Props: `let { title, items = [], onselect } = $props();` with a `Props` type. Two-way props with `$bindable()`.
- `$effect` only for side effects touching the outside world (DOM APIs, subscriptions), with a returned cleanup. Never use it to sync one state into another; use `$derived`.
- Events are props: `onclick={handle}`, not `on:click`. Component events are callback props, not `createEventDispatcher`.
- Content via snippets: `{#snippet row(item)}...{/snippet}` and `{@render children?.()}`, not `<slot>`.
- Shared reactive state in `.svelte.ts` modules exporting `$state` objects or classes with `$state` fields.
- Keyed each blocks: `{#each items as item (item.id)}`.
- In SvelteKit, load data in `+page.ts`/`+page.server.ts` and read it from `let { data } = $props()`; mutations through form actions with `use:enhance`.

## Don't
- Don't use `export let`, `$:` reactive statements, or stores for local state in new code.

## Done when
`npx svelte-check` and `npm run test` pass.

Related rules

Web accessibility (WCAG 2.2) rules

Windsurf rules for building accessible web UIs to WCAG 2.2 AA: semantics, keyboard, focus, contrast, and testing.

WindsurfAccessibility

Django Windsurf rules

Windsurf rules for Django 5.2 LTS projects: apps, models and migrations, ORM performance, forms, and tests.

WindsurfDjango

Documentation writing rules

Windsurf rules for writing and updating READMEs, docstrings, ADRs, and changelogs alongside code changes.

WindsurfAgent workflows

Electron app Windsurf rules

Windsurf rules for secure Electron 44 apps: context isolation, preload bridges, typed IPC, and packaging.

WindsurfElectron

Get new rules weekly

One email a week: fresh rule files, agent tips, and what's changing in Cursor, Claude Code and Copilot. Free, unsubscribe anytime.

Opens the Rulestack Newsletter on beehiiv in a new tab. Or subscribe directly on beehiiv.