Svelte component

From HopeArtOrg/hope-re · View interactive version

Svelte component is an AI agent skill from the GitHub repository HopeArtOrg/hope-re. Create a new Svelte 5 component following Hope:RE conventions with runes, Tailwind CSS, and proper barrel exports

How to use this skill

Skill file

Svelte 5 Component Pattern

When creating a new component in Hope:RE, follow these conventions:

File Structure

src/lib/components/<feature>/
  index.svelte
  index.ts
  types.ts
  sub-component.svelte

Component Template

<script lang="ts">
  import type { ComponentProps } from "./types";

  let {
    prop1 = "default",
    prop2 = $bindable(false),
    ...restProps
  }: ComponentProps = $props();

  let localState = $state<string>("");
  const derivedValue = $derived(prop1.toUpperCase());

  $effect(() => {
    return () => {};
  });

  function handleAction() {
  }
</script>

<div class="flex items-center gap-2">
  {derivedValue}
</div>

Barrel Export (`index.ts`)

export { default as ComponentName } from "./index.svelte";
export type { ComponentProps } from "./types";

Types File (`types.ts`)

export type ComponentProps = {
  prop1?: string;
  prop2?: boolean;
  onAction?: () => void;
};

Rules

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.