sveltekit-2

sveltekit-2 is a cursor rule for coding agents from travishorn/cursor-rules-sveltekit. It costs 0 tokens per session (3,037 once invoked), scanned A, original, MIT.

A set of coding rules for SvelteKit 2, a framework for building Svelte web applications. It highlights changes from SvelteKit 1, including error handling, redirects, and cookie paths.

In plain words
What is it for?
It is for updating or building SvelteKit 2 routes and server code, especially code using error responses, redirects, and cookies.
Why use it?
It prevents the coding agent from applying older SvelteKit patterns that no longer fit version 2. This helps avoid mistakes in redirects, errors, and cookies.

Cursor rule

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add rules/travishorn/cursor-rules-sveltekit/sveltekit-2
Clone the repo
git clone --depth 1 https://github.com/travishorn/cursor-rules-sveltekit

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for sveltekit-2

README.md
[![agentmods](https://agentmods.dev/badge/rules/travishorn/cursor-rules-sveltekit/sveltekit-2.svg)](https://agentmods.dev/rules/travishorn/cursor-rules-sveltekit/sveltekit-2)
Your own site
<a href="https://agentmods.dev/rules/travishorn/cursor-rules-sveltekit/sveltekit-2"><img src="https://agentmods.dev/badge/rules/travishorn/cursor-rules-sveltekit/sveltekit-2.svg" alt="Measured on agentmods" height="20"></a>
Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 3,037 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 1 finding. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00000 $0.03037
Opus 5 $0.00000 $0.01519
Sonnet 5 $0.00000 $0.00607
Haiku 4.5 $0.00000 $0.00304

Measured 5d ago against content hash d2d80c32be1b, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-05, from the pricing page.

Security

Grade A, and why

sveltekit-2 scanned grade A with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 5d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Makes network callslowCapability

Not a fault in itself. Listed so you know the mod talks to something, and to what.

const response = fetch(url).then(r => r.json());
sveltekit-2.mdc · 239 lines

How it starts

The opening of the file, as written. The whole thing — 239 lines — stays where its author put it; the contents beside it link to each section on GitHub.

SvelteKit 2

This project uses the newer SvelteKit 2 instead of the older, but more common SvelteKit 1.

Using SvelteKit version 2 instead of version 1 is mostly seamless. There are a few breaking changes to note, which are listed here.

redirect and error are no longer thrown by you

Previously, you had to throw the values returned from error(...) and redirect(...) yourself. In SvelteKit 2 this is no longer the case — calling the functions is sufficient.

Old, SvelteKit 1 syntax:

import { error } from '@sveltejs/kit'

// ...
throw error(500, 'something went wrong');

New, SvelteKit 2 syntax:

import { error } from '@sveltejs/kit'

// ...
error(500, 'something went wrong');

Do not use error or redirect inside a try {...} block.

path is required when setting cookies

When receiving a Set-Cookie header that doesn't specify a path, browsers will set the cookie path to the parent of the resource in question. This behaviour isn't particularly helpful or intuitive, and frequently results in bugs because the developer expected the cookie to apply to the domain as a whole.

As of SvelteKit 2.0, you need to set a path when calling cookies.set(...), cookies.delete(...) or cookies.serialize(...) so that there's no ambiguity. Most of the time, you probably want to use path: '/', but you can set it to whatever you like, including relative paths — '' means 'the current path', '.' means 'the current directory'.

Old, SvelteKit 1 syntax:

/** @type {import('./$types').PageServerLoad} */
export function load({ cookies }) {
	cookies.set(name, value);
	return { response }
}

New, SvelteKit 2 syntax:

/** @type {import('./$types').PageServerLoad} */
export function load({ cookies }) {
	cookies.set(name, value, { path: '/' });
	return { response }
}

Top-level promises are no longer awaited

In SvelteKit version 1, if the top-level properties of the object returned from a load function were promises, they were automatically awaited. With the introduction of streaming this behavior became a bit awkward as it forces you to nest your streamed data one level deep.

Read the full file on GitHub · 239 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 5d ago First seen · 239 lines · 0 tokens per session scan A d2d80c32be1b

Subscribe to this mod's changes

sveltekit-2 is a cursor rule published in the GitHub repository travishorn/cursor-rules-sveltekit (9 stars, last pushed 1y ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 3,037 tokens. A static security scan graded it A with 1 finding (makes network calls). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.