.cursor/rules/security.mdc
Cursor security rule for SvelteKit
A focused Cursor `.mdc` rule for auth, secrets, and untrusted input. It attaches when those files change, instead of repeating security policy in every chat. This copy is written for a SvelteKit project. This repository is a SvelteKit app. Load data in load functions, mutate through form actions, and write new components with Svelte 5 runes.
The example uses a balanced, readable style, pragmatic tests, and comments only where the intent is not obvious. Open the generator to make the agent stricter, switch to test-first, quiet the comments, or pick a different file.
The example assumes SvelteKit with Svelte 5 runes (`$state`, `$derived`, `$props`). It does not assume a database or an auth library. If the repo is still on Svelte 4 stores, follow the local style instead of rewriting it.
Example file
Balanced strictness, readable style, pragmatic tests. Download name: security.mdc
---
description: "Security rules for a SvelteKit repository"
globs: "**/*{auth,Auth,secret,config,Config}*"
alwaysApply: false
---
# Security rules
Attach these rules when editing auth, config, or secret-handling code in this SvelteKit repository.
This repository is a SvelteKit app. Load data in load functions, mutate through form actions, and write new components with Svelte 5 runes.
## Secrets and trust
- Do not import $lib/server into client code.
- Keep secrets in private env vars, never $env/static/public.
- Check locals.user in form actions, not only in the page.
## Errors
- Fail at the boundary. Do not swallow errors.
- Use SvelteKit's `error` and `fail` helpers so the page can render a useful message. Do not throw a bare string.
## Done when
- Untrusted input is validated before a side effect.
- No secret was added to source, logs, or a client bundle.
- `npm run check` is clean for the files you touched, and the route still loads in `npm run dev`.
Add it to the project
01
Copy a starting file
Copy the example Cursor security rule on this page, or open the generator if you want different testing, strictness, or comment rules.
02
Save it at .cursor/rules/security.mdc
Save it at `.cursor/rules/security.mdc` in the SvelteKit repo. Narrow the globs if your auth and config files live in a known folder.
03
Start a fresh agent session
Rules files are read when a session starts. A chat that is already open may still be using the old instructions.
04
Give it one small task
Ask for one change a SvelteKit agent often gets wrong, such as a page whose data comes from a load function rather than onMount. If it ignores the file, confirm the path and start a new session.
Questions about this file
Where do I put Cursor security rule in a SvelteKit repo?
Save it at `.cursor/rules/security.mdc` in the SvelteKit repo. Narrow the globs if your auth and config files live in a known folder.
Which tools read this Cursor security rule?
Cursor loads `.cursor/rules/security.mdc` for files that match its globs. Pair it with the always-on project rule. It is not a substitute for code review.
What does the SvelteKit example assume?
The example assumes SvelteKit with Svelte 5 runes (`$state`, `$derived`, `$props`). It does not assume a database or an auth library. If the repo is still on Svelte 4 stores, follow the local style instead of rewriting it.
Does VibeSpell upload my repository?
No. Recipe pages are static, and the generator builds the file in your browser from the options you pick. Your source code never leaves the machine.
Other files for SvelteKit
Cursor security rule for other stacks
- Cursor security rule for Next.js
- Cursor security rule for React
- Cursor security rule for Vue
- Cursor security rule for Node.js
- Cursor security rule for FastAPI
- Cursor security rule for Django
- Cursor security rule for Go
- Cursor security rule for Rust
- Cursor security rule for Unity
- Cursor security rule for Godot
- Cursor security rule for Laravel
- Cursor security rule for Rails
- Cursor security rule for Flutter
- Cursor security rule for Swift
- Cursor security rule for Kotlin
- Cursor security rule for Unreal
- Cursor security rule for Next.js + Supabase
- Cursor security rule for T3
- Cursor security rule for Astro
- Cursor security rule for Remix
- Cursor security rule for Nuxt
- Cursor security rule for Electron
- Cursor security rule for Tauri
- Cursor security rule for Expo
- Cursor security rule for Spring Boot
- Cursor security rule for .NET
- Cursor security rule for Phaser
- Cursor security rule for Bevy
- Cursor security rule for Roblox
- Cursor security rule for Python ML
- Cursor security rule for LangChain