MR
Mayur Rathi
@github
⭐ 34.1k GitHub stars

Svelte

Svelte是一款code方向的AI技能,核心价值是Svelte 5 and SvelteKit development standards and best practices for component-based user interfaces and full-stack applications,可用于解决开发者在code领域的实际问题,帮助用户提升效率、自动化重复任务或优化工作流。

Svelte 5 and SvelteKit development standards and best practices for component-based user interfaces and full-stack applications

Last verified on: 2026-05-30
mkdir -p ./skills/svelte && curl -sfL https://raw.githubusercontent.com/github/awesome-copilot/main/skills/svelte/SKILL.md -o ./skills/svelte/SKILL.md

Run in terminal / PowerShell. Requires curl (Unix) or PowerShell 5+ (Windows).

Skill Content

# Svelte 5 and SvelteKit Development Instructions


Instructions for building high-quality Svelte 5 and SvelteKit applications with modern runes-based reactivity, TypeScript, and performance optimization.


Project Context

- Svelte 5.x with runes system ($state, $derived, $effect, $props, $bindable)

- SvelteKit for full-stack applications with file-based routing

- TypeScript for type safety and better developer experience

- Component-scoped styling with CSS custom properties

- Progressive enhancement and performance-first approach

- Modern build tooling (Vite) with optimizations


Core Concepts


Architecture

- Use Svelte 5 runes system for all reactivity instead of legacy stores

- Organize components by feature or domain for scalability

- Separate presentation components from logic-heavy components

- Extract reusable logic into composable functions

- Implement proper component composition with slots and snippets

- Use SvelteKit's file-based routing with proper load functions


Component Design

- Follow single responsibility principle for components

- Use `<script lang="ts">` with runes syntax as default

- Keep components small and focused on one concern

- Implement proper prop validation with TypeScript annotations

- Use `{#snippet}` blocks for reusable template logic within components

- Use slots for component composition and content projection

- Pass `children` snippet for flexible parent-child composition

- Design components to be testable and reusable


Reactivity and State


Svelte 5 Runes System

- Use `$state()` for reactive local state management

- Implement `$derived()` for computed values and expensive calculations

- Use `$derived.by()` for complex computations beyond simple expressions

- Use `$effect()` sparingly - prefer `$derived` or function bindings for state sync

- Implement `$effect.pre()` for running code before DOM updates

- Use `untrack()` to prevent infinite loops when reading/writing same state in effects

- Define component props with `$props()` and destructuring with TypeScript annotations

- Use `$bindable()` for two-way data binding between components

- Migrate from legacy stores to runes for better performance

- Override derived values directly for optimistic UI patterns (Svelte 5.25+)


State Management

- Use `$state()` for local component state

- Implement type-safe context with `createContext()` helper over raw `setContext`/`getContext`

- Use context API for sharing reactive state down component trees

- Avoid global `$state` modules for SSR - use context to prevent cross-request data leaks

- Use SvelteKit stores for global application state when needed

- Keep state normalized for complex data structures

- Prefer `$derived()` over `$effect()` for computed values

- Implement proper state persistence for client-side data


Effect Best Practices

- **Avoid** using `$effect()` to synchronize state - use `$derived()` instead

- **Do** use `$effect()` for side effects: analytics, logging, DOM manipulation

- **Do** return cleanup functions from effects for proper teardown

- Use `$effect.pre()` when code must run before DOM updates (e.g., scroll position)

- Use `$effect.root()` for manually controlled effects outside component lifecycle

- Use `untrack()` to read state without creating dependencies in effects

- Remember: async code in effects doesn't track dependencies after `await`


SvelteKit Patterns


Routing and Layouts

- Use `+page.svelte` for page components with proper SEO

- Implement `+layout.svelte` for shared layouts and navigation

- Handle routing with SvelteKit's file-based system


Data Loading and Mutations

- Use `+page.server.ts` for server-side data loading and API calls

- Implement form actions in `+page.server.ts` for data mutations

- Use `+server.ts` for API endpoints and server-side logic

- Use SvelteKit's load functions for server-side and universal data fetching

- Implement proper loading, error, and success states

- Handle streaming data with promises in serve

🎯 Best For

  • Claude users
  • GitHub Copilot users
  • Software engineers
  • Development teams
  • Tech leads

💡 Use Cases

  • Code quality improvement
  • Best practice enforcement

📖 How to Use This Skill

  1. 1

    Install the Skill

    Copy the install command from the Terminal tab and run it. The SKILL.md file downloads to your local skills directory.

  2. 2

    Load into Your AI Assistant

    Open Claude or GitHub Copilot and reference the skill. Paste the SKILL.md content or use the system prompt tab.

  3. 3

    Apply Svelte to Your Work

    Open your project in the AI assistant and ask it to apply the skill. Start with a small module to verify the output quality.

  4. 4

    Review and Refine

    Review AI suggestions before committing. Run tests, check for regressions, and iterate on the skill output.

❓ Frequently Asked Questions

Is Svelte compatible with Cursor and VS Code?

Yes — this skill works with any AI coding assistant including Cursor, VS Code with Copilot, and JetBrains IDEs.

Do I need specific dependencies for Svelte?

Check the install command and Works With section. Most code skills only require the AI assistant and your codebase.

How do I install Svelte?

Copy the install command from the Terminal tab and run it. The skill downloads to ./skills/svelte/SKILL.md, ready to use.

Can I customize this skill for my team?

Absolutely. Edit the SKILL.md file to add team-specific instructions, examples, or workflows.

⚠️ Common Mistakes to Avoid

Skipping validation

Always test AI-generated code changes, even for simple refactors.

Missing dependency updates

Check if the skill requires updated dependencies or new packages.

🔗 Related Skills