Svelte v4
Use when writing or modifying Svelte v4 components (.svelte files targeting svelte@^4). Triggers - "Svelte 4", "Svelte v4", "legacy Svelte", projects with `"svelte": "^4"` in package.json. CRITICAL - do NOT use Svelte 5 runes ($state, $derived, $effect, $props, $bindable, $inspect) or snippets ({#snippet}, {@render}) here. For Svelte 5 projects skip this skill.From its SKILL.md
npx -y skills add aimuzov/claude-svelte-v4 --skill svelte-v4Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- 0 stars0 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.
SKILL.md
5.4 KB, as published. Nobody here has run it
Svelte v4
Expert guidance for authoring Svelte v4 components. Covers core runtime and template syntax only — SvelteKit is out of scope for this skill.
When to use
Activate on any of:
- File extension is
.svelteand the project'spackage.jsonlistssvelte@^4/~4.x/ exact4.x.y. - User explicitly says "Svelte 4", "Svelte v4", "legacy Svelte".
- Existing code uses
export let,$:,createEventDispatcher,<slot>— all v4 idioms.
When to skip
svelte@^5inpackage.json— use runes/snippets idioms instead.- File already uses
$state,$derived,$effect,{#snippet},{@render}— it is Svelte 5. - User asks about SvelteKit routing,
load,form actions,hooks.server.ts— that's a different domain.
Version detection workflow
Before editing any .svelte file:
Read package.jsonat the project root.- Check
devDependencies.svelteordependencies.svelte. - If version is
^4.x,~4.x, or an exact4.x.y→ this skill applies. - If version is
^5.x/next/beta→ abort and use Svelte 5 idioms. - If no
svelteentry or ambiguous (git dep, workspace*) → ask the user which major version.
Hard DON'Ts in v4
Never generate or suggest:
- Runes:
$state,$state.raw,$state.snapshot,$derived,$derived.by,$effect,$effect.pre,$effect.root,$effect.tracking,$props,$bindable,$inspect,$host. - Snippets:
{#snippet name(params)}…{/snippet},{@render snippet(args)},childrenprop as a function. - New utilities:
untrack(),mount(),hydrate(),unmount(),getAllContexts()usage outside init,svelte/reactivityclasses (SvelteMap,SvelteSet,SvelteDate,SvelteURL). - New element API:
$host()for custom-element exports.
If the user asks for any of those, stop and confirm — they may be in the wrong skill.
Core v4 primitives (cheat-sheet)
<script lang="ts">
import { onMount, createEventDispatcher, tick } from 'svelte';
import { writable, derived } from 'svelte/store';
export let count = 0; // prop with default
export let label: string; // required prop
export const version = '1.0'; // read-only export
const dispatch = createEventDispatcher<{ change: number }>();
const store = writable(0);
const doubled = derived(store, ($s) => $s * 2);
$: parity = count % 2 === 0 ? 'even' : 'odd'; // reactive declaration
$: if (count > 10) dispatch('change', count); // reactive side-effect
onMount(() => {
const id = setInterval(() => store.update((n) => n + 1), 1000);
return () => clearInterval(id);
});
function increment() {
count += 1;
}
</script>
<button on:click={increment} class:big={count > 5}>
{label}: {count} ({parity}) — store={$store}, doubled={$doubled}
</button>
<slot name="footer" {count} />
<style>
button { padding: 0.5rem 1rem; }
.big { font-size: 1.25rem; }
</style>
Deep references
Load the relevant reference file when you need detail — don't guess. Paths are relative to this skill directory.
references/component.md— component anatomy, props, events, slots, bindings, TypeScript, client-side API (new Component,$set,$on,$destroy).references/reactivity.md—$:labels, stores (writable/readable/derived), auto-subscription, common pitfalls.references/lifecycle.md—onMount,onDestroy,beforeUpdate,afterUpdate,tick, Context API, SSR gotchas.references/template.md—{#if}/{#each}/{#await}/{#key}, directives (class:,style:,use:,transition:,animate:), special elements (<svelte:…>), actions, built-in transitions/animations.references/motion.md—svelte/motion(tweened,spring) andsvelte/easing(31 named functions).references/accessibility.md— full list ofa11y-*compile warnings with descriptions, common fix patterns.
External docs
Canonical reference: https://v4.svelte.dev/docs/. Svelte does not ship an llms.txt for v4 (only v5) — use WebFetch against specific v4 doc pages when you need detail beyond this skill:
https://v4.svelte.dev/docs/component-formathttps://v4.svelte.dev/docs/template-syntaxhttps://v4.svelte.dev/docs/special-elementshttps://v4.svelte.dev/docs/svelte(module:onMount,tick,createEventDispatcher, etc.)https://v4.svelte.dev/docs/svelte-store,/svelte-motion,/svelte-transition,/svelte-animate,/svelte-easing,/svelte-actionhttps://v4.svelte.dev/docs/client-side-component-apihttps://v4.svelte.dev/docs/typescripthttps://v4.svelte.dev/docs/accessibility-warnings
Migration guardrail
- If the user asks to migrate v4 → v5 (or vice versa), do not rewrite silently. Outline the diff (
export let→$props,$:→$derived/$effect, slots → snippets,createEventDispatcher→ callback props) and confirm scope first. - Never mix v4 and v5 idioms in the same file — the compiler accepts one mode per component.