ofershap/sveltekit-best-practices/sveltekit-best-practices
Claude Code and agent skill by ofershap/sveltekit-best-practices
- community
Checking that the SKILL.md file is still in the repository.
SvelteKit and Svelte 5 done right. Runes, load functions, form actions, SSR patterns, and modern Svelte.
Install
npx vskill@latest install ofershap/sveltekit-best-practices/sveltekit-best-practicesSKILL.md
When to use
Use this skill when working with SvelteKit or Svelte 5 code. AI agents are trained on Svelte 4 patterns and frequently generate outdated code using stores, reactive declarations, and export let. This skill enforces Svelte 5 runes, load functions, and form actions.
Critical Rules
1. Use Svelte 5 runes - never Svelte 4 stores or reactive declarations
Wrong (agents do this):
Correct:
Why: Svelte 5 runes ($state, $derived, $effect) replace stores and $: syntax. Agents default to Svelte 4 patterns.
2. Use $state for reactive state - not let with reactive assignments
Wrong:
Correct:
Why: In Svelte 5, reactivity is opt-in via $state. Plain let is not reactive.
3. Use $derived for computed values - not $: reactive declarations
Wrong:
Correct:
Why: $: is Svelte 4. Svelte 5 uses $derived for derivations.
4. Use $effect for side effects - not $: reactive statements
Wrong:
Correct:
Why: $effect runs when dependencies change. $: for side effects is deprecated.
5. Use $props() for component props - not export let
Wrong:
Correct:
Why: export let is Svelte 4. Svelte 5 uses $props().
6. Use $bindable() for two-way binding props
Wrong:
Correct:
Why: Props are one-way by default. $bindable() enables bind:value from parent.
7. Use load functions (+page.server.ts) for data fetching - not onMount fetch
Wrong:
Correct:
Why: Load runs on server for SSR, avoids loading flicker, and integrates with SvelteKit routing.
8. Use form actions for mutations - not API routes for form submissions
Wrong:
Correct:
Why: Form actions enable progressive enhancement, work without JS, and avoid client-side fetch boilerplate.
9. Use +layout.server.ts for shared layout data
Wrong:
Correct:
Why: Layout load runs once, data is available to all child pages. No duplicate fetches.
10. Use +error.svelte for error pages
Correct:
Why: SvelteKit uses +error.svelte to render load/action errors. Use it instead of try/catch in every page.
11. Use +page.ts for universal load (server and client)
When data is needed on both server and client (e.g. from $app/stores or browser APIs), put logic in +page.ts. Use +page.server.ts when data is server-only.
12. Use hooks.server.ts for middleware (auth, redirects)
Correct:
Why: Handle runs before every request. Use for auth, redirects, and setting locals.
13. Use $app/stores sparingly - prefer load function data
Prefer passing data via load props. Use $page, $navigating, etc. only when you need client-side routing state.
14. Use snippet blocks for reusable template chunks (Svelte 5)
Wrong:
Correct:
Why: Svelte 5 snippets replace slot-based composition with @render and snippet props.
Patterns
- Page data: +page.server.ts load returns object, +page.svelte receives via $props() with
data - Form with enhance:
method="POST"anduse:enhancefrom$app/forms - Streaming: Return promises from load without await; use
{#await data.promise}in template - TypeScript: Use
import type { PageServerLoad, PageProps } from './$types'
Anti-Patterns
- Do not use writable, readable, derived, get from svelte/store
- Do not use $: for derivations or side effects
- Do not use export let for props
- Do not fetch in onMount when data is needed for SSR
- Do not create +server.ts API routes just for form POST handling
- Do not use bind:value with a prop unless the prop is $bindable()
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/sveltekit-best-practices/SKILL.md
Popularity
- Repository stars
- 12
- 7-day trend score
- 13
Stars and forks are for the whole GitHub repository, not this skill alone. Refreshed 19 Mar 2026, 7 months ago.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/ofershap/sveltekit-best-practices/sveltekit-best-practices)