Command Palette

Search for a command to run...

Назад к скиллам
скилл № 71745

frontend-svelte-architecture

Use when the user asks about Svelte 5, runes ($state, $derived, $effect, $props, $bindable), .svelte component structure, snippets, or migrating from Svelte 4…

БесплатноБез исполняемых скриптов
j4flmaoот j4flmao★ 47 звёзд на GitHub

Установить frontend-svelte-architecture в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Об этом скилле

Svelte Architecture

Purpose

Build applications with Svelte 5 runes — explicit reactivity via $state, $derived, $effect, compiled at build time, no virtual DOM, and minimal runtime.

Agent Protocol

Trigger

Exact user phrases: "Svelte architecture", "Svelte 5", "Svelte runes", "Svelte component", "Svelte reactivity", "Svelte store", "Svelte compiler", ".svelte file".

Input Context

Before activating, verify:

  • package.json has svelte ^5 dependency.
  • Whether the project uses SvelteKit or Svelte standalone.
  • svelte.config.js has compilerOptions: { runes: true } if not default.

Output Artifact

No file output. Produces component code, rune usage, and lifecycle patterns as text.

Response Format

Code: show .svelte components with script, markup, optional style.

No preamble. No postamble. No explanations. No filler/hedging/transitions. Compress output — why use many token when few do trick.

Completion Criteria

  • Components use Svelte 5 runes ($state, $derived, $effect, $props).
  • Derived values use $derived, not $effect.
  • $state provides deep reactivity for objects and arrays.
  • State shared across components via $state class instances or context.
  • Lifecycle hooks (onMount, onDestroy) tied to component tree.
  • Legacy $: syntax replaced with runes in new code.

Max Response Length

Code: 15 lines per example.

Component Architecture / Decision Trees

Architecture Options

Approach Trade-off When to Use
Single-file .svelte with all logic Simple, colocated Small components under 100 lines
.svelte.js module for shared state Separates state from UI Multiple components share state
SvelteKit + load functions SSR data fetching built-in Full-stack SvelteKit apps
Svelte standalone + adapter Minimal, SPA-like Existing non-SvelteKit projects
Snippets + render functions Reusable template fragments Complex list rendering patterns

Decision Tree: State Sharing

Does state need to be shared across components?
  ├── No → $state() locally inside component
  └── Yes → Is it component-tree scoped?
       ├── Yes → setContext() / getContext()
       └── No → .svelte.js module with $state class

Decision Tree: Reactivity

Is the value derived from existing state?
  ├── No → $state()
  └── Yes → $derived() or $derived.by()
Is there a side effect (localStorage, analytics)?
  ├── No → Use $derived
  └── Yes → Use $effect with cleanup

Decision Tree: Template Syntax

What kind of logic in template?
  ├── Conditional display → {#if} {:else if} {:else} {/if}
  ├── List rendering → {#each items as item (key)} {/each}
  ├── Await promise → {#await promise} {:then value} {:catch error} {/await}
  └── Reusable fragment → {#snippet name()} {@render name()}

Component Design Patterns

Basic Counter

<script>
  let count = $state(0)
  let doubled = $derived(count * 2)

  function increment() { count++ }
  function decrement() { count-- }
</script>

<div>
  <p>Count: {count}</p>
  <p>Doubled: {doubled}</p>
  <button onclick={increment}>+</button>
  <button onclick={decrement}>-</button>
</div>

Form with Validation

<script>
  let email = $state('')
  let password = $state('')
  let errors = $state<Record<string, string>>({})

  let isValid = $derived(email.includes('@') && password.length >= 8)

  async function handleSubmit(e: Event) {
    e.preventDefault()
    const result = schema.safeParse({ email, password })
    if (!result.success) { errors = result.error.flatten().fieldErrors; return }
    await api.login(result.data)
  }
</script>

<form onsubmit={handleSubmit}>
  <input type="email" bind:value={email} aria-invalid={!!errors.email} />
  {#if errors.email}<span class="error">{errors.email}</span>{/if}
  <input type="password" bind:value={password} />
  {#if errors.password}<span class="error">{errors.password}</span>{/if}
  <button type="submit" disabled={!isValid}>Login</button>
</form>

Data Fetching with onMount

<script>
  import { onMount } from 'svelte'
  let users = $state<User[]>([])
  let loading = $state(true)
  let error = $state<string | null>(null)

  onMount(async () => {
    try {
      const res = await fetch('/api/users')
      if (!res.ok) throw new Error('Failed to load')
      users = await res.json()
    } catch (e) {
      error = e instanceof Error ? e.message : 'Unknown error'
    } finally {
      loading = false
    }
  })
</script>

{#if loading}
  <p>Loading...</p>
{:else if error}
  <p class="error">{error}</p>
{:else}
  {#each users as user (user.id)}
    <p>{user.name}</p>
  {/each}
{/if}

Snippet Pattern

{#snippet tableRow(item: { id: string; name: string; email: string })}
  <tr>
    <td>{item.name}</td>
    <td>{item.email}</td>
  </tr>
{/snippet}

<table>
  {#each users as user}
    {@render tableRow(user)}
  {/each}
</table>

St

Полный SKILL.md на GitHub

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

  • references/svelte-5-runes-deep-dive.md
  • references/svelte-5-runes.md
  • references/svelte-components.md
  • references/svelte-optimization.md
  • references/svelte-performance-optimization.md
  • references/svelte-reactivity.md
  • references/svelte-runes.md
  • references/svelte-testing.md

FAQ

Что делает скилл frontend-svelte-architecture?

Use when the user asks about Svelte 5, runes ($state, $derived, $effect, $props, $bindable), .svelte component structure, snippets, or migrating from Svelte 4 stores and $: syntax. Produces Svelte 5 component and state architecture. Not for SvelteKit routing, load functions or form actions (use sveltekit).

Как установить скилл frontend-svelte-architecture?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл frontend-svelte-architecture запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить frontend-svelte-architecture с