Skip to main content
skill CX Codex

svelte · oakoss — Claude Code skill: Svelte 5 runes and SvelteKit patterns

A reference sheet that teaches a coding agent Svelte 5 runes and SvelteKit routing, plus a table for moving Svelte 4 code onto the new API.

MIT 117 installs ★ 29 updated 2026-08-17

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add oakoss/agent-skills --skill svelte -a claude-code
Open on GitHub

What svelte does

The skill hands the agent a working reference for Svelte 5 and SvelteKit: runes $state, $derived, $effect, $props, $bindable, $inspect, snippets in place of slots, and onclick handlers instead of on: directives. A pattern table pairs each API with its syntax, so the agent does not have to guess how $derived.by or a server load is written.

SvelteKit coverage goes through file-based routes, load in +page.server.ts and +page.ts, form actions with use:enhance, the handle() hook in src/hooks.server.ts, adapters, and +error.svelte. A second table maps Svelte 4 code onto Svelte 5: plain let to $state, $: to $derived, slots to snippets, createEventDispatcher to a callback prop, stores to $state() inside .svelte.ts modules.

Common mistakes get their own list — deep proxying of $state over large data, destructuring $props() away from the declaration, conditional reads inside $effect. There is no slash command to type: the frontmatter sets user-invocable: false, so the agent picks the skill up on its own once Svelte files are in play.

What it helps with

  • port a Svelte 4 component to runes
  • wire a form action into +page.server.ts with use:enhance
  • trace why an $effect misses a dependency
  • swap slots for snippets and {@render}
  • move shared state into a .svelte.ts module

Example prompts for the agent

  • Rewrite this component with $state and $derived instead of $: declarations.
  • Add a form action to +page.server.ts and enhance it on the client.
  • Why does this $effect not rerun when count changes?

How to install svelte

1Skills CLI (Vercel)

npx skills add oakoss/agent-skills --skill svelte -a claude-code

2Manually: put the files in place

~/.claude/skills/svelte/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/svelte/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about svelte

How do I install svelte for Claude Code?

Run npx skills add oakoss/agent-skills --skill svelte -a claude-code. The skill file lands at ~/.claude/skills/svelte/SKILL.md.

What does the svelte skill do?

It gives the agent a Svelte 5 rune syntax sheet, SvelteKit patterns and a list of pitfalls to check while editing components or routes.

Does it cover the Svelte 4 to 5 migration?

Yes. A mapping table shows the replacements: reactive let and $: become $state and $derived, on:click becomes onclick, slots become snippets, stores become $state() in .svelte.ts.

Source text

SKILL.md · MIT
---
name: svelte
description: |
  Svelte 5 and SvelteKit framework patterns. Covers runes ($state, $derived, $effect, $props, $bindable, $inspect), snippets, fine-grained reactivity, component composition, and event handling. SvelteKit coverage includes file-based routing, server and universal load functions, form actions, hooks, adapters, and error handling. Includes Svelte 4 to 5 migration guidance (stores to runes, on:event to onevent, slots to snippets).

  Use when building Svelte 5 components, configuring SvelteKit routing, implementing form actions, migrating from Svelte 4, or debugging reactivity issues.
license: MIT
metadata:
  author: oakoss
  version: '1.0'
  source: 'https://svelte.dev/docs'
user-invocable: false
---

# Svelte

## Overview

Svelte is a **compiler-based UI framework** that shifts work from runtime to build time, producing minimal JavaScript with no virtual DOM. Svelte 5 introduces runes for explicit, fine-grained reactivity. SvelteKit is the full-stack framework built on Svelte, providing file-based routing, server-side rendering, and deployment adapters.

**When to use:** Full-stack web apps, static sites, progressive enhancement, SSR/SSG, projects needing small bundle sizes, migration from Svelte 4 to 5.

**When NOT to use:** React/Vue ecosystem lock-in, projects requiring extensive third-party component libraries only available for other frameworks, teams with no Svelte experience on tight deadlines.

## Quick Reference

