Skip to content

skillFrontendsvelte

Svelte Runes Components

Builds Svelte 5 components with runes and snippets, and replaces stores and legacy reactive statements. Use it when writing or upgrading Svelte code.

npx workspacetemplates add svelte-runes-components --tool claude-code

Writes 1 file to .claude/skills/svelte-runes-components/

.claude/skills/svelte-runes-components/SKILL.md26 lines · 1.6 KBFile
---
name: svelte-runes-components
description: Builds Svelte 5 components with runes and snippets, and replaces stores and legacy reactive statements. Use it when writing or upgrading Svelte code.
---

# Svelte runes components

Write Svelte 5. If the file uses `export let`, `$:` or `<slot>`, convert it unless the user said to leave it.

## Rules

1. Props: `let { title, items = [], onselect }: Props = $props();` with an `interface Props` above it. Callback props replace `createEventDispatcher`.
2. Local state is `$state`. When two components need the same state, export it from a `.svelte.ts` module as an object, never as a bare reassigned primitive.
3. Anything computed from state is `$derived` (use `$derived.by` for multi-line logic). Never assign to another `$state` inside an effect to mirror a value.
4. `$effect` is the last resort: DOM measurement, third-party widgets, syncing to storage. Return a cleanup function for every listener or timer. Reading a signal after an `await` inside an effect does not track it.
5. Replace `<slot>` with `{#snippet}` and `{@render children?.()}`. Typed snippet props use `Snippet<[Item]>`.
6. Bindable props need `$bindable()` and a reason: prefer a callback.
7. Deeply mutated arrays and objects are fine in `$state` (they are proxied); use `$state.raw` for large read-only data from an API.

## Verify

Run `npx svelte-check` and fix every warning that mentions state or reactivity. Open the dev server only if the user asked.

## Report

List each legacy construct you replaced and any `$effect` you kept, with the reason it could not be `$derived`.

What it does

Models still produce Svelte 4 code by habit: export let, the dollar-label reactive statements, slots and writable stores. Those still compile in Svelte 5, but they fight the new compiler and confuse a reader who expects runes.

This skill makes the agent write runes-first components, choose between state, derived and effect with care, and use snippets instead of slots for anything that needs arguments.

Example

you › Convert Cart.svelte to Svelte 5 and get rid of the cart store

agent › Converted Cart.svelte to runes. The writable store became cart.svelte.ts exporting a `$state` object with add and remove functions. The total is a `$derived`; the old reactive block that wrote it is gone. One `$effect` remains, persisting to localStorage with a cleanup. svelte-check reports 0 warnings.

Questions

Will it break components that still use Svelte 4 syntax?
It only converts files it is working on. Mixed projects run fine, so you can move one component at a time.
Why is effect treated as a last resort?
Effects run after render and invite loops. A derived value is computed on demand and cannot get out of sync.
  • Bundle Size Reduction

    Skilljavascript

    Free