/svelte-5:composition-sveltefrom svelte-5
Guides Svelte 5 component composition decisions: shape, snippet API, and state location. Covers provider/wrapper patterns, third-party DOM bridging (maplibre, leaflet, d3), and overlay a11y.
Ships in svelte-5. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Decompose a Svelte 5 feature by ROLE. Wrong role assignment is the root cause of every architectural fuckup. Before generating files, pin three decisions: composition shape, snippet API, state location. Per-file contracts fall out from those.
Rules from frontend:code-style, svelte-5:code-style-svelte, frontend:editing, frontend:comments, svelte:svelte-code-writer, svelte:svelte-core-bestpractices apply throughout. Run mcp__plugin_svelte_svelte__svelte-autofixer after every .svelte edit.
bind:this$effect(() => { new ThirdPartyThing(...) })prop={appState.x} or prop={someStore.value}Default.svelte / Feature.svelte / Wrapper.sveltesetDOMContent / appendChild(svelteRenderedNode) / similarMarker, leaflet L.marker, d3 selection:global(...) inside a wrapper's <style> blockSkip for: CSS-only tweaks, test-only edits, backend / non-Svelte work.
Answer in writing BEFORE generating files. Full tables and pointers in references/decisions.md.
children, named snippets, or mix?.svelte.ts modules (module-level $state exports, classes with $state fields), component-local $state, context (createContext), existing global state.If intent is ambiguous, ask via AskUserQuestion, never infer silently.
| Need | Read |
|---|---|
| Picking shape and snippet/state design | references/decisions.md |
| Composition shape, seven-role contract + folder structure (covers both caller-content and view-dispatcher / Provider behaviour) | references/composition-shape.md |
| Non-Svelte Host shape | references/non-svelte-host.md |
| Lifecycle rune choice | references/lifecycle.md |
| Bridging to a third-party DOM library | references/third-party.md |
A11y for overlays (focus, ESC, :focus-visible) | references/a11y-overlays.md |
CSS scope (avoiding :global()) | references/css-scope.md |
| Counter-arguments for common rationalizations | references/rationalizations.md |
Default.svelte alone is too vague: DefaultItems.svelte reads. Feature.svelte / Wrapper.svelte are banned for new code.subscribeX/unsubscribeX for event subscription; attachX/detachX for Svelte {@attach} lifecycle; mountX/unmountX for component lifecycle; createX/destroyX for factory pairs. Don't conflate.frontend:code-style: element not el; event not e; result not res.$utils/domActions.ts for all DOM attachments). NOT one file per export.When a pattern appears in 2+ components, extract to $utils/<category>.ts. Don't pre-extract, first use is inline; second triggers the move.
Delegate creating, editing, or reviewing any .svelte / .svelte.ts / .svelte.js file to the svelte:svelte-file-editor subagent (per agent:before-you-act "Consider before doing it yourself"), multi-file refactors most of all. The subagent runs in its own context window, so its docs lookup (mcp__plugin_svelte_svelte__get-documentation) and autofixer iteration (mcp__plugin_svelte_svelte__svelte-autofixer) don't spend the main agent's context.
UX bugs in overlay-style components almost always span ALL overlay-style components. On fix: grep for analogous (role="menu", tabindex="-1", onkeydown.*Escape), confirm, apply symmetrically in the same change, test both.
Overlay-specific. Other feature types (forms, tables, panels without close behaviour) need their own done-matrix, write one local to that feature, mirroring this structure (interactions and their expected post-state, exit paths, regression neighbours). Before declaring an overlay feature done, run ALL of these in a real browser via Playwright MCP:
closeOnClick: both clearedreferences/composition-shape.md Controller)mcp__plugin_svelte_svelte__svelte-autofixer: zero new issues. $effect calling function advisories on imperative third-party calls are OK; bind:this suggestions are NOT.Per agent:done: declaring done before this matrix is fraudulent. Per agent:asshole: don't dismiss failures as "not my problem".
| Red flag | Means | Fix |
|---|---|---|
prop={appState.x} / prop={someStore.value} | Prop-drilling a global | Import the store, read it directly |
bind:this with {@attach} autofixer suggestion | Wrong tool for element augmenters | references/lifecycle.md + references/third-party.md |
Default.svelte / Feature.svelte / Wrapper.svelte | Role not conveyed | Role-specific name |
| Third-party library import (maplibre / leaflet / d3 / etc.) inside the markup-only file mounted into a third-party container | Wrong axis | Move bridging to the parent Wrapper. See references/third-party.md. |
$effect(() => new ThirdPartyThing(...)) for one-shot setup | Wrong rune | onMount + cleanup return |
$effect writing to $state | Wrong rune | $derived |
| Fixing ESC for one menu only | Other menus have the same bug | Symmetric coverage |
| Two overlays visible simultaneously | Opened directly instead of through the Controller's handler | Funnel every open through the Controller's handler, it closes any prior overlay before opening the new one. See references/composition-shape.md Controller. |
| Auxiliary element (marker dot, badge, etc.) still visible after popup auto-close | Visibility gated on popup.isOpen(), but the third-party lib fires 'close' AFTER popup.remove() | Reconcile unconditionally on open; addTo/remove are idempotent |
| Snippet inlined in consumer feels too long | Time to extract | <script module> re-export, references/composition-shape.md |
attachX named but uses map.on() | Verb mismatch | subscribeX |
:global(button) in a wrapper's <style> | Wrong place to style children | references/css-scope.md |
el / e / tmp variable names | Code-style violation | Rename |
When tempted to rationalize, read references/rationalizations.md.
references/a11y-overlays.md (opens in a new tab)references/composition-shape.md (opens in a new tab)references/css-scope.md (opens in a new tab)references/decisions.md (opens in a new tab)references/lifecycle.md (opens in a new tab)references/non-svelte-host.md (opens in a new tab)references/rationalizations.md (opens in a new tab)references/third-party.md (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub fubits1/svelte-skills --plugin svelte-58 skills in this plugin
/code-style-svelteSvelte component code style rules. Auto-invoke when creating .svelte files, editing component structure, transitions or layout reads, or SvelteKit URL state and navigation guards. Covers component docs and Svelte style conventions./doc-componentDocument a Svelte component using @component JSDoc. Auto-invoke when asked to document a .svelte component. Reads the component, analyzes its interface, and writes a structured @component comment block./mswMocks HTTP with msw 3 in Svelte, Storybook, Vitest and SvelteKit. Use when writing http.get handlers or parameters.msw, upgrading from msw 2, or debugging blank stories, handler order, query strings, onUnhandledFrame or mockServiceWorker.js./storybookStorybook authoring and browser checks for Svelte: MCP instructions, previews, Svelte 4 store wrappers, CSS imports in preview.ts. Use when writing or reviewing .stories.svelte files, moving a CSS import that stories need, or a story renders empty./storybook-vitestSvelte CSF stories as Vitest browser tests via @storybook/addon-vitest: play, tags, decorators, asChild. Use when wiring or debugging them in Vitest/CI, or on 'Vitest failed to find the current suite' or props_invalid_value. Not for React/Vue./testing-svelteFix or write Svelte 5 tests with vitest-browser-svelte and Playwright. Use when debugging broken or flaky tests, 'Cannot connect to the iframe', strict mode violations, or writing unit/SSR/e2e tests.Other plugins' skills for the same job