| Pattern            | API / Syntax                                            | Key Points                                         |
| ------------------ | ------------------------------------------------------- | -------------------------------------------------- |
| Reactive state     | `let count = $state(0)`                                 | Replaces `let` reactivity from Svelte 4            |
| Derived state      | `const double = $derived(count * 2)`                    | Replaces `$:` reactive declarations                |
| Complex derivation | `const value = $derived.by(() => { ... })`              | Multi-statement derived computations               |
| Side effects       | `$effect(() => { ... })`                                | Runs after DOM update, auto-tracks dependencies    |
| Component props    | `let { name, age = 25 } = $props()`                     | Replaces `export let`, supports defaults           |
| Bindable props     | `let { value = $bindable() } = $props()`                | Two-way binding with `bind:value`                  |
| Debug inspection   | `$inspect(value)`                                       | Dev-only logging, stripped in production           |
| Snippets           | `{#snippet name(params)}...{/snippet}`                  | Replaces slots, reusable template blocks           |
| Render snippet     | `{@render name(args)}`                                  | Invoke a snippet with arguments                    |
| Event handling     | `<button onclick={handler}>`                            | Properties replace `on:click` directive            |
| Each blocks        | `{#each items as item (item.id)}...{/each}`             | Keyed iteration for efficient updates              |
| Await blocks       | `{#await promise}...{:then}...{:catch}...`              | Inline async rendering                             |
| Server load        | `export function load({ params })` in `+page.server.ts` | Runs server-side only, accesses DB/secrets         |
| Universal load     | `export function load({ fetch })` in `+page.ts`         | Runs on server and client                          |
| Form actions       | `export const actions` in `+page.server.ts`             | Progressive enhancement with `use:enhance`         |
| Layout             | `+layout.svelte` / `+layout.server.ts`                  | Shared UI and data across child routes             |
| Server hooks       | `handle()` in `src/hooks.server.ts`                     | Request middleware, auth, redirects                |
| Error page         | `+error.svelte`                                         | Per-route error boundaries                         |
| Adapters           | `adapter-auto`, `adapter-node`, `adapter-static`        | Deploy to Vercel, Node, static hosting             |
| API routes         | `+server.ts` with `GET`, `POST`, etc.                   | Standalone endpoints, not tied to pages            |
| Page options       | `export const prerender = true`                         | Per-route SSR, CSR, prerender control              |
| Shared state       | `$state()` in `.svelte.ts` modules                      | Replaces writable stores for cross-component state |
| Raw state          | `$state.raw(data)`                                      | Opts out of deep proxying for large datasets       |

## Svelte 4 to 5 Migration

| Svelte 4 (Legacy)                         | Svelte 5 (Current)                              |
| ----------------------------------------- | ----------------------------------------------- |
| `let count = 0` (reactive)                | `let count = $state(0)`                         |
| `$: double = count * 2`                   | `const double = $derived(count * 2)`            |
| `$: { sideEffect() }`                     | `$effect(() => { sideEffect() })`               |
| `export let name`                         | `let { name } = $props()`                       |
| `<slot />`                                | `{#snippet children()}{/snippet}` + `{@render}` |
| `on:click={handler}`                      | `onclick={handler}`                             |
| `createEventDispatcher()`                 | Callback props: `let { onclick } = $props()`    |
| `import { writable } from 'svelte/store'` | `$state()` in `.svelte.ts` modules              |
| `$store` auto-subscription                | Direct value access from rune-based state       |

## Common Mistakes

