| name | svelte5 |
| description | Guidance for building Svelte 5 components with runes, JSDoc-typed props/state, snippets/slots, events, and accessibility/styling. Use when editing `.svelte` files, designing component APIs, handling component state/effects, or debugging rendering issues; pair with `sveltekit2` for routing/load/action work. |
Svelte 5
Overview
Use this skill for component-level work in Svelte 5: runes-based state, props/events, snippets/slots, styling, and accessibility. For routing, load/actions, or endpoints, load the companion sveltekit2 skill alongside this one.
Quick start
- Reach for official syntax when uncertain: https://svelte.dev/docs/llms.txt (light) or https://svelte.dev/docs/llms-full.txt (full).
- Check repo conventions before coding:
.github/AGENTS.md,.github/AGENTS-SVELTE.md,.github/AGENTS-SVELTE-JSDocs.md. If doing SEO/GEO, also.github/AGENTS-SEO-GEO.md. - Prefer
$state,$derived,$effect,$props,$bindablefor reactivity; keep components small and extract shared pieces to$lib. - Document props/state with JSDoc before
$props()destructuring; type event payloads and async handlers. - Keep styling scoped; reuse existing tokens/utilities; ensure ARIA/keyboard support on interactive elements.
- Treat error handling as part of the component contract: use
svelte:boundaryor shared ErrorBoundary components, surface user-friendly fallbacks, and let unrecoverable faults bubble to SvelteKit error routes. - If the change touches data loading/mutations/routing, pull in the
sveltekit2skill for load/actions/endpoint patterns.
Workflow
- Clarify component contract: props (typed), events, slots/snippets, bindables. Keep single responsibility and reuse
$libfor shared logic. - Model state with runes (
$statefor local mutation,$derivedfor computed values,$effectfor side-effects). Guard expensive effects and clean up subscriptions. - Compose UI with snippets/slots; pass fallbacks via snippets for resilience.
- Wire events with
createEventDispatcheror callbacks; type payloads. Sanitize any HTML before{@html ...}. - Style and ensure accessibility: semantic elements, labels/roles, focus order, keyboard handlers. Use keyed
{#each}for lists and minimal work inside effects. - Test when behavior changes. For SvelteKit apps, see
sveltekit2references for Vitest/Playwright commands.
References
references/runes.md— rune patterns for props/state/effects, snippets, events/bindings.references/components-and-testing.md— component composition, accessibility/styling reminders, and lightweight test pattern; seesveltekit2for app-level CLI/tests.