frontend-svelte
Skill4 starsChanged 5 months agoMITView on GitHub
Svelte 5 and SvelteKit production patterns — runes-based reactivity, stores, Web Components, Shadow DOM, and performance optimization. Use for frontend architecture decisions or implementing complex UI components.
2 other projects use a version of this.
Adopted by
Most recently taken up by
- ProjAnvil/MindForgetheir own version, first seen Oct 9, 2026
- HK-hub/AgentSkillstheir own version, first seen Mar 2, 2026
Other versions2 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 2
- HK-hub/AgentSkills★ 6same name
- ProjAnvil/MindForge★ 3same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository101 other files it gives its agents.
- ai-video-understandingSkill
- apple-foundation-modelsSkill
- arch-dddSkill
- arch-decision-recordsSkill
- arch-diagramsSkill
- arch-eventsSkill
- arch-mvp-roadmapSkill
- arch-python-modernSkill
- aws-app-runnerSkill
- aws-cicd-patternsSkill
- aws-security-hardeningSkill
- azure-functions-python-v2Skill
- azure-identity-m2m-authSkill
- azure-service-bus-messagingSkill
- azure-workflow-execution-modelsSkill
- caddy-tls-proxySkill
- compliance-frameworksSkill
- design-system-workflowSkill
- dev-debugging-strategiesSkill
- dev-standardsSkill
- docker-python-poetrySkill
- docker-pythonSkill
- fastapi-patternsSkill
- ffmpeg-laravel-videoSkill
- formik-yup-react-nativeSkill
- frontend-accessibilitySkill
- frontend-angular-aiSkill
- frontend-angularSkill
- frontend-angular-toolingSkill
- frontend-design-systemsSkill
- frontend-material-chatSkill
- frontend-material-design-3Skill
- gcp-cicd-patternsSkill
- gcp-cloud-runSkill
- gcp-cloudsql-infrastructureSkill
- gcp-finopsSkill
- gcp-observabilitySkill
- gcp-security-hardeningSkill
- github-actions-cicdSkill
- healthkit-biofeedbackSkill
- infra-terraformSkill
- ios-app-qualitySkill
- ios-audio-hapticsSkill
- jest-nestjs-testingSkill
- langchain-azure-openai-patternsSkill
- laravel-auth-hardeningSkill
- laravel-ci-mysqlSkill
- laravel-mix-webpackSkill
- laravel-modern-patternsSkill
- laravel-pint-patternsSkill
- laravel-s3-storageSkill
- laravel-sail-dockerSkill
- mobile-app-deploymentSkill
- mobile-e2e-testingSkill
- mobile-offline-syncSkill
- mobile-push-notificationsSkill
- mobile-video-uploadSkill
- mongodb-asyncmongoclient-patternsSkill
- mongodb-atlas-patternsSkill
- nestjs-patternsSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
4 rules. About 0 are common, 4 are distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈4
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 197
Create consistent directional indicators using border-based triangles.
- Distinctive: line 233
Anti-pattern: Use HTML elements for arrows — conic-gradient and complex CSS-only solutions need browser-specific fallbacks and fail on …
- Distinctive: line 241
When validating UX tickets for an embedded widget, the Shadow DOM boundary is the first question.
- Distinctive: line 266
Add a display variant by building a new shell component that mounts the same presentational components and stores/services, swapping only …
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Svelte Production Patterns
Production-ready patterns for Svelte 5 and SvelteKit applications.
Core Concepts
Svelte 5 Reactivity (Runes)
<script>
let count = $state(0);
let doubled = $derived(count * 2);
function increment() {
count++;
}
</script>
<button onclick={increment}>{count} × 2 = {doubled}</button>Key Runes
| Rune | Purpose |
$state | Reactive state declaration |
$derived | Computed values |
$effect | Side effects (like useEffect) |
$props | Component props |
$bindable | Two-way bindable props |
State Management Patterns
Factory Pattern with Props-Based DI (Multi-Instance Isolation)
Use Case: Web Components that need per-instance state isolation (multiple <my-widget> elements on same page).
Problem: Singleton stores are shared across all Web Component instances. Shadow DOM isolates CSS, NOT JavaScript state.
Solution: Factory functions + Props-based dependency injection + Backward compatible defaults.
Implementation:
Step 1: Convert Store to Factory
// src/lib/stores/chat.svelte.ts
export class ChatStore {
messages = $state<Message[]>([]);
error = $state<string | null>(null);
// ...
}
// Factory function (NEW)
export function createChatStore(): ChatStore {
return new ChatStore();
}
// Singleton for backward compatibility (KEEP)
export const chatStore = createChatStore();Step 2: Per-Instance Stores in Web Component
// src/main.ts
class MyWidgetElement extends HTMLElement {
private _chatStore: ChatStore;
private _configStore: ConfigStore;
constructor() {
super();
this._shadowRoot = this.attachShadow({ mode: 'open' });
// Create isolated stores per instance
this._chatStore = createChatStore();
this._configStore = createConfigStore();
}
private mountApp() {
this._app = mount(MyWidget, {
target: container,
props: {
chat: this._chatStore, // Pass instance stores
config: this._configStore
}
});
}
}Step 3: Props Pattern in Components
// src/lib/components/MyWidget.svelte
<script lang="ts">
import { chatStore, configStore } from '@/lib/stores';
interface Props {
chat?: ChatStore;
config?: ConfigStore;
}
// Destructure with singleton defaults (backward compat)
let { chat = chatStore, config = configStore }: Props = $props();
// Always use prop, never global
const hasError = $derived(chat.error !== null); // ✅ Uses prop
</script>
<MessageList {chat} {config} /> <!-- Pass to children -->Anti-Pattern to Avoid:
// ❌ WRONG: Component has prop but uses singleton
let { chat = chatStore }: Props = $props();
const isDisabled = $derived(chatStore.error !== null); // ❌ Uses singleton
// ^^^^^^^^^ Should be `chat.error`Testing Pattern:
it('test__multi_widget__state_isolation', async () => {
const widget1 = document.createElement('my-widget');
const widget2 = document.createElement('my-widget');
document.body.append(widget1, widget2);
// Access internal stores
const store1 = (widget1 as any)._chatStore;
const store2 = (widget2 as any)._chatStore;
// Trigger in Widget 1
store1.setError('Error 1');
// Assert Widget 2 unaffected
expect(store1.error).toBe('Error 1');
expect(store2.error).toBeNull(); // ✅ Isolated
});Benefits:
- Multi-instance isolation (each widget has own state)
- Zero breaking changes (singleton defaults preserve behavior)
- Testability (inject mock stores)
- Bundle optimization (-0.3KB, tree-shaking improves)
Detection Command (find singleton usage in props-based components):
for file in $(grep -l "let {.*Store.*}: Props" src/**/*.svelte); do
grep -n "[a-z]Store\." "$file" | grep -v "= $props()"
doneSvelteKit Patterns
Routing
- File-based routing in
src/routes/ +page.sveltefor pages+layout.sveltefor shared layouts+server.tsfor API endpoints
Data Loading
+page.tsfor universal load+page.server.tsfor server-only load+layout.tsfor shared data
Rendering Modes
- SSR (default): Server-rendered, hydrated
- CSR: Client-side only
- Prerender: Static generation
Performance Targets
| Metric | Target |
| LCP | < 2.5s |
| FID | < 100ms |
| CLS | < 0.1 |
| Initial JS | < 100KB |
When NOT to Use Svelte
- Simple interactivity → Vanilla JS
- Static content → Plain HTML + CSS
- < 50KB JS budget → Web Components
- SEO-critical, no JS → Static site generator
CSS Triangle Arrows (Standard Dimensions)
Create consistent directional indicators using border-based triangles.
Standard dimensions for visual harmony:
- Border width: 7px (transparent sides)
- Border height: 12px (colored edge)
- Opacity: 0.7 for decorative elements
/* Downward arrow (▼) */
.arrow-down {
width: 0;
height: 0;
border-left: 7px solid transparent;
border-right: 7px solid transparent;
border-top: 12px solid var(--accent-primary);
opacity: 0.7;
}
/* Right-pointing arrow (▶) */
.arrow-right {
width: 0;
height: 0;
border-top: 7px solid transparent;
border-bottom: 7px solid transparent;
border-left: 12px solid var(--accent-primary);
opacity: 0.7;
}
/* Curved connector */
.curve-connector {
border-left: 2px dashed var(--color);
border-top: 2px dashed var(--color);
border-top-left-radius: 20px;
}Anti-pattern: Use HTML elements for arrows — conic-gradient and complex CSS-only solutions need browser-specific fallbacks and fail on older WebKit.
Use case: Workflow diagrams, process flows, directional UI.
Shadow DOM Layout Patterns
Shadow DOM as Ticket-Routing Boundary
When validating UX tickets for an embedded widget, the Shadow DOM boundary is the first question. Issues about layout/positioning around the widget are host-page changes; issues about widget internals are widget changes.
Host Display Mode
Problem: Custom elements default to display: inline, breaking height: 100% inheritance in child elements.
Solution:
:host {
display: block;
}Why: Without display: block, percentage-based heights in children have no reference height to calculate from. This is a Web Component fundamental, not a Svelte-specific issue.
Two-Style-Element Pattern
Problem: Theme switching can cause layout regressions when all styles are in one <style> element that gets replaced.
Solution: Separate permanent layout styles from mutable theme styles using two <style> elements — one prepended (never replaced), one appended (swapped on theme change).
See examples.md for the full TypeScript implementation.
Thin-Shell Layout Variant
Add a display variant by building a new shell component that mounts the same presentational components and stores/services, swapping only container and positioning logic. Keeps existing internals intact.
See reference.md § Thin-Shell Layout Variant for the composition pattern.
Anti-Patterns
| Anti-Pattern | Pattern |
sticky/absolute + left:50% + translateX(-50%) for centering | align-self: center + max-width — position-based centering overflows in narrow fixed-width containers |
Web Component attributes read only in connectedCallback | Declare observedAttributes and handle changes in attributeChangedCallback; mount-only reads miss runtime updates |
Responsive Image Optimization
WebP with <picture> fallback preserves compatibility while serving 60-80% smaller files. At 4x CSS display size, small images (icons, thumbnails) remain sharp on Retina displays; 2x causes visible blur. Full-width images need original resolution as a high-DPI srcset option (e.g., 1440px viewport × 2x = needs 2880px source). macOS sips + cwebp provides a zero-dependency processing pipeline.
See examples.md for the WebP <picture> pattern and image processing pipeline.
See reference.md for detailed patterns and examples.md for component implementations.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