| Mistake                                       | Correct Pattern                                                              |
| --------------------------------------------- | ---------------------------------------------------------------------------- |
| Using `$state` on non-primitives without care | `$state` deeply proxies objects; use `$state.raw()` for large read-only data |
| Destructuring `$props()` loses reactivity     | Destructure at declaration only: `let { x } = $props()`                      |
| Reading `$effect` dependencies conditionally  | Ensure all tracked reads happen unconditionally                              |
| Returning cleanup from `$effect` incorrectly  | Return a function: `$effect(() => { return () => cleanup() })`               |
| Mixing `on:click` and `onclick` in Svelte 5   | Use `onclick` exclusively in Svelte 5 components                             |
| Using stores in new Svelte 5 code             | Use `$state()` in `.svelte.ts` modules for shared state                      |
| Forgetting `(key)` in `{#each}` blocks        | Always key: `{#each items as item (item.id)}`                                |
| Exporting load from `.svelte` files           | Load functions belong in `+page.ts` or `+page.server.ts`                     |
| Not awaiting parent `load` in layouts         | Use `await parent()` when child load depends on layout                       |
| Using `goto()` in server load functions       | Use `redirect(303, '/path')` from `@sveltejs/kit`                            |

## Delegation

- **Pattern discovery**: Use `Explore` agent
- **Code review**: Delegate to `code-reviewer` agent
- **Build configuration**: Delegate to `Task` agent

> If the `tailwind` skill is available, delegate Tailwind CSS utility class patterns and configuration to it.
> If the `vitest-testing` skill is available, delegate Svelte component unit testing patterns to it.
> If the `playwright` skill is available, delegate end-to-end testing of SvelteKit routes and form actions to it.
> If the `drizzle-orm` skill is available, delegate database schema and query patterns used in SvelteKit server load functions to it.
> If the `vite` skill is available, delegate Vite build configuration and plugin setup to it.

## References

- [Runes and reactivity patterns ($state, $derived, $effect, $props)](references/runes-reactivity.md)
- [Snippets, rendering, and component composition](references/component-patterns.md)
- [SvelteKit routing, load functions, and layouts](references/sveltekit-routing.md)
- [Form actions, progressive enhancement, and validation](references/form-actions.md)
- [Hooks, middleware, and error handling](references/hooks-errors.md)
- [Svelte 4 to 5 migration patterns](references/migration-guide.md)
- [SvelteKit adapters and deployment](references/adapters-deployment.md)

© oakoss · MIT · oakoss/agent-skills

Similar skills

All skills for Frontend and UI →

svelte by other authors comes first.

svelte vercel-labs Guides AI coding agents through building Svelte 5 component trees from json-render specs, including state, events, bindings, and catalogs. CX Codex +1 1,300installs svelte Mindrally Guides AI assistants through modern Svelte 5 and SvelteKit development, covering runes, snippets, SSR, and Svelte 4 migration. CX Codex +1 806installs svelte Claude MPM Team Get Svelte 5 guidance for reactive components and SvelteKit apps. Use it when building UI state, bindings, routes, or data-loading flows. CX Codex +1 360installs svelte-development manutej svelte-development guides coding assistants on Svelte 5 conventions, focusing on reactivity runes, scoped styling, and component props. CX Codex +1 437installs svelte-stinger Legion Code Inc. svelte-stinger is a Claude Code skill for Svelte 5 and SvelteKit 2, covering runes, reactivity, and migration from Svelte 4. CX Codex +1 ★ 96repo stars svelte-migrate davila7 svelte-migrate is a Claude Code command that moves Svelte and SvelteKit projects between versions. Ask it to adopt runes or address upgrade-related breakage. CX Codex +1 120installs svelte5-best-practices ejirocodes svelte5-best-practices — a skill that feeds your coding agent Svelte 5 runes, snippets and SvelteKit patterns while you write or refactor components. CX Codex +1 18,800installs svelte-wasp-drone Legion Code Inc. svelte-wasp-drone is a Claude Code subagent for Svelte 5 syntax and SvelteKit 2 runtime mechanics. It guides Svelte 4 upgrades, manages runes, and audits server load handlers. CX Codex ★ 96repo stars svelte-core-bestpractices sveltejs svelte-core-bestpractices — a skill that tells the agent how to write Svelte components with runes: $state, $derived, events, styling. Useful as soon as the agent edits a Svelte project. CX Codex +1 12,400installs

From the same set106

The whole set →

Project sponsors

Companies that keep this analytics open