Standardized patterns for Svelte 5 development, including state management with runes and UI component composition.
Install
mkdir -p .claude/skills/svelte && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/1482" && unzip -o skill.zip -d .claude/skills/svelte && rm skill.zipInstalls to .claude/skills/svelte
Activation
This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.
Svelte 5 component and state-module patterns for Epicenter apps. Use when editing `.svelte`, `.svelte.ts`, or Svelte UI state code involving runes, `$props`, snippets, keyed lifecycles, `{#await}`, TanStack Query, SvelteMap, shadcn-svelte, or workspace observers.Key capabilities
- →Implement Svelte 5 runes for reactive values and computed state
- →Manage component lifecycles and reactivity with Svelte 5 features
- →Integrate TanStack Query for data mutations within Svelte components
- →Utilize shadcn-svelte components for UI development
- →Handle component composition using snippets and `{@render}`
- →Avoid legacy Svelte patterns in new runes-mode code
How it works
This skill guides the use of Svelte 5 runes for reactivity, `$state` for mutable values, and `$derived` for computed state. It also covers integrating TanStack Query for data mutations and using shadcn-svelte for UI components.
Inputs & outputs
When to use svelte
- →Implement Svelte 5 runes state
- →Build UI components with shadcn-svelte
- →Manage async data with TanStack Query
- →Refactor Svelte component composition
About this skill
Svelte Guidelines
Keep the first pass focused on Svelte runes, component lifecycle, workspace-backed state, TanStack Query usage, and local UI composition.
Reference Repositories
- Svelte: Svelte 5 framework with runes and fine-grained reactivity
- shadcn-svelte: Port of shadcn/ui for Svelte with Bits UI primitives
- shadcn-svelte-extras: Additional components for shadcn-svelte
Source Checks
- Check Svelte
$props,$bindable, and snippets before changing prop ownership,bind:APIs, orchildrensnippet typing rules. - Check Svelte
{#key},{#await}, and lifecycle hooks before changing keyed resource or async readiness guidance. - Check Svelte
{@attach},use:, andsvelte/attachmentsbefore changing reusable DOM behavior, actions, or attachment guidance. - Check Svelte
svelte/reactivitybefore changingSvelteMap,SvelteSet, or reactive collection guidance. - Check the Svelte 5 migration guide before changing legacy API avoidance, event syntax, slot migration, or callback-prop guidance.
- Check TanStack Svelte Query
createMutationand local installed types before changing mutation lifecycle guidance.
Upstream Grounding
When Svelte 5 runes, compiler behavior, lifecycle, reactivity, snippets, or template behavior affect correctness, use source-backed grounding before relying on memory. If DeepWiki MCP is available, ask a narrow question against sveltejs/svelte; for SvelteKit integration, ask against sveltejs/kit; for shadcn-svelte or extras component APIs, ask against huntabyte/shadcn-svelte or ieedan/shadcn-svelte-extras. If DeepWiki is unavailable or the repo is not indexed, use upstream source or official docs directly. Treat DeepWiki as orientation, then verify decisive details against local installed types, source, or official docs before changing code.
Skip DeepWiki for stable basics and repo-local patterns already documented here or in references.
Related Skills
query-layer: TanStack Query integrationerror-handling: carry Results through operations, then present outcomes at the interaction boundary; includes tagged errors,$lib/report, andextractErrorMessagestyling: CSS and Tailwind conventions, including the flex column scroll trapui-design: visual direction plus loading, empty, pending, tooltip, and component selection patterns
Svelte 5 Baseline
- Use
$statefor reactive values the component mutates in place. Use$state.rawfor values that are only ever reassigned wholesale (large arrays, replace-only persisted stores, opaque handles): it stores by reference with no deep proxy, does not freeze, and reacts only to reassignment, so an in-place property write mutates the object without triggering reactivity or persistence (not an error, but not reactive either). Reach for it when the deep proxy buys reactivity you never use, and when stable value identity matters (for example a store whose value is JSON-serialized or compared by reference). - Prefer
$derivedfor computed state. Treat$effectas a browser-only escape hatch for DOM integration, analytics, subscriptions, and external systems. A returned cleanup runs before the effect re-runs and when the component is destroyed. - Props can change. Compute changing values with
$derivedor read the prop directly where used. Initialize an adapter once only when its owner is fixed for that component instance; reactive properties do not imply changing adapter identity. Read lifecycle and reactivity. - Treat props as parent-owned by default. Use callback props for commands and
$bindableonly for intentional two-way APIs such as UI wrappers,bind:value,bind:open, andbind:ref. Preferbind:value={get, set}over paired read/write props on controlled inputs; see function bindings. - Prefer snippets and
{@render}over slots for new Svelte 5 code. Type exposed snippet props withSnippetfromsvelte; use tuple parameters such asSnippet<[Row]>. - Avoid legacy patterns in runes-mode code:
$:declarations,export let,on:click,<slot>,<svelte:component>,<svelte:self>,beforeUpdate,afterUpdate, andcreateEventDispatcher. - Use event attributes and callback props:
onclick={...},onkeydown={...}, andonSelect={() => ...}style props. Do not addon:directives or dispatch component events in new runes-mode code.
Core Decisions
- When a deferred binding callback loses the narrowing of an optional property, capture that value with
{@const}in the nearest supported template scope containing the controls that need it, then narrow the local before creating the callbacks. Share one local across those controls; use$derivedwhen script code also needs it or no existing template scope supports{@const}before the guard. Nested access alone does not require a local, and an already-narrowed value needs no extra alias. See function bindings. - For a form that submits explicitly, choose its draft owner before adding content state: one draft per submission, preferably a
$state.rawobject updated by replacement. Read input ownership. Keep request, selection, and widget state separate from that draft. - Read a capability (a folder, an auth client,
openAi, a conversation) throughreactive(capability)from@epicenter/svelte/reactive, made once where the capability is made (ADR-0769). It keeps the capability's own names and type: reads stay methods (folder.todos.items(),auth.state(),ai.models()) and track in a template,$derivedor effect; a read in setup or a handler is a snapshot. Actions answer promises and pass through untracked, so an effect may call one (void ai.refresh()) without subscribing to it. Never write a per-capability adapter or getter facade; a capability that needs one does not have the shape yet. When several reads must narrow one value, read it once (const signIn = $derived(auth.state())). - If a disposable resource identity depends on a prop, let the parent own mount and unmount with
{#key}or{#if}; open the resource synchronously in the child. Read lifecycle and reactivity. - If readiness is a stable promise, use
{#await}in the template instead of a$state(false)flag and a cancellation effect. - Keep source reads and actions visible where used: read owner properties such as
session.currentin markup, keep template locals that narrow them for controls, and inline forwarding handlers beside those controls, including short guards when they clarify the interaction. Keep a name when it explains substantial work or owns necessary behavior. Read component and UI patterns and lifecycle and reactivity. - When several template branches render variants of an optional discriminated union, check presence once in an outer block, then branch on its discriminant inside. Repeated optional checks or a forwarding
$derivedalias obscure the shared presence condition; an isolated variant check can use optional chaining. See optional union rendering. - Map finite unions to labels, icons, or other values with a
satisfies Recordlookup, not nested ternaries or$derived.by()switches. Use template branches when variants render different markup or need variant-specific fields. - Use
SvelteMapfor ID-keyed collections whereget,has,size, or iteration should update reactively. Values inside aSvelteMapare not deep-proxied, so store reactive row objects or replace values when nested data changes. Convert maps to stable arrays with$derivedbefore passing them to table-like consumers. - Use
SvelteSetfor an id set whose membership (has,size, iteration) is read in a reactive or template context:add/deletethen drive the UI directly, replacing$state<string[]>plus spread/filter reassignment. Reach forSvelteMapinstead the moment the set needs to carry per-key data (a timestamp, a last error). Use a plainSet/Map(not the reactive class) when the collection is read only in imperative code, such as a subscription's listener bag: a reactive wrapper read outside any effect is cost with no reader. - An app's capabilities are module values (ADR-0766):
src/lib/app.tsexportsfolder,account,aiand the rest, opened synchronously, and editing it reloads the page in development; components,.svelte.tsmodules, event handlers and toasts import them, and nothing passes them through context. The root layout renders<WhenOpen {folder} {settings}>from@epicenter/svelte, so pages render once the folder and this computer's settings have connected, and components read collections straight off it (folder.todos.items()), synchronously (ADR-0778); never add aStartuproot, a per-collection context, or areadyorloading()gate. The component that shows a note makes one editor of it during setup (const todo = todos.edit({ id })), gates on `todo.ex
Content truncated.
When not to use it
- →When DeepWiki is unavailable or the relevant repository is not indexed
- →For stable basics and repo-local patterns already documented in references
Limitations
- →This skill focuses on Svelte 5 patterns and may not apply to older Svelte versions
- →This skill does not cover SvelteKit integration in detail
- →This skill does not provide guidance for `use:` actions in new reusable DOM behavior
How it compares
This skill provides specific guidelines for Svelte 5 patterns, including runes, snippets, and TanStack Query mutations, which differs from general Svelte development by focusing on the latest framework features and best practices.
Compared to similar skills
svelte side by side with the closest alternatives in the catalog.
| Skill | Installs | Updated | Safety | Difficulty |
|---|---|---|---|---|
| svelte (this skill) | 3 | 5mo | No flags | Intermediate |
| admin-crud-page | 1 | 10mo | No flags | Intermediate |
| component-builder | 1 | 10mo | No flags | Beginner |
| svelte-ui-design | 23 | 1y | No flags | Intermediate |
Try saying
Example prompts that trigger this skill in your AI assistant.
More by EpicenterHQ
View all by EpicenterHQ →You might also like
admin-crud-page
svelte-society
Create admin dashboard pages with tables, forms, and actions
component-builder
svelte-society
Create UI components using tailwind-variants for type-safe styling. Use when creating or editing components in src/lib/ui/.
svelte-ui-design
XIYO
ALWAYS use this skill for ANY Svelte component styling, design, or UI work. Svelte 5 UI design system using Tailwind CSS 4, Skeleton Labs design tokens/presets/Tailwind Components, and Bits UI headless components. Covers class composition, color systems, interactive components, forms, overlays, and all visual design.
tanstack-form
exceptionless
TanStack Form with Zod validation in Svelte 5. Form state management, field validation, error handling, and ProblemDetails integration. Keywords: TanStack Form, createForm, Field, form validation, zod schema, form errors, onSubmit, onSubmitAsync, problemDetailsToFormErrors
tanstack-query
exceptionless
Data fetching and caching with TanStack Query in Svelte. Query patterns, mutations, cache invalidation, WebSocket-driven updates, and optimistic updates. Keywords: createQuery, createMutation, TanStack Query, query keys, cache invalidation, optimistic updates, refetch, stale time, @exceptionless/fetchclient, WebSocket
svelte-migrate
temporalio
Migrate a Svelte 4 component to Svelte 5 runes syntax. Use when asked to migrate, convert, or upgrade a .svelte file to Svelte 5.