svelte-runes

Guide Svelte 5 runes usage for reactive state, derived values, and effects.

Updated Dec 15, 2025
One-click install
npx skills add https://github.com/spences10/claudefiles --skill svelte-runes
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: svelte-runes
Source: https://github.com/spences10/claudefiles/tree/main/skills/svelte-runes
Command: npx skills add https://github.com/spences10/claudefiles --skill svelte-runes

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Guides to correctly apply Svelte 5 runes for state, props, effects, and attachments, reducing misuses and bugs.

Core Features & Use Cases

  • Rune semantics: Distinguish between $state, $derived, $effect, and $bindable.
  • Migration tips: Helps migrate from Svelte 4 to 5, avoiding common pitfalls.
  • Use Case: Convert a component to runes and ensure deep reactivity is preserved.

Quick Start

Ask the AI to refactor a traditional Svelte 4 component to use Svelte 5 runes.

Frequently Asked Questions about svelte-runes

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

FAQPage Schema
How do I migrate a Svelte 4 component to use Svelte 5 runes?

Migrate Svelte 4 components to runes by replacing reactive declarations with $state for mutable state, $derived for computed values, and $effect for side effects. This ensures deep reactivity is preserved and components follow Svelte 5's explicit binding model, reducing common pitfalls during the transition.

What's the difference between $state, $derived, and $effect in Svelte 5?

$state creates mutable reactive state, $derived computes values that update when dependencies change, and $effect runs side effects when state changes. Understanding these rune semantics prevents misuse and ensures your component reactivity works correctly in Svelte 5.

When should I use $bindable in Svelte 5 components?

$bindable enables explicit two-way binding between parent and child components in Svelte 5, replacing implicit reactive prop binding. Use it when a child needs to update a parent's state, making data flow transparent and preventing unexpected mutations.

How do I ensure deep reactivity with Svelte 5 runes?

Svelte 5 runes preserve deep reactivity by automatically tracking nested object and array mutations through $state and $derived. Structure your state declarations at the top level and use $derived for computed values to maintain reactivity across your component's entire state tree.

Can I use $attach in Svelte 5 for DOM node references?

$attach lifecycle references DOM nodes during component initialization, replacing traditional ref patterns. Use it alongside $state and $effect to manage DOM interactions and attach event listeners while maintaining clean reactivity semantics.

What common pitfalls should I avoid when refactoring to Svelte 5 runes?

Avoid forgetting to declare top-level rune discipline, mixing reactive declarations with runes inconsistently, and breaking deep reactivity by reassigning entire objects instead of mutating properties. Follow migration guides to catch these patterns before they cause unexpected behavior.