agentsclimarketplace

Svelte

Skill ComeOnOliver/skillshub/skills/TerminalSkills/skills/svelte

🧠 The right skill, one API call. AI agent skills registry with token-efficient skill resolution. 5,000+ skills from 500+ top repos.

Install
npx -y skills add ComeOnOliver/skillshub --skill svelte

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

SKILL.md

5.1 KB, as published. Nobody here has run it

Svelte β€” Compile-Time Reactive UI Framework

You are an expert in Svelte, the UI framework that shifts work from runtime to compile time. You help developers build web applications using Svelte's reactive declarations, component system, stores, transitions, and actions β€” compiling to minimal vanilla JavaScript with no virtual DOM overhead, resulting in smaller bundles and faster runtime performance than React or Vue.

Core Capabilities

Reactive Components (Svelte 5 Runes)

<!-- Counter.svelte β€” Svelte 5 with runes -->
<script lang="ts">
  let count = $state(0);                  // Reactive state
  let doubled = $derived(count * 2);      // Computed value

  function increment() {
    count++;                              // Direct mutation triggers updates
  }

  $effect(() => {
    // Runs when dependencies change (like useEffect)
    console.log(`Count changed to ${count}`);
    document.title = `Count: ${count}`;
  });
</script>

<button onclick={increment}>
  Clicked {count} times (doubled: {doubled})
</button>

<style>
  button {
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    background: #ff3e00;
    color: white;
    border: none;
    cursor: pointer;
  }
  button:hover {
    background: #ff5722;
  }
</style>

Props and Events

<!-- Card.svelte -->
<script lang="ts">
  interface Props {
    title: string;
    description?: string;
    variant?: "default" | "featured";
    onclick?: () => void;
  }

  let { title, description = "", variant = "default", onclick }: Props = $props();
</script>

<div class="card {variant}" onclick={onclick}>
  <h3>{title}</h3>
  {#if description}
    <p>{description}</p>
  {/if}
  {@render children()}                    <!-- Slot content -->
</div>

<style>
  .card { padding: 1rem; border: 1px solid #ddd; border-radius: 0.5rem; }
  .card.featured { border-color: #ff3e00; background: #fff5f2; }
</style>

Stores (Global State)

// stores/cart.ts β€” Writable store
import { writable, derived } from "svelte/store";

interface CartItem {
  id: string;
  name: string;
  price: number;
  quantity: number;
}

export const cart = writable<CartItem[]>([]);

export const cartTotal = derived(cart, ($cart) =>
  $cart.reduce((sum, item) => sum + item.price * item.quantity, 0)
);

export const cartCount = derived(cart, ($cart) =>
  $cart.reduce((sum, item) => sum + item.quantity, 0)
);

export function addToCart(item: Omit<CartItem, "quantity">) {
  cart.update((items) => {
    const existing = items.find((i) => i.id === item.id);
    if (existing) {
      existing.quantity++;
      return [...items];
    }
    return [...items, { ...item, quantity: 1 }];
  });
}

export function removeFromCart(id: string) {
  cart.update((items) => items.filter((i) => i.id !== id));
}
<!-- CartSummary.svelte β€” Using stores -->
<script lang="ts">
  import { cart, cartTotal, cartCount, removeFromCart } from "$lib/stores/cart";
</script>

<div class="cart">
  <h2>Cart ({$cartCount} items)</h2>
  {#each $cart as item (item.id)}
    <div class="item">
      <span>{item.name} Γ— {item.quantity}</span>
      <span>${(item.price * item.quantity).toFixed(2)}</span>
      <button onclick={() => removeFromCart(item.id)}>βœ•</button>
    </div>
  {/each}
  <p class="total">Total: ${$cartTotal.toFixed(2)}</p>
</div>

Transitions and Animations

<script>
  import { fade, fly, slide, scale } from "svelte/transition";
  import { flip } from "svelte/animate";

  let items = $state(["Apple", "Banana", "Cherry"]);
  let showModal = $state(false);
</script>

<!-- Animate list changes -->
{#each items as item (item)}
  <div animate:flip={{ duration: 300 }} transition:fade={{ duration: 200 }}>
    {item}
  </div>
{/each}

<!-- Modal with transitions -->
{#if showModal}
  <div class="overlay" transition:fade={{ duration: 150 }}>
    <div class="modal" transition:fly={{ y: 50, duration: 300 }}>
      <h2>Modal Content</h2>
      <button onclick={() => showModal = false}>Close</button>
    </div>
  </div>
{/if}

Installation

npx sv create my-app                      # SvelteKit project
cd my-app && npm install && npm run dev

# Or standalone Svelte (with Vite)
npm create vite@latest my-app -- --template svelte-ts

Best Practices

  1. Runes for state β€” Use $state(), $derived(), $effect() in Svelte 5; cleaner than Svelte 4's $: syntax
  2. Scoped styles by default β€” CSS in <style> is component-scoped; no CSS modules or CSS-in-JS needed
  3. Stores for shared state β€” Use writable/derived stores for state shared between components; auto-subscribe with $
  4. Transitions built-in β€” Use transition:fade, transition:fly etc.; no animation library needed for common effects
  5. Small bundles β€” Svelte compiles away the framework; a typical app ships 5-10KB of runtime vs 40KB+ for React
  6. SvelteKit for full-stack β€” Use SvelteKit for SSR, routing, API endpoints, and deployment adapters
  7. TypeScript support β€” Use <script lang="ts"> for type-safe components; types flow through props and stores
  8. Actions for DOM β€” Use use:action for reusable DOM behavior (click-outside, tooltip, intersection observer)

Keep looking

Skills are one crate of 328,083. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.