code-style-svelte
Installation
SKILL.md
Svelte Code Style
Optional snippet rendering
Use {@render snippet?.()} instead of {#if snippet}{@render snippet()}{/if}. The optional chaining form is shorter and idiomatic Svelte 5.
No $effect for setting state
NEVER use $effect to set state. If you need derived state, use $derived instead. Effects that write to state create unnecessary re-renders and are a sign of wrong reactive design.
No bare async in onMount or $effect
NEVER pass an async function directly to onMount or $effect:
// BAD — cleanup function is lost, dependency tracking breaks
onMount(async () => { ... });
$effect(async () => { ... });