A comprehensive Claude Code skill for building type-safe SvelteKit applications using remote functions. This skill provides AI assistants with patterns, best practices, and complete examples for implementing client-server communication in SvelteKit.
This skill helps AI assistants write correct code for:
- Type-safe data fetching - Query patterns with full TypeScript support
- Progressive enhancement forms - Form submissions that work without JavaScript
- Imperative server actions - Command patterns for event handlers
- Optimistic updates - Instant UI feedback with automatic error recovery
- Query invalidation - Efficient data refresh and cache management
- N+1 prevention - Batch query patterns
- Validation - Zod schema integration and validation error handling
cd ~/.claude/skills/
git clone https://github.com/wiesson/svelte-remote-functions-
Create the directory:
mkdir -p ~/.claude/skills/svelte-remote-functions -
Download the skill files from this repository
-
Place them in
~/.claude/skills/svelte-remote-functions/
The skill should appear in Claude Code's available skills. The skill will automatically activate for SvelteKit projects.
svelte-remote-functions/
├── SKILL.md # Main entry point for AI
├── README.md # This file (for humans)
└── references/
├── quick-reference.md # Syntax and common patterns
├── query.md # Complete query function documentation
├── form.md # Form functions with progressive enhancement
├── command.md # Imperative command functions
└── invalidation.md # Data refresh and optimistic updates
- Right-sized: Main file is ~350 lines, reference files are 200-300 lines each
- Pattern-focused: Shows complete server + client integration patterns
- Scannable structure: Clear headers and code blocks
- No fluff: Every section serves a practical purpose
- Complete patterns - Not just syntax, but full working examples
- Common mistakes section - Explicit anti-patterns with ❌ DON'T and ✅ DO examples
- Critical syntax rules - Prevents errors like
query(async ({})or missing validation - Best practices front-and-center - Single-flight mutations, validation requirements
- Real workflow examples - Create → Redirect + Refresh, Delete → Optimistic Remove
- Validation emphasis - Every example uses Zod properly
The skill includes a dedicated "Common Mistakes" section highlighting:
❌ Query without validation schema
// DON'T
export const getPost = query(async (slug) => { ... });
// DO
export const getPost = query(z.string(), async (slug) => { ... });❌ Invalid empty object syntax
// DON'T
export const getPosts = query(async ({}) => { ... });
// DO
export const getPosts = query(async () => { ... });❌ Missing arguments when calling
// DON'T
const post = getPost(); // Missing slug!
// DO
const post = getPost(params.slug);❌ Using event as parameter
// DON'T
export const getUser = query(z.string(), async (id, event) => {
const session = event.cookies.get('session');
...
});
// DO
import { getRequestEvent } from '$app/server';
export const getUser = query(z.string(), async (id) => {
const { cookies } = getRequestEvent();
const session = cookies.get('session');
...
});See SKILL.md for complete anti-pattern documentation.
- ✅ Query functions (read data)
- ✅ Form functions (write with progressive enhancement)
- ✅ Command functions (imperative actions)
- ✅ Prerender functions (static data)
- ✅ Batch queries (N+1 prevention)
- ✅ Isolated form instances (form.for(id))
- ✅ Sensitive field protection (_password pattern)
- ✅ Custom validation error handling
- ✅ Optimistic updates
- ✅ Single-flight mutations
- ✅ Request context access
- ✅ Zod integration (primary)
- ✅ Standard Schema support (Valibot, Arktype)
- ✅ Complex nested schemas
- ✅ Optional and default values
This skill is designed to be consumed by Claude Code. The main content is in SKILL.md, which provides:
- When to Use guidance
- Quick Start Patterns for immediate implementation
- Common Workflows for real-world scenarios
- Best Practices for decision-making
- References to detailed documentation
This skill assumes:
- SvelteKit project
- TypeScript (recommended)
- Zod for validation (recommended)
- Remote functions feature enabled in svelte.config.js
Contributions welcome! Please ensure:
- Examples use Zod for validation
- No mentions of "experimental" status
- Patterns are complete (server + client)
- Code is practical and actionable
MIT License - See LICENSE file for details
Based on official SvelteKit remote functions documentation from https://svelte.dev/docs/kit/remote-functions/