skills/sveltekit-data-optimizer/SKILL.md
Optimize SvelteKit applications by leveraging SvelteKit's full-stack architecture for instant server-side rendering and progressive enhancement. Specialized in load functions, form actions, and SvelteKit's data loading patterns. Use when: - User reports slow initial page load with loading spinners - Page uses onMount + fetch for data fetching - Store patterns cause waterfall fetching - Need to improve SEO (content not in initial HTML) - Converting client-side data fetching to server-side load functions - Implementing progressive enhancement patterns Triggers: "slow loading", "optimize fetching", "SSR data", "SvelteKit optimization", "remove loading spinner", "server-side fetch", "convert to load function", "progressive enhancement", "data fetch lambat", "loading lama"
npx skillsauth add ajianaz/skills-collection performance-optimizerInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Optimize SvelteKit applications by leveraging the framework's full-stack capabilities for instant server-side rendering and progressive enhancement.
Search for these anti-patterns in the codebase:
# Find client-side fetching patterns
rg -n "onMount.*fetch|\$state.*loading|writable\(\)" --type svelte
rg -n "fetch\(" src/routes/ --type svelte
rg -n "export let data" src/routes/ --type svelte
Red flags:
onMount + fetch() = slow initial load$state(true) for isLoading = user sees spinnerwritable() or derived for initial page data = waterfall fetchingexport let data in page components = not using load functionsDetermine what data the page needs on initial render:
Move sections with on:viewportenter, $state, on:click to separate components while preserving SvelteKit patterns:
<!-- src/lib/components/DataSection.svelte -->
<script lang="ts">
export let data: Item[]; // Receive data as props from load function
import { onMount } from 'svelte';
import { scrollReveal } from '$lib/actions/scrollReveal.js';
import { fly, fade } from 'svelte/transition';
let element: HTMLElement;
let isVisible = false;
// Client-side animation with Svelte patterns
onMount(() => {
scrollReveal(element);
});
</script>
<div
bind:this={element}
transition:fly={{ y: 20 }}
class:visible={isVisible}
>
{#each data as item}
<div transition:fade>
{item.content}
</div>
{/each}
</div>
<!-- src/routes/+page.svelte -->
<script lang="ts">
import DataSection from '$lib/components/DataSection.svelte';
import type { PageData } from './$types';
export let data: PageData; // Data from universal load function
</script>
<DataSection {data} />
<!-- Optional: Progressive enhancement form -->
<form method="POST" action="?/submit">
<input name="message" />
<button type="submit">Submit</button>
</form>
// src/routes/+page.server.ts
import { getData } from '$lib/server/data';
import type { PageServerLoad, Actions } from './$types';
import { fail } from '@sveltejs/kit';
export const load: PageServerLoad = async ({ url }) => {
const data = await getData(); // Fetch on server
return { data };
};
export const actions: Actions = {
default: async ({ request }) => {
const formData = await request.formData();
const message = formData.get('message');
if (!message) {
return fail(400, { message: 'Message is required' });
}
// Process data...
return { success: true };
}
};
When DB types differ from frontend types:
// src/lib/server/adapters.ts
import type { Item as DBItem } from "$lib/server/database.types";
import type { Item } from "$lib/types";
export function adaptDBToFrontend(db: DBItem): Item {
return {
id: db.id,
name: db.name,
description: db.description ?? "",
createdAt: new Date(db.created_at),
};
}
// src/routes/+page.server.ts
import { getItems } from '$lib/server/items';
import { adaptDBToFrontend } from '$lib/server/adapters';
import type { PageServerLoad } from './$types';
export const load: PageServerLoad = async ({ params, url, cookies }) => {
const dbItems = await getItems();
const items = dbItems.map(adaptDBToFrontend);
return {
items,
// Additional SvelteKit-specific data
search: url.searchParams.get('search') || '',
user: cookies.get('user') ? JSON.parse(cookies.get('user')) : null
};
};
// src/routes/+page.ts for universal load
import type { PageLoad } from './$types';
export const load: PageLoad = async ({ parent, url }) => {
const parentData = await parent();
const clientData = await getClientOnlyData();
return {
...parentData,
clientData
};
};
Keep client-side fetching when:
Best practice: Use SvelteKit's progressive enhancement - server-side load + client-side enhancement
See references/patterns.md for:
depends()+layout.server.ts hookstools
Replace with description of the skill and when Claude should use it.
testing
Generate structured task lists from specs or requirements. IMPORTANT: After completing ANY spec via ExitSpecMode, ALWAYS ask the user: "Would you like me to generate a task list for this spec?" Use when user confirms or explicitly requests task generation from a plan/spec/PRD.
development
Implement or extend user-facing workflows in SvelteKit applications with full-stack capabilities. Specialized in SvelteKit's load functions, form actions, and progressive enhancement. Use when the feature is primarily a UI/UX change backed by existing APIs, affects only the web frontend, and requires following SvelteKit conventions.
testing
Analyze and implement purposeful UI animations for Svelte/SvelteKit + Tailwind projects. Specialized in Svelte transitions, actions, and animation patterns. Use when user asks to add animations, enhance UI motion, animate pages/components, or improve visual feedback. Triggers on "add animations", "animate UI", "motion design", "hover effects", "scroll animations", "page transitions", "micro-interactions".