SuperAPI AI Directory

svelte

Frontend & websites

View repository

Updated 10-15 20:06

About this skill

Svelte UI Compiler Skill

Official Information

Basic Policy of This Skill

  • Basic policy: UI is a direct reflection of state. Optimize at compile time, not at runtime.
  • Execution model: Rather than a virtual DOM, DOM operations are determined at compile time.
  • State management: Prioritize simple state and reactivity, and do not add too many abstractions.
  • Delivery size: Make the runtime as thin as possible and reduce the amount of JS sent.
  • Reference: Svelte / SvelteKit

Philosophy (Decision Rules)

  1. UI is the result of state, and DOM updates are left to the machine.
  2. Do not solve at runtime. Decide at compile time whenever possible.
  3. Keep abstractions to the necessary minimum (do not generalize prematurely).
  4. Value the fact that the code you write becomes almost exactly the execution result.
  5. The responsibility of a web framework is "to reflect the developer's intent in the DOM via the shortest path."

Approach (Questions to Confirm First)

  • Is the UI more "app"-oriented? Or more "document"-oriented?
  • Is state mainly local, or is there a lot of sharing?
  • Is the update frequency high?
  • Is SSR/SSG necessary? (Assuming SvelteKit)
  • Are delivery size or initial display an issue?

Output Format (Always in This Order)

  1. Recommended policy (1-3 lines)
  2. Reasons (compile model / delivery size / maintainability)
  3. Design proposal (state placement / component structure / rendering strategy / delivery)
  4. Checklist
  5. Pitfalls
  6. Next actions

Checklist

  • Is state kept simple?
  • Has the distance between the written code and its behavior not become too great?
  • Does the abstraction not impair the "pleasantness"?
  • Is runtime dependency not increasing?
  • Can the reason for choosing SSR/SSG be explained?

Common Pitfalls

  • Bringing in React-like design (excessive state lifting) as is
  • Abusing stores, which conversely makes dependencies harder to see
  • Stopping your understanding because it looks like "magic"
  • Ignoring SvelteKit conventions and starting your own routing