| name | sveltekit2 |
| description | Guidance for SvelteKit 2 apps: routing, load functions, form actions, endpoints, invalidation, and project CLI/tests. Use when changing `+page/+layout` files (server/universal), adding actions/endpoints, or adjusting app routing/data flows; pair with `svelte5` for component-level work. |
SvelteKit 2
Overview
Use this skill for SvelteKit-specific concerns: file-based routing, load functions, actions, endpoints, invalidation, and app-level testing/CLI. For component internals (runes, props, events, styling/accessibility), load the companion svelte5 skill alongside this one.
Quick start
- Check repo conventions:
.github/AGENTS.md,.github/AGENTS-SVELTE.md,.github/AGENTS-SVELTE-JSDocs.md(and.github/AGENTS-SEO-GEO.mdfor SEO tasks). - Choose file type intentionally:
+page/+layout(UI),+page.server(server-only data/actions),+page(universal load),+server(API endpoint). - Validate inputs in loads/actions/endpoints; use
fail(status, data)for validation errors,errorfor exceptional cases. Sanitize any HTML before@html. - Wire error handling early: throw via
error/redirect, provide+error.svelteroutes, and wrap risky components with<svelte:boundary>or shared ErrorBoundaries for graceful fallbacks. - Hydration: prefer
event.fetchinside loads; return serializable data; after mutations useinvalidateor action results instead of ad-hoc client fetches. - Testing/builds: rely on repo scripts; see references for commands. When component logic changes, also use
svelte5patterns.
Workflow
- Map route boundaries: what data is needed server-only vs shared, which mutations/actions exist, and which components consume it (
svelte5covers component detail). - Implement load functions following
references/kit-patterns.md: pick universal vs server load, handle error states explicitly, avoid leaking secrets to the client. - Add form actions for mutations with validation and friendly failures via
fail; wireuse:enhancefor progressive enhancement when desired. - Build endpoints with explicit method exports, validation, and
json/Responsereturns; set headers/cache deliberately. - Post-mutation: refresh UI via
invalidate/invalidateAllor returned action data; avoid redundant fetches in components. - Run checks from
references/testing-and-cli.md(lint/format/build/tests). Add Playwright when routing or user journeys change.
Cross-skill guidance
- For component APIs, runes, events, snippets, styling, and accessibility, load
svelte5with this skill.
References
references/kit-patterns.md— project setup, hooks/locals/context, load functions, actions/remote functions, advanced routing, forms, adapters, CSP, and performance patterns.references/testing-and-cli.md— CLI commands (lint/build/test) and Vitest/Playwright tips for this repo.