Apply Epicenter’s Svelte 5 patterns for runes, components, lifecycles, and workspace-backed state. Use when editing `.svelte`, `.svelte.ts`, or Svelte UI state.
89%
Does it follow best practices?
Run evals on this skill
Adds up to 20 points to the overall score
Passed
No findings from the security scan
Keep the first pass focused on Svelte runes, component lifecycle, workspace-backed state, TanStack Query usage, and local UI composition.
$props, $bindable, and snippets before changing prop ownership, bind: APIs, or children snippet typing rules.{#key}, {#await}, and lifecycle hooks before changing keyed resource or async readiness guidance.{@attach}, use:, and svelte/attachments before changing reusable DOM behavior, actions, or attachment guidance.svelte/reactivity before changing SvelteMap, SvelteSet, or reactive collection guidance.createMutation and local installed types before changing mutation lifecycle guidance.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.
query-layer: TanStack Query integrationerror-handling: carry Results through operations, then present outcomes at the interaction boundary; includes tagged errors, $lib/report, and extractErrorMessagestyling: CSS and Tailwind conventions, including the flex column scroll trapui-design: visual direction plus loading, empty, pending, tooltip, and component selection patterns$state for reactive values the component mutates in place. Use $state.raw for 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).$derived for computed state. Treat $effect as 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.$derived or 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.$bindable only for intentional two-way APIs such as UI wrappers, bind:value, bind:open, and bind:ref. Prefer bind:value={get, set} over paired read/write props on controlled inputs; see function bindings.{@render} over slots for new Svelte 5 code. Type exposed snippet props with Snippet from svelte; use tuple parameters such as Snippet<[Row]>.$: declarations, export let, on:click, <slot>, <svelte:component>, <svelte:self>, beforeUpdate, afterUpdate, and createEventDispatcher.onclick={...}, onkeydown={...}, and onSelect={() => ...} style props. Do not add on: directives or dispatch component events in new runes-mode code.{@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 $derived when 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.$state.raw object updated by replacement. Read input ownership. Keep request, selection, and widget state separate from that draft.openAi, a conversation) through reactive(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, $derived or 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())).{#key} or {#if}; open the resource synchronously in the child. Read lifecycle and reactivity.{#await} in the template instead of a $state(false) flag and a cancellation effect.session.current in 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.$derived alias obscure the shared presence condition; an isolated variant check can use optional chaining. See optional union rendering.satisfies Record lookup, not nested ternaries or $derived.by() switches. Use template branches when variants render different markup or need variant-specific fields.SvelteMap for ID-keyed collections where get, has, size, or iteration should update reactively. Values inside a SvelteMap are not deep-proxied, so store reactive row objects or replace values when nested data changes. Convert maps to stable arrays with $derived before passing them to table-like consumers.SvelteSet for an id set whose membership (has, size, iteration) is read in a reactive or template context: add/delete then drive the UI directly, replacing $state<string[]> plus spread/filter reassignment. Reach for SvelteMap instead the moment the set needs to carry per-key data (a timestamp, a last error). Use a plain Set/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.src/lib/app.ts exports folder, account, ai and the rest, opened synchronously, and editing it reloads the page in development; components, .svelte.ts modules, 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 a Startup root, a per-collection context, or a ready or loading() gate. The component that shows a note makes one editor of it during setup (const todo = todos.edit({ id })), gates on todo.exists() (a note that reads is listed), reads and binds every value through todo.fields (bind:value={todo.fields.title}, bind:checked={todo.fields.done}), or the whole note through todo.text, instead of a second get or a prop. The editor keeps typed fields until their save lands, and a save never fails, so a view shows no save error; <WhenOpen> says when the store is out of reach (folder.unavailable()). Code that is not typing (a list row's toggle, a workflow) writes with set(args, changes) and delete(args), which answer once they land (ADR-0774, ADR-0775). Product state that is not a capability lives in the app's own objects, created once. See Contract reads and editing.window events, an auth store) into reactivity with createSubscriber from svelte/reactivity, not a hand-rolled $state plus $effect plus listener set: reads inside an effect become reactive and the subscription is ref-counted to effect usage (start on first subscriber, cleanup at zero). A capability with subscribe needs none of this: reactive already does it (packages/svelte/src/reactive.ts). Keep a manual listener set only when the same source also serves imperative .get()/.watch() consumers whose liveness cannot ride on effect ref-counting.{@attach} attachments over new use: actions. Keep use: for existing code or libraries that only expose actions..svelte files and call mutation.mutate(...) directly from template handlers unless the action earns a semantic helper. Read mutations and workspace inputs.edit), which saves as the person types.label="Loading {name}", href="/users/{id}") instead of a JavaScript template literal attribute. Keep expression attributes for non-string values, callbacks, objects, booleans, and cases where the entire attribute is a computed JavaScript expression.Props only when a wrapper, generic relationship, exported contract, or native DOM type composition earns it. Push large view-mode branches into focused child components. Read component and UI patterns.@epicenter/ui loading, empty, pending, and tooltip components before ad hoc markup.$effect cleanup, template locals, stable adapters, value maps, SvelteMap, table state, or .svelte.ts state modules.await, or workspace-backed text inputs.@epicenter/ui imports, $props typing, $bindable, function bindings, snippets, DOM attachments, self-contained dialogs, view branching, repetitive markup, single-use helper inlining, loading or empty states, prop-first derivation, or template text gotchas.EpicenterHQ/epicenter
04f87cb
If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.