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.

More: all SvelteKit rules · all Windsurf rules

Related rules

SvelteKit AGENTS.md

AGENTS.md for SvelteKit 2 + Svelte 5 (runes) apps with TypeScript.

AGENTS.mdSvelteKit

Next.js Windsurf rules

Windsurf (Cascade) workspace rules for Next.js + shadcn/ui projects.

WindsurfNext.js

Tailwind CSS v4 rules

Windsurf rules for clean, consistent, accessible Tailwind CSS v4 styling.

WindsurfTailwind CSS

Angular 20 Copilot instructions

Copilot instructions for Angular 20 apps using standalone components, signals, and the new control flow.

GitHub CopilotAngular

Astro content site rules

Cursor rules for Astro 5 sites with content collections, islands, and zero-JS-by-default pages.

CursorAstro

Chrome extension (Manifest V3) rules

Cursor rules for building Manifest V3 browser extensions with TypeScript and minimal permissions.

CursorChrome extensions

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.