svelte-development
БесплатноБез исполняемых скриптовНе проверенComprehensive Svelte development skill covering reactivity runes, components, stores, lifecycle, transitions, and modern Svelte 5 patterns
Об этом скилле
Svelte Development Skill
This skill provides comprehensive guidance for building modern Svelte applications using reactivity runes (Svelte 5), components, stores, lifecycle hooks, transitions, and animations based on official Svelte documentation.
When to Use This Skill
Use this skill when:
- Building high-performance web applications with minimal JavaScript overhead
- Creating single-page applications (SPAs) with reactive UI
- Developing interactive user interfaces with compile-time optimization
- Building embedded widgets and components with small bundle sizes
- Implementing real-time dashboards and data visualizations
- Creating progressive web apps (PWAs) with excellent performance
- Developing component libraries with native reactivity
- Building server-side rendered applications with SvelteKit
- Migrating from frameworks with virtual DOM to compiled approach
- Creating accessible and performant web applications
Core Concepts
Reactivity with Runes (Svelte 5)
Svelte 5 introduces runes, a new way to declare reactive state with better TypeScript support and clearer semantics.
$state Rune:
<script>
let count = $state(0);
let user = $state({ name: 'Alice', age: 30 });
function increment() {
count++;
}
function updateAge() {
user.age++;
}
</script>
<button on:click={increment}>
Count: {count}
</button>
<button on:click={updateAge}>
{user.name} is {user.age} years old
</button>
$derived Rune:
<script>
let count = $state(0);
let doubled = $derived(count * 2);
let quadrupled = $derived(doubled * 2);
// Complex derived values
let users = $state([
{ name: 'Alice', active: true },
{ name: 'Bob', active: false },
{ name: 'Charlie', active: true }
]);
let activeUsers = $derived(users.filter(u => u.active));
let activeCount = $derived(activeUsers.length);
</script>
<p>Count: {count}</p>
<p>Doubled: {doubled}</p>
<p>Quadrupled: {quadrupled}</p>
<p>Active users: {activeCount}</p>
$effect Rune:
<script>
let count = $state(0);
let name = $state('Alice');
// Effect runs when dependencies change
$effect(() => {
console.log(`Count is now ${count}`);
document.title = `Count: ${count}`;
});
// Effect with cleanup
$effect(() => {
const interval = setInterval(() => {
count++;
}, 1000);
return () => {
clearInterval(interval);
};
});
// Conditional effects
$effect(() => {
if (count > 10) {
console.log('Count exceeded 10!');
}
});
</script>
$props Rune:
<script>
// Type-safe props in Svelte 5
let { name, age = 18, onClick } = $props();
// With TypeScript
interface Props {
name: string;
age?: number;
onClick?: () => void;
}
let { name, age = 18, onClick }: Props = $props();
</script>
<div>
<h2>{name}</h2>
<p>Age: {age}</p>
{#if onClick}
<button on:click={onClick}>Click me</button>
{/if}
</div>
Components
Components are the building blocks of Svelte applications. Each component is a single file with script, markup, and styles.
Basic Component Structure:
<script>
// Component logic
let name = $state('World');
let count = $state(0);
function handleClick() {
count++;
}
</script>
<!-- Component markup -->
<div class="container">
<h1>Hello {name}!</h1>
<p>Count: {count}</p>
<button on:click={handleClick}>Increment</button>
</div>
<!-- Component styles (scoped by default) -->
<style>
.container {
padding: 1rem;
border: 1px solid #ccc;
border-radius: 8px;
}
h1 {
color: #ff3e00;
font-size: 2rem;
}
button {
background: #ff3e00;
color: white;
border: none;
padding: 0.5rem 1rem;
border-radius: 4px;
cursor: pointer;
}
button:hover {
background: #ff5722;
}
</style>
Component Props:
<!-- Card.svelte -->
<script>
let { title, description, imageUrl, onClick } = $props();
</script>
<div class="card" on:click={onClick}>
{#if imageUrl}
<img src={imageUrl} alt={title} />
{/if}
<h3>{title}</h3>
<p>{description}</p>
</div>
<style>
.card {
border: 1px solid #ddd;
border-radius: 8px;
padding: 1rem;
cursor: pointer;
transition: transform 0.2s;
}
.card:hover {
transform: translateY(-4px);
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}
img {
width: 100%;
border-radius: 4px;
}
</style>
Component Events:
<!-- Button.svelte -->
<script>
import { createEventDispatcher } from 'svelte';
let { variant = 'primary', disabled = false } = $props();
const dispatch = createEventDispatcher();
function handleClick() {
dispatch('click', { timestamp: Date.now() });
}
</script>
<button
class="btn {variant}"
{disabled}
on:click={handleClick}
>
<slot />
</button>
<style>
.btn {
padding: 0.5rem 1rem;
border: none;
border-radius: 4px;
cursor: pointer
Установить svelte-development в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл svelte-development?
Comprehensive Svelte development skill covering reactivity runes, components, stores, lifecycle, transitions, and modern Svelte 5 patterns
Как установить скилл svelte-development?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл svelte-development запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
frontend-design
Guidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making…
от Anthropicwebapp-testing
Toolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing…
от Anthropicbrand-guidelines
Applies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand…
от Anthropicweb-artifacts-builder
Suite of tools for creating elaborate, multi-component claude.ai HTML artifacts using modern frontend web technologies (React, Tailwind CSS, shadcn/ui). Use…
от Anthropic