| name | svelte-house-rules |
| description | Apply when working on Svelte 5 / SvelteKit projects — planning, building UI, writing $app/server query/command remote functions, shaping Drizzle/D1 schemas, migrating data models, wiring navigation CTAs, handling timezones, gating routes, designing admin tools, integrating libraries, deploying to Cloudflare Workers, animating screen-to-screen transitions, building mobile or PWA surfaces, fixing iOS keyboard or safe-area issues, building vaul drawers with forms, or reviewing a diff. Triggers when the project uses Svelte, SvelteKit, Drizzle, D1, Tailwind v4, vaul-svelte, bits-ui, runed, valibot, svelte-sonner, carta-md, date-fns-tz, mode-watcher, paraglide-js, or river.ts. Covers process discipline, library choices, engineering taste (anchor over button-goto, discriminated unions, failfast at consumers), Tailwind v4 styling tokens with mode-watcher light/dark fork, Apple Liquid Glass recipe, animation patterns that avoid layout overlap, and mobile keyboard fixes. |
Svelte House Rules
A working set of corrections, library choices, and conventions distilled from one Svelte 5 + SvelteKit + Cloudflare Workers project. Project-neutral.
Each rule names the wrong reflex it replaces, followed by the right move. The reasoning travels with the rule so it survives without the conversation that produced it.
Route to a reference
Load the reference for the area in play. Don't bulk-load — each one is self-contained.
| Area | Read | When |
|---|
| Process discipline | references/process.md | Before planning. Before deploying. When the user pushes back on an approach. |
| Library choices | references/libraries.md | Before reaching for a new dep. Before writing a utility component from scratch. |
| Svelte / SvelteKit engineering | references/svelte-kit.md | When writing remote functions, URL-state stores, navigation CTAs, validators, markdown surfaces, timezone code, or icon usage. |
| Database (Drizzle + D1 / SQLite) | references/database.md | When shaping schemas, writing migrations, or doing state transitions on shared rows. |
| Styling + mobile | references/styling-and-mobile.md | When touching CSS, theme tokens, the app shell, safe-area insets, iOS keyboard offsets, or scroll containers. |
| UX patterns | references/ux-patterns.md | When gating routes, hosting OS dialogs inside vaul drawers, or wiring forms inside drawers. |
| Cloudflare Workers + live events | references/cloudflare.md | When working with cron, CSRF allowlists, OG tags on SSR-disabled routes, rate-limit DOs, or river.ts SSE. |
| Animations | references/animations.md | When animating screen-to-screen transitions, swapping content with directional slides, or anywhere stock Svelte transitions feel jittery. |
| Error handling | references/error-handling.md | When wiring +error.svelte, handleError hooks, status-to-copy humanization, inline error banners, or in-place block error states. |
| Analytics (PostHog) | references/analytics.md | When wiring captureEvent / identifyCustomer / captureError, the same-origin /ingest proxy, the server-side flush via waitUntil, or registering an event taxonomy. |
| Swipe / 3-page carousel / filter popovers | references/swipe-and-carousel.md | When building swipe gestures, paged content with peek-then-commit, discriminated-union period pickers, or month-navigator chrome. |
House style: writing the code
These thread through every rule above. They are short on purpose; they apply universally.
- No "X, not Y" prose in code comments, commit messages, or docs. The reader didn't see the wrong version. Name what something IS. If an edit removed something, the final state has no before — there is no removal to narrate.
- No comments explaining WHAT. Identifiers do that. Only write a comment when the WHY is non-obvious — a hidden constraint, a subtle invariant, a workaround for a specific bug, behavior that would surprise a reader.
- No future-proofing. Three similar lines beats a premature abstraction. Don't design for hypothetical requirements.
- No error handling for scenarios that can't happen. Trust internal code and framework guarantees. Validate at system boundaries (user input, external APIs).
The check before declaring done
Single-pass sweep over the diff. Reach back into the relevant reference if any item raises a question.
Process (see references/process.md)
Svelte / SvelteKit (see references/svelte-kit.md)
Database (see references/database.md)
Styling (see references/styling-and-mobile.md)
Mobile / PWA (see references/styling-and-mobile.md + references/ux-patterns.md)
UX (see references/ux-patterns.md)
Animations (see references/animations.md)
Error handling (see references/error-handling.md)
Analytics (see references/analytics.md)
Swipe / carousel (see references/swipe-and-carousel.md)
Prose
When deploying
- Wait for explicit go-ahead.
- Run the clean-and-build script (wipe
.svelte-kit/cloudflare + .svelte-kit/output, then vite build, then wrangler deploy).
- Tail the worker for unexpected exceptions immediately after.
- Scheduled handlers (
scheduled()) and webhook routes are common sources of silent post-deploy failures — watch for those specifically if either was touched.