frontend-svelte-patterns
Use when the user asks about Svelte forms and bind:value, transitions and animate, use: actions or attachments, shared state in .svelte.ts modules or Svelte…
от j4flmao★ 47 звёзд на GitHub
Установить frontend-svelte-patterns в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Об этом скилле
Svelte Patterns
Purpose
Apply production patterns to Svelte 5 applications: forms with bind:value and progressive enhancement, animations via transition/animate directives, actions for reusable DOM behavior, and data fetching strategies.
Agent Protocol
Trigger
Exact user phrases: "Svelte pattern", "Svelte form", "Svelte animation", "Svelte transition", "Svelte action", "Svelte store pattern", "Svelte data fetching".
Input Context
Before activating, verify:
- Svelte 5 project (package.json with svelte ^5).
- Whether project uses SvelteKit (load functions) or standalone (onMount).
- If superforms is available for Zod validation.
Output Artifact
No file output. Produces code patterns for forms, animations, actions, and data fetching.
Response Format
Code: show .svelte component patterns with script + template.
No preamble. No postamble. No explanations. No filler/hedging/transitions. Compress output — why use many token when few do trick.
Completion Criteria
- Forms use bind:value for two-way input binding.
- Progressive enhancement via use:enhance with SvelteKit.
- Validation uses superforms + Zod or HTML validation.
- Transitions use transition: directive (fade, slide, scale, fly).
- List animations use animate:flip with keyed each blocks.
- Actions (use:) encapsulate reusable DOM behavior.
- Data fetching uses onMount + $state for CSR, SvelteKit load for SSR.
Max Response Length
Code: 15 lines per example.
Component Architecture / Decision Trees
Architecture Options
| Approach | Trade-off | When to Use |
|---|---|---|
| bind:value + manual submit handler | Full control, no magic | Simple forms, custom validation |
| use:enhance (SvelteKit) | Progressive enhancement, no JS fallback | SvelteKit form actions |
| Superforms + Zod | Auto validation, field errors, loading states | Complex forms with validation |
| SvelteKit load functions | SSR data fetching, streaming | Full-stack apps |
| onMount + fetch | CSR data fetching | Standalone Svelte (non-SvelteKit) |
| Transition directives | CSS-driven animation | Enter/leave animations |
| use:action | Reusable DOM behavior | Global event listeners, tooltips, portals |
Decision Tree: Form Handling
Is the project using SvelteKit?
├── No -> bind:value + manual submit + fetch
└── Yes -> Is the form complex (many fields, validation)?
├── Yes -> Superforms + Zod + use:enhance
└── No -> use:enhance with basic validation
Decision Tree: Data Fetching
Is SvelteKit used?
├── Yes -> Use load() in +page.ts or +page.server.ts
│ ├── Public data -> universal load (+page.ts)
│ └── Private/DB data -> server load (+page.server.ts)
└── No -> onMount() + $state() + fetch()
Decision Tree: Animation Strategy
What kind of animation?
├── Enter/leave single element -> transition: directive
├── List reorder -> animate:flip + keyed each
├── Shared element between routes -> SvelteKit crossfade
└── Continuous animation -> svelte/motion (tweened, spring)
Component Design Patterns
Form with Superforms + Zod
<script>
import { superForm } from 'sveltekit-superforms/client'
import { schema } from './schema'
const { form, errors, enhance, submitting } = superForm(data.form, { schema })
</script>
<form method="POST" use:enhance>
<input name="email" type="email" bind:value={form.email} aria-invalid={!!errors.email} />
{#if errors.email}<span>{errors.email}</span>{/if}
<input name="password" type="password" bind:value={form.password} />
{#if errors.password}<span>{errors.password}</span>{/if}
<button type="submit" disabled={submitting}>
{submitting ? 'Submitting...' : 'Login'}
</button>
</form>
Custom Action (use:)
<script>
function tooltip(node: HTMLElement, text: string) {
const tip = document.createElement('div')
tip.className = 'tooltip'
tip.textContent = text
tip.style.cssText = 'position:absolute;background:#333;color:white;padding:4px 8px;border-radius:4px;'
function show() {
const rect = node.getBoundingClientRect()
tip.style.top = `${rect.top - tip.offsetHeight - 4}px`
tip.style.left = `${rect.left + rect.width / 2 - tip.offsetWidth / 2}px`
document.body.appendChild(tip)
}
function hide() { tip.remove() }
node.addEventListener('mouseenter', show)
node.addEventListener('mouseleave', hide)
return {
destroy() {
node.removeEventListener('mouseenter', show)
node.removeEventListener('mouseleave', hide)
hide()
},
update(newText: string) { tip.textContent = newText },
}
}
let message = $state('Hello')
</script>
<button use:tooltip={message}>Hover me</button>
Nested Transition Animation
<script>
import { fly, slide } from 'svelte/transition'
import { cubicOut } from 'svelte/easing'
let items = $state([
{ id
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
- references/svelte-component-patterns.md
- references/svelte-forms.md
- references/svelte-routing.md
- references/svelte-ssr-hydration.md
- references/svelte-state.md
- references/svelte-stores-state-management.md
- references/svelte-stores-state.md
- references/svelte-transitions.md
FAQ
Что делает скилл frontend-svelte-patterns?
Use when the user asks about Svelte forms and bind:value, transitions and animate, use: actions or attachments, shared state in .svelte.ts modules or Svelte data-fetching patterns. Produces reusable Svelte 5 UI patterns. Not for SvelteKit load functions and form actions (use sveltekit) or rune basics (use frontend-svelte-architecture).
Как установить скилл frontend-svelte-patterns?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл frontend-svelte-patterns запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
skill-creator
AnthropicCreate new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an…
discernment-nudge
AnthropicAfter you give a substantive answer or draft that the user may act on — advice or recommendations, drafted artifacts such as goals, plans, pitches, proposals…
data-consolidate
AnthropicJoins the plant's scheduled exports and connector data into one working dataset — ERP items (NetSuite or Infor M3), sales orders, production work orders…
inspection-to-capa
AnthropicRuns the quality chain end to end: writes the nonconformance against the requirement it violates, searches history at the moment of writing to say whether…