svelte5-init
Skill1 starsChanged 3 months agoMITView on GitHub
Scaffolds a new Svelte 5 or SvelteKit application with Tailwind CSS v4, TypeScript, and deployment adapter configuration. Use when the user wants to create, initialize, or start a new Svelte 5 project, SvelteKit app, or asks about project setup with Tailwind. Supports deployment targets like Cloudflare, Vercel, Netlify, Node, and static sites.
- Installs packages
In this repository24 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- ai-video-generationSkill
- claude-md-improverSkill
- code-reviewerSkill
- frontend-designSkill
- heron-buildSkill
- heron-claude-dataSkill
- heron-tray-windowsSkill
- minimalist-uiSkill
- product-launch-videoSkill
- rust-engineerSkill
- secure-code-guardianSkill
- seo-auditSkill
- svelte5-reviewSkill
- tauri-app-autostartSkill
- tauri-app-notificationSkill
- tauri-app-positionerSkill
- tauri-app-system-traySkill
- tauri-buildSkill
- tauri-securitySkill
- tauriSkill
- tauri-windowSkill
- test-masterSkill
- typescript-proSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
31 rules. About 0 are common, 7 are distinctive, and 24 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈7
Distinctive · estimate
This author's own choices. Worth a look.
24
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 12
Before starting, ask the user (if not already specified):
- Very specific: line 24
If the user does not specify a deployment target, use auto.
- Very specific: line 35
Use the official sv CLI to create the project:
- Distinctive: line 46
If the user wants a library instead of an app, use the "library" template.
- Very specific: line 48
If sv create is not available or fails, fall back to:
- Very specific: line 60
No action needed. @sveltejs/adapter-auto is installed by default and auto-detects the platform (Cloudflare, Vercel, Netlify, Azure, AWS, …
- Very specific: line 100
Update src/app.d.ts to type platform bindings:
- Very specific: line 254
Create a Dockerfile if the user wants containerized deployment:
- Very specific: line 309
Important: All pages must be prerenderable.
- Distinctive: line 349
If Tailwind was not added during scaffolding, install it manually:
- Very specific: line 367
Create or update src/app.css:
- Very specific: line 386
Update tsconfig.json to ensure strict mode:
- Very specific: line 401
Create src/app.d.ts with proper type declarations (skip if already created in Step 2 for Cloudflare):
- Very specific: line 426
Create src/app.html if not present:
- Very specific: line 478
Create src/error.html as a static fallback:
- Very specific: line 561
Add scripts to package.json:
- Distinctive: line 580
Verify: open the browser, confirm the page renders with Tailwind styles and the counter works.
- Very specific: line 614
Use $props() for component inputs, never export let
- Very specific: line 615
Use $state, $derived, $effect runes (not $: reactive declarations)
- Very specific: line 616
Use {#snippet} + {@render} instead of <slot>
- Very specific: line 617
Use onclick={handler} instead of on:click={handler}
- Very specific: line 619
Use callback props instead of createEventDispatcher
- Very specific: line 620
Use reactive classes in .svelte.ts for shared state (not stores)
- Very specific: line 624
Keep src/routes/ thin: data passing and composition only
- Very specific: line 626
Use $lib imports instead of deep relative paths
- Very specific: line 627
Keep server-only code in $lib/server/
- Very specific: line 628
Use $env/static/private for secrets, $env/static/public for client config
- Distinctive: line 631
Use TypeScript with explicit types for props and exported functions
- Distinctive: line 632
Use Tailwind v4 utility classes for styling
- Very specific: line 634
Every page has a unique <title> (accessibility + SEO)
- Distinctive: line 635
Test server actions first (they are pure functions), then components, then E2E
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 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 5 + SvelteKit Project Initialization
Scaffold a production-ready Svelte 5 / SvelteKit project with Tailwind CSS v4, TypeScript strict mode, and modern conventions.
User parameters
Before starting, ask the user (if not already specified):
- Project name: directory name for the project
- Deployment target: where the app will run. Options:
auto(default) - auto-detects platform at build timecloudflare- Cloudflare Workers / Pagesvercel- Vercel serverless / edgenetlify- Netlify functions / edgenode- Self-hosted Node.js serverstatic- Static site generation (SSG)spa- Single-page application (client-only)
If the user does not specify a deployment target, use auto.
Prerequisites
- Node.js 18.13+ (22+ recommended)
- pnpm (preferred) or npm
Workflow
Step 1: Scaffold the project
Use the official sv CLI to create the project:
npx sv create <project-name>When prompted, select:
- Template: SvelteKit minimal (or skeleton if available)
- Type checking: TypeScript
- Add-ons: Select Tailwind CSS, prettier, eslint
If the user wants a library instead of an app, use the "library" template.
If sv create is not available or fails, fall back to:
npx create-svelte@latest <project-name>Step 2: Install and configure the deployment adapter
Based on the user's chosen deployment target, install the appropriate adapter.
auto (default)
No action needed. @sveltejs/adapter-auto is installed by default and auto-detects the platform (Cloudflare, Vercel, Netlify, Azure, AWS, Google Cloud).
cloudflare
pnpm add -D @sveltejs/adapter-cloudflaresvelte.config.js:
import adapter from '@sveltejs/adapter-cloudflare';
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';
/** @type {import('@sveltejs/kit').Config} */
const config = {
preprocess: vitePreprocess(),
kit: {
adapter: adapter()
}
};
export default config;Create wrangler.jsonc:
{
"name": "<project-name>",
"main": ".svelte-kit/cloudflare/_worker.js",
"compatibility_flags": ["nodejs_als"],
"compatibility_date": "2025-01-01",
"assets": {
"binding": "ASSETS",
"directory": ".svelte-kit/cloudflare"
}
}Update src/app.d.ts to type platform bindings:
declare global {
namespace App {
interface Error {
message: string;
code?: string;
}
interface Locals {}
interface PageData {}
interface PageState {}
interface Platform {
env: {
// Add your KV, D1, R2 bindings here, e.g.:
// MY_KV: KVNamespace;
};
ctx: ExecutionContext;
caches: CacheStorage;
cf: IncomingRequestCfProperties;
}
}
}
export {};Add to .gitignore:
.wranglerImportant: Cloudflare Workers cannot use Node.js fs. Use read() from $app/server to read static files, or prerender routes that need file access.
vercel
pnpm add -D @sveltejs/adapter-vercelsvelte.config.js:
import adapter from '@sveltejs/adapter-vercel';
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';
/** @type {import('@sveltejs/kit').Config} */
const config = {
preprocess: vitePreprocess(),
kit: {
adapter: adapter()
}
};
export default config;Per-route configuration is available via config export:
// src/routes/api/heavy/+server.ts
export const config = {
runtime: 'nodejs22.x', // or 'edge'
regions: ['iad1'],
maxDuration: 15
};For ISR (Incremental Static Regeneration):
// src/routes/blog/[slug]/+page.server.ts
export const config = {
isr: {
expiration: 60 // seconds
}
};netlify
pnpm add -D @sveltejs/adapter-netlifysvelte.config.js:
import adapter from '@sveltejs/adapter-netlify';
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';
/** @type {import('@sveltejs/kit').Config} */
const config = {
preprocess: vitePreprocess(),
kit: {
adapter: adapter({
edge: false,
split: false
})
}
};
export default config;Create netlify.toml:
[build]
command = "npm run build"
publish = "build"Set edge: true for Netlify Edge Functions (Deno-based, lower latency). Note: edge and split cannot both be true.
node
pnpm add -D @sveltejs/adapter-nodesvelte.config.js:
import adapter from '@sveltejs/adapter-node';
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';
/** @type {import('@sveltejs/kit').Config} */
const config = {
preprocess: vitePreprocess(),
kit: {
adapter: adapter({
out: 'build',
precompress: true
})
}
};
export default config;Run in production:
ORIGIN=https://my.site node buildFor reverse proxy setups, use header-based origin detection:
PROTOCOL_HEADER=x-forwarded-proto HOST_HEADER=x-forwarded-host node buildCreate a Dockerfile if the user wants containerized deployment:
FROM node:22-slim AS build
WORKDIR /app
COPY package.json pnpm-lock.yaml ./
RUN corepack enable && pnpm install --frozen-lockfile
COPY . .
RUN pnpm build
FROM node:22-slim
WORKDIR /app
COPY --from=build /app/build ./build
COPY --from=build /app/package.json .
ENV NODE_ENV=production
ENV PORT=3000
EXPOSE 3000
CMD ["node", "build"]static
pnpm add -D @sveltejs/adapter-staticsvelte.config.js:
import adapter from '@sveltejs/adapter-static';
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';
/** @type {import('@sveltejs/kit').Config} */
const config = {
preprocess: vitePreprocess(),
kit: {
adapter: adapter({
pages: 'build',
assets: 'build',
precompress: true,
strict: true
})
}
};
export default config;Enable prerendering in root layout:
// src/routes/+layout.ts
export const prerender = true;Important: All pages must be prerenderable. No form actions, no url.searchParams in load functions, no dynamic user-specific content.
spa
Uses @sveltejs/adapter-static with a fallback page:
pnpm add -D @sveltejs/adapter-staticsvelte.config.js:
import adapter from '@sveltejs/adapter-static';
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';
/** @type {import('@sveltejs/kit').Config} */
const config = {
preprocess: vitePreprocess(),
kit: {
adapter: adapter({
fallback: '200.html'
})
}
};
export default config;Disable SSR in root layout:
// src/routes/+layout.ts
export const ssr = false;Warning: SPA mode hurts SEO and performance (no server rendering, multiple round trips before content shows). Prefer hybrid rendering (prerender static pages + SSR dynamic pages) when possible.
Step 3: Install Tailwind CSS v4
If Tailwind was not added during scaffolding, install it manually:
pnpm add -D tailwindcss @tailwindcss/viteConfigure the Vite plugin in vite.config.ts:
import { sveltekit } from '@sveltejs/kit/vite';
import tailwindcss from '@tailwindcss/vite';
import { defineConfig } from 'vite';
export default defineConfig({
plugins: [tailwindcss(), sveltekit()]
});Create or update src/app.css:
@import 'tailwindcss';Import in src/routes/+layout.svelte:
<script lang="ts">
import '../app.css';
let { children } = $props();
</script>
{@render children()}Step 4: Configure TypeScript strict mode
Update tsconfig.json to ensure strict mode:
{
"extends": "./.svelte-kit/tsconfig.json",
"compilerOptions": {
"strict": true,
"noUncheckedIndexedAccess": true,
"exactOptionalPropertyTypes": false
}
}Step 5: Set up the app type declarations
Create src/app.d.ts with proper type declarations (skip if already created in Step 2 for Cloudflare):
declare global {
namespace App {
interface Error {
message: string;
code?: string;
}
interface Locals {
// Add per-request state here (e.g., user session)
}
interface PageData {
// Add shared page data here
}
interface PageState {
// Add shallow routing state here
}
interface Platform {}
}
}
export {};Create src/app.html if not present:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="icon" href="%sveltekit.assets%/favicon.png" />
%sveltekit.head%
</head>
<body data-sveltekit-preload-data="hover">
<div style="display: contents">%sveltekit.body%</div>
</body>
</html>Step 6: Create the root layout
src/routes/+layout.svelte:
<script lang="ts">
import '../app.css';
let { children } = $props();
</script>
<svelte:head>
<meta name="description" content="App description" />
</svelte:head>
{@render children()}Step 7: Create the root error page
src/routes/+error.svelte:
<script lang="ts">
import { page } from '$app/state';
</script>
<svelte:head>
<title>Error {page.status}</title>
</svelte:head>
<h1>{page.status}</h1>
<p>{page.error?.message}</p>Create src/error.html as a static fallback:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>%sveltekit.status%</title>
</head>
<body>
<h1>%sveltekit.status%</h1>
<p>%sveltekit.error.message%</p>
</body>
</html>Step 8: Create a sample home page
src/routes/+page.svelte:
<script lang="ts">
let count = $state(0);
</script>
<svelte:head>
<title>Home</title>
</svelte:head>
<h1 class="text-3xl font-bold">Welcome</h1>
<button class="rounded bg-blue-500 px-4 py-2 text-white" onclick={() => count++}>
Clicks: {count}
</button>Step 9: Set up testing
Install Vitest and Playwright:
pnpm add -D vitest @testing-library/svelte @testing-library/jest-dom jsdom playwright @playwright/test
npx playwright installCreate vitest.config.ts:
import { sveltekit } from '@sveltejs/kit/vite';
import { defineConfig } from 'vitest/config';
export default defineConfig({
plugins: [sveltekit()],
test: {
include: ['src/**/*.{test,spec}.{js,ts}'],
environment: 'jsdom',
setupFiles: ['./vitest-setup.ts']
}
});Create vitest-setup.ts:
import '@testing-library/jest-dom/vitest';Create playwright.config.ts:
import type { PlaywrightTestConfig } from '@playwright/test';
const config: PlaywrightTestConfig = {
webServer: {
command: 'pnpm build && pnpm preview',
port: 4173
},
testDir: 'tests',
testMatch: /(.+\.)?(test|spec)\.[jt]s/
};
export default config;Add scripts to package.json:
{
"scripts": {
"test": "vitest",
"test:unit": "vitest run",
"test:e2e": "playwright test"
}
}Step 10: Install dependencies and verify
pnpm install
pnpm devVerify: open the browser, confirm the page renders with Tailwind styles and the counter works.
Project structure summary
src/
app.css # Tailwind import
app.d.ts # Type declarations
app.html # Root HTML template
error.html # Static error fallback
lib/
domains/ # Business domain modules
auth/ # Auth components, state, services
...
shared/ # Generic UI components (Button, Modal, etc.)
server/ # Server-only utilities
utils/ # Pure utility functions
routes/
+layout.svelte # Root layout
+error.svelte # Root error boundary
+page.svelte # Home page
tests/ # E2E tests (Playwright)
svelte.config.js # SvelteKit config with adapter
vite.config.ts # Vite config with Tailwind plugin
vitest.config.ts # Vitest config
playwright.config.ts # Playwright config
wrangler.jsonc # Only for Cloudflare target
netlify.toml # Only for Netlify target
Dockerfile # Only for Node target (if containerized)Conventions to follow
Svelte 5 syntax (mandatory)
- Use
$props()for component inputs, neverexport let - Use
$state,$derived,$effectrunes (not$:reactive declarations) - Use
{#snippet}+{@render}instead of<slot> - Use
onclick={handler}instead ofon:click={handler} - Use
{@attach fn}instead ofuse:action - Use callback props instead of
createEventDispatcher - Use reactive classes in
.svelte.tsfor shared state (not stores)
Architecture
- Organize code by domain (
$lib/domains/), not by technical layer - Keep
src/routes/thin: data passing and composition only - Business logic in
.svelte.tsfiles, not in components - Use
$libimports instead of deep relative paths - Keep server-only code in
$lib/server/ - Use
$env/static/privatefor secrets,$env/static/publicfor client config
Quality
- Use TypeScript with explicit types for props and exported functions
- Use Tailwind v4 utility classes for styling
- Semantic HTML elements (
<button>,<nav>,<main>, not<div onclick>) - Every page has a unique
<title>(accessibility + SEO) - Test server actions first (they are pure functions), then components, then E2E
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.

