mcpbeat

Sveltekit Data Flow

spences10/sveltekit-data-flow

SvelteKit data flow guidance. Use for load functions, form actions, and server/client data. Covers +page.server.ts vs +page.ts, serialization, fail(), redirect(), error().

8k tokens
context cost
the whole folder, loaded on every use
6
files
instructions only
0
copies elsewhere
how many repositories repackaged it
217
stars on the repo
on the repository, not the skill itself

Install

one command, takes just this skill from the repository
npx skills add https://github.com/spences10/svelte-claude-skills --skill sveltekit-data-flow

The instruction itself

5 sections, as written by the author

SvelteKit Data Flow

Quick Start

Which file? Server-only (DB/secrets): +page.server.ts |

Universal (runs both): +page.ts | API: +server.ts

Load decision: Need server resources? → server load | Need client

APIs? → universal load

Form actions: Always +page.server.ts. Return fail() for

errors, throw redirect() to navigate, throw error() for failures.

Example

// +page.server.ts
import { fail, redirect } from '@sveltejs/kit';

export const load = async ({ locals }) => {
	const user = await db.users.get(locals.userId);
	return { user }; // Must be JSON-serializable
};

export const actions = {
	default: async ({ request }) => {
		const data = await request.formData();
		const email = data.get('email');

		if (!email) return fail(400, { email, missing: true });

		await updateEmail(email);
		throw redirect(303, '/success');
	},
};

Reference Files

  • load-functions.md - Server vs

universal

  • form-actions.md - Form handling

patterns

  • serialization.md - What can/can't

serialize

  • error-redirect-handling.md -

fail/redirect/error

Notes

  • Server load → universal load via data param | ALWAYS

throw redirect()/error()

  • No class instances/functions from server load (not serializable)
  • Last verified: 2025-01-11

<!--

PROGRESSIVE DISCLOSURE GUIDELINES:

  • Keep this file ~50 lines total (max ~150 lines)
  • Use 1-2 code blocks only (recommend 1)
  • Keep description <200 chars for Level 1 efficiency
  • Move detailed docs to references/ for Level 3 loading
  • This is Level 2 - quick reference ONLY, not a manual

LLM WORKFLOW (when editing this file):

  • Write/edit SKILL.md
  • Format (if formatter available)
  • Run: claude-skills-cli validate <path>
  • If multi-line description warning: run claude-skills-cli doctor <path>
  • Validate again to confirm

-->

How to use it

Copy the folder

Take spences10/sveltekit-data-flow from the repository into ~/.claude/skills for personal use, or into .claude/skills inside a project.

Check the name does not clash

The agent identifies a skill by the name field in its header. Two skills with the same name cannot sit side by side — one of them will be ignored.