svelte
Use when editing Svelte components, .svelte files, svelte.config.js, Svelte 5 runes, $state, $derived, SvelteKit, component state, or migrating away from Svelte 4 patterns.
Best use case
svelte is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Use when editing Svelte components, .svelte files, svelte.config.js, Svelte 5 runes, $state, $derived, SvelteKit, component state, or migrating away from Svelte 4 patterns.
Teams using svelte should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/svelte/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How svelte Compares
| Feature / Agent | svelte | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Use when editing Svelte components, .svelte files, svelte.config.js, Svelte 5 runes, $state, $derived, SvelteKit, component state, or migrating away from Svelte 4 patterns.
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# Svelte 5 Framework Skill
<workflow>
## Quick Reference
### Svelte 5 Runes
<example>
```svelte
<script lang="ts">
interface Props {
title: string;
items: Item[];
onselect?: (item: Item) => void;
}
let { title, items, onselect }: Props = $props();
let selected = $state<Item | null>(null);
let count = $derived(items.length);
function handleSelect(item: Item) {
selected = item;
onselect?.(item);
}
$effect(() => {
console.log('Selected changed:', selected);
});
</script>
<div>
<h2>{title} ({count})</h2>
<ul>
{#each items as item (item.id)}
<li onclick={() => handleSelect(item)}>
{item.name}
</li>
{/each}
</ul>
</div>
```
</example>
### State Management with Runes
<example>
```ts
// stores/counter.svelte.ts
class Counter {
count = $state(0);
doubled = $derived(this.count * 2);
increment() {
this.count++;
}
decrement() {
this.count--;
}
}
export const counter = new Counter();
```
</example>
### Bindable Props
<example>
```svelte
<script lang="ts">
let { value = $bindable('') }: { value: string } = $props();
</script>
<input bind:value />
```
</example>
### Snippets (Svelte 5)
<example>
```svelte
<script lang="ts">
import type { Snippet } from 'svelte';
interface Props {
header: Snippet;
children: Snippet;
footer?: Snippet<[{ count: number }]>;
}
let { header, children, footer }: Props = $props();
let count = $state(0);
</script>
<div class="card">
<header>{@render header()}</header>
<main>{@render children()}</main>
{#if footer}
<footer>{@render footer({ count })}</footer>
{/if}
</div>
```
</example>
### SvelteKit Load Functions
<example>
```ts
// +page.server.ts
import type { PageServerLoad, Actions } from './$types';
export const load: PageServerLoad = async ({ params, fetch }) => {
const res = await fetch(`/api/items/${params.id}`);
if (!res.ok) throw error(404, 'Not found');
return {
item: await res.json()
};
};
export const actions: Actions = {
update: async ({ request, params }) => {
const data = await request.formData();
await updateItem(params.id, data);
return { success: true };
}
};
```
</example>
### Form Actions
<example>
```svelte
<script lang="ts">
import { enhance } from '$app/forms';
import type { ActionData } from './$types';
let { form }: { form: ActionData } = $props();
</script>
<form method="POST" action="?/update" use:enhance>
<input name="title" required />
<button type="submit">Save</button>
{#if form?.success}
<p>Saved!</p>
{/if}
</form>
```
</example>
## Key Differences from Svelte 4
| Svelte 4 | Svelte 5 |
|----------|----------|
| `export let prop` | `let { prop } = $props()` |
| `$: derived` | `$derived(expr)` |
| `$: { effect }` | `$effect(() => { })` |
| `<slot>` | `{@render children()}` |
| `on:click` | `onclick` |
| `bind:this` | Still `bind:this` |
</workflow>
## Best Practices
- Use TypeScript with Svelte 5
- Prefer `$state` over stores for local state
- Use `$derived` for computed values
- Extract reusable state into classes with runes
- Use `$effect.pre` for DOM measurements
- Use snippets instead of slots
## References Index
- **[Litestar-Vite Integration](references/litestar_vite.md)** — Backend integration with Litestar-Vite plugin.
## Official References
- <https://svelte.dev/docs/svelte/what-are-runes>
- <https://svelte.dev/docs/svelte/v5-migration-guide>
- <https://svelte.dev/docs/kit/load>
- <https://svelte.dev/docs/kit/form-actions>
- <https://svelte.dev/docs/cli/overview>
- <https://github.com/sveltejs/svelte/releases>
## Shared Styleguide Baseline
- Use shared styleguides for generic language/framework rules to reduce duplication in this skill.
- [General Principles](https://github.com/cofin/flow/blob/main/templates/styleguides/general.md)
- [Svelte](https://github.com/cofin/flow/blob/main/templates/styleguides/frameworks/svelte.md)
- [TypeScript](https://github.com/cofin/flow/blob/main/templates/styleguides/languages/typescript.md)
- Keep this skill focused on tool-specific workflows, edge cases, and integration details.
<guardrails>
## Guardrails
- **Always use Svelte 5 Runes for state management** -- Use `$state` for reactive variables and `$derived` for computed logic. Avoid legacy Svelte 4 store patterns for local state.
- **Use Snippets instead of Slots** -- Svelte 5 introduces snippets for more explicit and flexible content composition. Avoid `<slot>` as it is deprecated in the new version.
- **Prefer TypeScript for component logic** -- Use `<script lang="ts">` to ensure type safety for props and event handlers.
- **Avoid `$effect` for simple state updates** -- Use `$derived` whenever possible to keep reactivity declarative. `$effect` should only be used for side effects (e.g., DOM interactions).
- **Use `$bindable()` only when necessary** -- Two-way binding should be used sparingly; prefer one-way data flow via props and callbacks where possible.
</guardrails>
<validation>
## Validation Checkpoint
- [ ] Component uses Svelte 5 Runes (`$state`, `$derived`, `$props`)
- [ ] No legacy `<slot>` tags are used; snippets rendering is verified
- [ ] TypeScript types are defined for all props
- [ ] `$effect` is not misused for logic that can be handled by `$derived`
- [ ] Component uses modern event handlers (e.g., `onclick` instead of `on:click`)
- [ ] Any two-way bindings use the `$bindable()` rune
</validation>Related Skills
flow-memory-keeper
Use at task, phase, flow, sync, archive, finish, revise, or failure checkpoints to keep Flow specs clean, capture learnings and failures, elevate durable patterns, and refine this skill with project-specific nuances
vue
Use when editing Vue projects, .vue files, vue.config.js, Vue 3 components, Composition API, <script setup>, SFC state, deployment workflows, or Vue CI configuration.
vite
Use when editing Vite projects, vite.config.ts, vite.config.js, Vite plugins, HMR, asset bundling, frontend build settings, deployment config, or Litestar/Vite integration.
uvicorn
Use when deploying ASGI apps with uvicorn, editing uvicorn CLI commands, Config or Server usage, workers, reload, event loop selection, SSL, lifespan, logging, or development server behavior.
tracer
Use when tracing execution paths, mapping dependencies, understanding unfamiliar code, following data flow, investigating end-to-end behavior, debugging call chains, or deciding which files to read next.
testing
Use when writing or refactoring tests, editing test_*.py, *.test.ts, *.spec.ts, conftest.py, vitest.config.ts, pytest fixtures, mocks, coverage, async tests, anyio, or test failure debugging.
terraform
Use when creating, adopting, refactoring, or operating Terraform, *.tf files, .terraform.lock.hcl, terragrunt.hcl, root modules, backends, state, workspaces, imports, CI plan/apply, tests, or policy checks.
tanstack
Use when editing TanStack code, @tanstack imports, useQuery, createRouter, React Query, TanStack Router, Table, Form, Store, file-based routing, data fetching, or SPA state management.
tailwind
Use when styling with Tailwind CSS, editing tailwind.config.ts, tailwind.config.js, @tailwind directives, utility classes, responsive layouts, @apply, cn(), @theme config, dark mode, or forms.
sqlserver
Use when writing T-SQL, editing SQL Server .sql files, using sqlcmd, SQL Server connection strings, stored procedures, execution plans, indexes, Always On, JSON, security, or connector code.
sqlalchemy
Use when editing SQLAlchemy code, sqlalchemy imports, mapped_column, DeclarativeBase, ORM models, relationships, select() queries, async sessions, engines, events, or migrations.
sphinx
Use when editing Sphinx docs, conf.py, .rst files, docs/source, autodoc, Read the Docs builds, Shibuya or Immaterial themes, Wasm extensions, VHS terminal recordings, or Sphinx CI.