svelte-migrate
БесплатноБез исполняемых скриптовНе проверенMigrate a Svelte 4 component to Svelte 5 runes syntax. Use when asked to migrate, convert, or upgrade a .svelte file to Svelte 5.
Об этом скилле
Svelte 4 to 5 Migration
Migrate individual Svelte files from v4 to v5 runes syntax.
Usage
When the user provides a file path, migrate that specific file following the patterns below.
Migration Patterns
1. Props: export let → $props()
Before:
<script lang="ts">
export let name: string;
export let count = 0;
export let optional: string | undefined = undefined;
let className = '';
export { className as class };
</script>
After:
<script lang="ts">
interface Props {
name: string;
count?: number;
optional?: string;
class?: string;
}
let { name, count = 0, optional, class: className = '' }: Props = $props();
</script>
2. State: let → $state()
Only reactive variables that are reassigned or mutated need $state().
Before:
<script lang="ts">
let count = 0;
let items = [];
</script>
After:
<script lang="ts">
let count = $state(0);
let items = $state<string[]>([]);
</script>
3. Derived Values: $: → $derived()
Before:
<script lang="ts">
$: doubled = count * 2;
$: filtered = items.filter((i) => i.active);
</script>
After:
<script lang="ts">
const doubled = $derived(count * 2);
const filtered = $derived(items.filter((i) => i.active));
</script>
For complex derivations use $derived.by():
Before:
<script lang="ts">
$: {
let total = 0;
for (const item of items) total += item.value;
sum = total;
}
</script>
After:
<script lang="ts">
const sum = $derived.by(() => {
let total = 0;
for (const item of items) total += item.value;
return total;
});
</script>
4. Side Effects: $: statements → $effect()
Before:
<script lang="ts">
$: console.log('count changed:', count);
$: if (count > 10) alert('High count!');
$: document.title = `Count: ${count}`;
</script>
After:
<script lang="ts">
$effect(() => {
console.log('count changed:', count);
});
$effect(() => {
if (count > 10) alert('High count!');
});
$effect(() => {
document.title = `Count: ${count}`;
});
</script>
5. Event Handlers: on:event → onevent
Before:
<button on:click={handleClick}>Click</button>
<button on:click={() => count++}>Increment</button>
<button on:click|preventDefault={submit}>Submit</button>
<input on:input={handleInput} on:focus={handleFocus} />
After:
<button onclick={handleClick}>Click</button>
<button onclick={() => count++}>Increment</button>
<button
onclick={(e) => {
e.preventDefault();
submit(e);
}}>Submit</button
>
<input oninput={handleInput} onfocus={handleFocus} />
Event modifiers like |preventDefault, |stopPropagation must be handled manually in the handler.
6. Component Events: createEventDispatcher → callback props
Before:
<script lang="ts">
import { createEventDispatcher } from 'svelte';
const dispatch = createEventDispatcher<{
change: string;
submit: { data: FormData };
}>();
function handleChange(value: string) {
dispatch('change', value);
}
</script>
After:
<script lang="ts">
interface Props {
onchange?: (value: string) => void;
onsubmit?: (data: { data: FormData }) => void;
}
let { onchange, onsubmit }: Props = $props();
function handleChange(value: string) {
onchange?.(value);
}
</script>
Parent component changes:
Before: <Child on:change={handler} />
After: <Child onchange={handler} />
7. Forwarding Events: on:event → explicit handler
Before:
<button on:click>Click me</button>
After:
<script lang="ts">
interface Props {
onclick?: (e: MouseEvent) => void;
}
let { onclick }: Props = $props();
</script>
<button {onclick}>Click me</button>
8. Slots → Snippets
Default slot:
Before:
<slot />
After:
<script lang="ts">
import type { Snippet } from 'svelte';
interface Props {
children?: Snippet;
}
let { children }: Props = $props();
</script>
{@render children?.()}
Named slots:
Before:
<slot name="header" />
<slot />
<slot name="footer" />
After:
<script lang="ts">
import type { Snippet } from 'svelte';
interface Props {
header?: Snippet;
children?: Snippet;
footer?: Snippet;
}
let { header, children, footer }: Props = $props();
</script>
{@render header?.()}
{@render children?.()}
{@render footer?.()}
Slots with props (let:):
Before:
<slot item={currentItem} index={i} />
<!-- Usage -->
<List {items} let:item let:index>
<span>{index}: {item.name}</span>
</List>
After:
<script lang="ts">
import type { Snippet } from 'svelte';
interface Props {
children?: Snippet<[{ item: Item; index: number }]>;
}
let { chi
Установить svelte-migrate в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл svelte-migrate?
Migrate a Svelte 4 component to Svelte 5 runes syntax. Use when asked to migrate, convert, or upgrade a .svelte file to Svelte 5.
Как установить скилл svelte-migrate?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл svelte-migrate запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
theme-factory
Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
от Anthropicaccess
Manage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropicconfigure
Set up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
от Anthropicaccess
Manage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropic