svelte-core-bestpractices

Guides writing modern Svelte 5 components using runes, snippets, and attachments.

Updated May 16, 2026
One-click install
npx skills add https://github.com/michalo1334/ScenarioImpactDSL --skill svelte-core-bestpractices-michalo1334
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: svelte-core-bestpractices
Source: https://github.com/michalo1334/ScenarioImpactDSL/tree/main/.opencode/skills/svelte-core-bestpractices
Command: npx skills add https://github.com/michalo1334/ScenarioImpactDSL --skill svelte-core-bestpractices-michalo1334

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Svelte 5 introduced runes and new syntax that replace legacy patterns, and developers often mix old and new approaches or misuse reactivity primitives. This Skill provides authoritative guidance so generated or reviewed Svelte code follows current best practices. ## Core Features & Use Cases - Reactivity guidance: Correct usage of $state, $derived, $effect, $props, and $inspect, including when to avoid effects and when to use $state.raw. - Modern syntax patterns: Snippets with {@render}, keyed each blocks, function bindings, {@attach} attachments, event attributes, and CSS custom property styling. - Async Svelte support: Covers experimental await expressions, hydratable, and <svelte:boundary> for async rendering in Svelte 5.36+. - Use Case: When asked to refactor a Svelte component that uses on:click, export let, and $: statements, this Skill directs the rewrite to runes mode with $props, $derived, and onclick handlers. ## Quick Start Review this Svelte component and rewrite it using Svelte 5 runes and modern best practices.

Frequently Asked Questions about svelte-core-bestpractices

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I use $state and $derived runes in Svelte 5?▼

Use $state for variables that should trigger reactive updates, and $derived for values computed from state instead of updating them inside $effect. Objects and arrays in $state are deeply reactive; use $state.raw for large reassigned-only data like API responses.

How to migrate Svelte 4 code to Svelte 5 runes?▼

Replace implicit reactivity with $state, $: statements with $derived or $effect, export let with $props, on:click with onclick, slots with snippets and {@render}, and actions with {@attach}. Always use runes mode for new code.

When should I use $effect in Svelte?▼

$effect is an escape hatch and should mostly be avoided, especially for updating state. Prefer event handlers for user interaction, {@attach} for syncing with external libraries like D3, and createSubscriber for observing external event-based systems.

Does Svelte 5 support await expressions in components?▼

Yes, Svelte 5.36+ supports await in the component script, $derived declarations, and markup, but it requires enabling the experimental.async option in svelte.config.js. Errors bubble to the nearest svelte:boundary, and pending snippets show loading states.

Why is my Svelte component not updating when props change?▼

Values computed directly from props are not reactive, so wrap them in $derived to re-evaluate when props change. You can also add $inspect.trace() as the first line of an effect or derived to trace which dependency triggered an update.