Programming svelte
Octomind Agents Registry
npx -y skills add Muvon/octomind-tap --skill programming-svelteAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- 3 stars3 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
What its author says it does
Copied from the file, not written here
Svelte 5 runes, SvelteKit architecture, server/client boundaries, and progressive enhancement. Auto-activates in Svelte projects.
The file declares its own license as Apache-2.0. That is the author’s claim about this one file, and it is not the same thing as the license GitHub reports for the repository, which is listed with the other numbers below.
SKILL.md
5.1 KB, as published. Nobody here has run it
Mental model
Svelte 5 compiles components to small, efficient updates; SvelteKit adds routing, server-side rendering, and form actions on top. The Svelte advantage is its compiler — most apps need very little client state management, no global store libraries, and no useEffect-style synchronization. Most maintenance trouble comes from importing React habits: pushing everything client-side, manual derived state, and effects doing the job of derivations.
Runes (Svelte 5)
$state(...)for reactive local state — replaces top-levelletreactivity$derived(...)for computed values — replaces the old$:reactive blocks; deep dependency tracking is automatic$effect(...)for side effects only (DOM, subscriptions, non-Svelte libraries) — never for derived values$props()for typed component props;$bindable()for two-way bindable props- Runes work in
.svelte.ts/.svelte.jsfiles too — extract reactive logic into modules - Avoid effects that read state and write state — they create loops and obscure data flow
Component design
- One component per
.sveltefile;<script lang="ts">→ markup →<style>ordering - Props are an API — type them with
$props<{...}>()and document defaults - Snippets (Svelte 5) replace slots for reusable markup with parameters
- Keep components small; extract sub-components when sections have their own state or events
- Scoped styles by default — global styles only via
:global(...)when intentional
SvelteKit architecture
- File-based routing in
src/routes/:+page.svelte(page),+layout.svelte(shared layout),+page.ts/+page.server.ts(load),+server.ts(API endpoints) +page.server.tsruns only on the server — safe for database queries, secrets, server-only deps+page.tsruns on both server and client (universal) — pure data fetching that can hydrateloadfunctions return data the page renders; throwredirect()/error()for control flow- Layouts compose; place shared data loading at the layout level and child pages inherit via
$page.data hooks.server.tsfor cross-cutting concerns: auth, request logging, CSRF, response headers
Forms and mutations
- Form actions (
+page.server.tsactions = { default: ... }) for mutations — progressive-enhancement friendly, work without JS use:enhanceupgrades the form to a fetch-driven submission with optimistic updates- Validate on the server; share validation schemas (zod/valibot) between client and server when both validate
- Return validation errors from actions; the page renders them via
formprop - Use API endpoints (
+server.ts) for non-form mutations, third-party integrations, or non-HTML responses
State management
- Local reactive state with
$statecovers most needs — no global store library required for typical apps - Cross-component shared state: a module exporting a
$stateobject, imported where needed - The
$pagestore and SvelteKit'sgoto/invalidatecover URL-driven state and re-fetching - Persist state in URL search params, cookies, or localStorage — not in long-lived module-level reactive state across navigations
- Avoid the legacy
writable/readable/derivedstores for new code unless interop demands them — runes replace them
Server/client boundary
- Server-only code lives in
+page.server.ts,+server.ts,+layout.server.ts, and$lib/server/— anything else may be bundled to the client - Secrets and server-only modules go behind the
$lib/server/boundary; SvelteKit fails the build if they leak to client code - Environment variables:
$env/static/private(server, build-time),$env/static/public(client-safe, build-time),$env/dynamic/*(runtime) - Stream data with
await streamed.fooin load functions — page renders progressively without blocking on slow data
Performance
- Svelte's compiler already optimizes updates — micro-optimizations are rarely needed
- Code-split happens at route boundaries automatically
- Lazy-load heavy components with dynamic
import()when they're conditionally rendered - Use
{#key value}{/key}to force a subtree to recreate when identity changes
Testing
- Vitest for unit and component logic
@testing-library/sveltefor component tests — query by role and text, not by component internals- Playwright for end-to-end flows — particularly important for form actions and progressive enhancement paths
- Mock at the network layer (MSW) rather than mocking
fetch
Project layout
src/lib/for reusable code ($libalias);src/lib/server/for server-only modules- Feature folders inside
src/lib/when the app grows; routes stay slim and import features - Components, types, and utilities colocated by feature, not split by kind