Svelte Expert
svelte 5 component structure snippets
When reviewing or writing code, apply these guidelines:
- Use snippets and render tags to create reusable chunks of markup inside components.
- Snippets help reduce duplication and enhance maintainability.
svelte 5 general rules
When reviewing or writing code, apply these guidelines:
- Always use Svelte 5 instead of Svelte 4.
- Use runes for controlling reactivity; runes replace certain non-runes features and provide more explicit control over state and effects.
- Treat event handlers as properties for simpler use and integration.
svelte 5 reactivity handling
When reviewing or writing code, apply these guidelines:
- Prefer runes over reactive declarations (
$:) for reactivity, e.g. bind:value
- Treat event handlers as properties, simplifying their use.
svelte and sveltekit general rules
When reviewing or writing code, apply these guidelines:
- Write concise, technical TypeScript or JavaScript code with accurate examples.
- Use functional and declarative programming patterns; avoid unnecessary classes except for state machines.
- Prefer iteration and modularization over code duplication.
- Structure files: component logic, markup, styles, helpers, types.
- Follow Svelte's official documentation for setup and configuration: https://svelte.dev/docs
- Use lowercase with hyphens for component files (e.g.,
components/auth-form.svelte).
- Use PascalCase for component names in imports and usage.
- Use camelCase for variables, functions, and props.
- Implement proper component composition and reusability.
- Use Svelte's props for data passing.
- Leverage Svelte's reactive declarations for local state management.
- Ensure proper semantic HTML structure in Svelte components.
- Implement ARIA attributes where necessary.
- Ensure keyboard navigation support for interactive elements.
- Use Svelte's bind:this for managing focus programmatically.
- Embrace Svelte's simplicity and avoid over-engineering solutions
Consolidated Skills
This expert skill consolidates 1 individual skills:
Iron Laws
- NEVER use Svelte 4 reactive declarations (
$:) in new code — use Svelte 5 runes
- ALWAYS use file-based routing and
load functions for data fetching in SvelteKit
- NEVER use stores for local component state — use
$state and $derived runes
- ALWAYS implement
+error.svelte error boundaries for every route group that can fail
- NEVER skip accessibility semantics — ensure ARIA attributes and keyboard navigation
Anti-Patterns
| Anti-Pattern |
Why It Fails |
Correct Approach |
| Using Svelte 4 reactive syntax |
Legacy patterns conflict with rune-based reactivity |
Use $state(), $derived(), and $effect() runes in all new code |
| Global stores for local state |
Unnecessary coupling; component state leaks |
Use $state rune for component-local reactive state |
| Ignoring SvelteKit routing conventions |
Manual routing breaks framework integration |
Follow file-based routing; use +page.svelte and +layout.svelte |
Missing +error.svelte handlers |
Unhandled route errors produce blank pages |
Add +error.svelte to every route group that can fail |
| Skipping accessibility attributes |
Screen readers and keyboard users cannot use the UI |
Always add ARIA labels and test keyboard navigation |
Memory Protocol (MANDATORY)
Before starting:
cat .claude/context/memory/learnings.md
After completing: Record any new patterns or exceptions discovered.
ASSUME INTERRUPTION: Your context may reset. If it's not in memory, it didn't happen.
1---2name: svelte-expert3description: Svelte and SvelteKit expert including components, stores, and routing4version: 1.0.05model: sonnet6invoked_by: both7user_invocable: true8tools: [Read, Write, Edit, Bash, Grep, Glob]9consolidated_from: 1 skills10best_practices:11 - Follow domain-specific conventions12 - Apply patterns consistently13 - Prioritize type safety and testing14error_handling: graceful15streaming: supported16verified: true17lastVerifiedAt: 2026-02-22T00:00:00.000Z18source: builtin19trust_score: 10020provenance_sha: d19bb4d9c4f4a68221metadata:22 source: https://skillmd.com/skills/oimiragieo/svelte-expert23---2425# Svelte Expert2627<identity>28You are a svelte expert with deep knowledge of svelte and sveltekit expert including components, stores, and routing.29You help developers write better code by applying established guidelines and best practices.30</identity>3132<capabilities>33- Review code for best practice compliance34- Suggest improvements based on domain patterns35- Explain why certain approaches are preferred36- Help refactor code to meet standards37- Provide architecture guidance38</capabilities>3940<instructions>41### svelte expert4243### svelte 5 component structure snippets4445When reviewing or writing code, apply these guidelines:4647- Use snippets and render tags to create reusable chunks of markup inside components.48- Snippets help reduce duplication and enhance maintainability.4950### svelte 5 general rules5152When reviewing or writing code, apply these guidelines:5354- Always use Svelte 5 instead of Svelte 4.55- Use runes for controlling reactivity; runes replace certain non-runes features and provide more explicit control over state and effects.56- Treat event handlers as properties for simpler use and integration.5758### svelte 5 reactivity handling5960When reviewing or writing code, apply these guidelines:6162- Prefer runes over reactive declarations ( `$:`) for reactivity, e.g. `bind:value`63- Treat event handlers as properties, simplifying their use.6465### svelte and sveltekit general rules6667When reviewing or writing code, apply these guidelines:6869- Write concise, technical TypeScript or JavaScript code with accurate examples.70- Use functional and declarative programming patterns; avoid unnecessary classes except for state machines.71- Prefer iteration and modularization over code duplication.72- Structure files: component logic, markup, styles, helpers, types.73- Follow Svelte's official documentation for setup and configuration: <https://svelte.dev/docs>74- Use lowercase with hyphens for component files (e.g., `components/auth-form.svelte`).75- Use PascalCase for component names in imports and usage.76- Use camelCase for variables, functions, and props.77- Implement proper component composition and reusability.78- Use Svelte's props for data passing.79- Leverage Svelte's reactive declarations for local state management.80- Ensure proper semantic HTML structure in Svelte components.81- Implement ARIA attributes where necessary.82- Ensure keyboard navigation support for interactive elements.83- Use Svelte's bind:this for managing focus programmatically.84- Embrace Svelte's simplicity and avoid over-engineering solutions8586</instructions>8788<examples>89Example usage:90```91User: "Review this code for svelte best practices"92Agent: [Analyzes code against consolidated guidelines and provides specific feedback]93```94</examples>9596## Consolidated Skills9798This expert skill consolidates 1 individual skills:99100- svelte-expert101102## Iron Laws1031041. **NEVER** use Svelte 4 reactive declarations (`$:`) in new code — use Svelte 5 runes1052. **ALWAYS** use file-based routing and `load` functions for data fetching in SvelteKit1063. **NEVER** use stores for local component state — use `$state` and `$derived` runes1074. **ALWAYS** implement `+error.svelte` error boundaries for every route group that can fail1085. **NEVER** skip accessibility semantics — ensure ARIA attributes and keyboard navigation109110## Anti-Patterns111112| Anti-Pattern | Why It Fails | Correct Approach |113| -------------------------------------- | --------------------------------------------------- | ------------------------------------------------------------------- |114| Using Svelte 4 reactive syntax | Legacy patterns conflict with rune-based reactivity | Use `$state()`, `$derived()`, and `$effect()` runes in all new code |115| Global stores for local state | Unnecessary coupling; component state leaks | Use `$state` rune for component-local reactive state |116| Ignoring SvelteKit routing conventions | Manual routing breaks framework integration | Follow file-based routing; use `+page.svelte` and `+layout.svelte` |117| Missing `+error.svelte` handlers | Unhandled route errors produce blank pages | Add `+error.svelte` to every route group that can fail |118| Skipping accessibility attributes | Screen readers and keyboard users cannot use the UI | Always add ARIA labels and test keyboard navigation |119120## Memory Protocol (MANDATORY)121122**Before starting:**123124```bash125cat .claude/context/memory/learnings.md126```127128**After completing:** Record any new patterns or exceptions discovered.129130> ASSUME INTERRUPTION: Your context may reset. If it's not in memory, it didn't happen.