3 svelte rules available
Cursor has three Svelte rules: a long SvelteKit full-stack rule and short rules on routing/layouts and reactivity patterns. The reactivity rule mentions stores; Svelte 5 replaced most store use with runes, so the file below makes the version decision explicit.
Cursor applies project rules stored as .mdc files in .cursor/rules. Each rule's frontmatter (description, globs, alwaysApply) decides whether it is always included, attached to matching files, chosen by the agent from its description, or only used when you @-mention it. Cursor also reads AGENTS.md in the project root and subdirectories for plain-Markdown instructions.
.cursor/rules/svelte.mdcStarting point, not a tested configuration for your repository. Attached when files matching the globs are in context (alwaysApply: false with globs). Review the instructions, adapt the file paths and run your project's existing checks.
--- description: "Svelte development project conventions" globs: "**/*.svelte,**/*.svelte.ts,**/*.svelte.js,src/routes/**/*.ts" alwaysApply: false --- # Svelte instructions for Cursor ## Focus for this project - For new shared state on Svelte 5, export state from a .svelte.ts module; keep existing stores unless asked to migrate. - Use +layout.server.ts load functions for data every child route needs. - Use $props() destructuring with types for new Svelte 5 components. ## Svelte conventions - Check the svelte version in package.json. On Svelte 5 use runes ($state, $derived, $props, $effect); on Svelte 4 keep export let and $: and do not mix the two styles in one component. - Prefer $derived over $effect for values computed from state; use $effect only to synchronize with something outside Svelte. - In SvelteKit, load data in +page.server.ts or +page.ts load functions and handle form posts with form actions, not ad-hoc fetch calls in onMount. - Put reusable reactive state in .svelte.ts modules so runes are available there. ## Before you finish - Run npx svelte-check (or the project's check script) and the test script and report the actual output. If you cannot run them, say so and list the exact commands instead of saying they pass. - Summarize which of the rules above affected the change. - If another attached Cursor rule conflicts with this one, name both rules and follow the one with the narrower globs.
Create your own Cursor rules for Svelte and share with the community.
Ask for a small change to one matching file. Check the tool's loaded context or instruction view, inspect the diff for the requested convention, and run the relevant build or test. A well-formatted file does not guarantee the model follows every instruction.
Cursor's docs recommend keeping individual rules under 500 lines and splitting large rules into composable ones. Cursor's documentation states that it supports AGENTS.md in the project root and in subdirectories. Use AGENTS.md for plain-Markdown instructions you also want other tools to read, and .mdc rules when you need Cursor's scoping options (globs, description-based selection, always-apply).
Documentation checked 2026-11-05: Cursor docs: Rules
Illustrative input and expected result. This example is a verification guide, not a recorded model run.
You ask Cursor's agent to add shared state to a Svelte 5 app and want a .svelte.ts module with runes instead of a new writable store.
Add a cart that several pages can read and update.
src/lib/cart.svelte.ts exporting rune-based state and functions, components reading it, no new writable store on Svelte 5, and svelte-check output.
Content reviewed 2026-11-05. Confirm instruction activation in your installed client before relying on it.
Organize SvelteKit applications effectively