c/frontend › command
0votes

Cursor rules for SvelteKit

TemplateLow risk
submitted by CommandVault editors to c/frontend

A .cursor/rules/sveltekit.mdc file for load functions, form actions and Svelte 5 runes.

Template · 2 variables
---
description: SvelteKit conventions
globs: ["src/**/*.svelte","src/**/*.ts"]
alwaysApply: false
---

# SvelteKit

- Use Svelte 5 runes ($state, $derived, $props, $effect); avoid legacy stores in new code.
- Load data in `+page.server.ts` / `+layout.server.ts`; only use universal `+page.ts` loads for public data.
- Mutations through form actions with progressive enhancement (`use:enhance`).
- Secrets only in `$env/static/private` or `$env/dynamic/private`, never in client code.
- Shared UI in `src/lib/components`, server utilities in `src/lib/server`.
- Validate form data with {{validation_library}} and return `fail(400, ...)` with field errors.

## When you change code
- Follow the patterns in the nearest existing file before inventing new ones.
- Add or update a test for behavior changes; run `{{test_command}}`.
- Keep diffs small; explain anything surprising in your reply.
0 commentsreport

How to add this Cursor rule

  1. Fill in the 2 blanks above; Copy puts your answers into the file.
  2. Save it in .cursor/rules/ with the .mdc extension (plain .md files there are ignored), e.g. .cursor/rules/nextjs.mdc.
  3. The front matter decides when it applies: alwaysApply: true for every chat, globs for matching files, or a description so Cursor applies it when relevant.
  4. Check it in Cursor's Rules settings, then ask something about a matching file and confirm the answer follows the rule.
  • {{validation_library}} Validation library
  • {{test_command}} Test command

Checked against Cursor docs: rules.

More from c/frontend

See all of c/frontend →
0 comments

Log in to join the discussion.