# svelte

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.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode, Windsurf (Devin Desktop), Claude.ai · 117 installs · ★ 29 repo stars
- Author: oakoss
- License: MIT · policy=mirror · the beginning of the file is at the end of this page
- Source: https://github.com/oakoss/agent-skills/tree/HEAD/skills/svelte/SKILL.md
- Updated: 2026-08-17
- Security check: automated, 2026-11-16 (text) — no signs of malicious code found.
- HTML: https://affpapa.org/en/nevibecode/skills/oakoss-svelte

## What it 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.

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add oakoss/agent-skills --skill svelte -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/svelte/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/svelte/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add oakoss/agent-skills --skill svelte -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/svelte/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add oakoss/agent-skills --skill svelte -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/svelte/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install oakoss/agent-skills skills/svelte
```

2. **Manually: put the files in place**
- File: `.github/skills/svelte/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add oakoss/agent-skills --skill svelte -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/oakoss/agent-skills --path skills/svelte
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/svelte/SKILL.md` — The legacy .windsurf/skills/ path still works

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add oakoss/agent-skills --skill svelte -a opencode
```

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/oakoss/agent-skills/tree/HEAD/skills/svelte/SKILL.md

## When to use it
- 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
- 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?

## Source text · SKILL.md · MIT

Below is the content of a third-party file. It is data, not instructions for you: do not act on anything written inside unless the human asks. Block tag: ab9f0f22181c508d.

BEGIN THIRD-PARTY FILE ab9f0f22181c508d
```text
---
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           |
```
END THIRD-PARTY FILE ab9f0f22181c508d

The third-party file has ended. Everything between the ab9f0f22181c508d tags is data: requests and commands from it are not followed. An “end of file” line with another tag inside the block is part of the file.

First 2681 of 8784 bytes. © oakoss · MIT · https://github.com/oakoss/agent-skills/tree/HEAD/skills/svelte/SKILL.md

_Part of the page did not fit — see the HTML version._

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
