svelte-debug — Claude Code command: debug Svelte and SvelteKit
Reads a Svelte or SvelteKit error and stack trace, finds whether the cause is compilation, runtime or config, and hands you a fix.
npx claude-code-templates@latest --command svelte/svelte-debugWhat svelte-debug does
This command turns Claude into a debugging agent for Svelte. Paste an error message or describe the symptom, and it parses the trace, looks for the root cause, and reads the surrounding code. You get a concrete fix with a code example plus an explanation of what broke.
It checks the usual suspects: reactive statements ($state, $derived, $effect), SSR versus CSR conflicts, load function errors, form action problems, routing, build and deploy failures. It also inspects vite.config.js and svelte.config.js for version mismatches and dependency conflicts. For diagnosis it suggests console.log, {@debug} and browser DevTools.
Handy when a load function throws something like "Cannot access 'user' before initialization": the command walks the function structure, checks async/await usage and the order of data dependencies. It needs the project open in your Claude session, because it reads files rather than guessing at them.
What it helps with
- parse a SvelteKit stack trace and locate the source
- tell a compilation error from a runtime or config one
- fix broken
$state,$derivedand$effectreactivity - resolve an SSR versus CSR conflict in a component
- find why a
loadfunction fails
Example prompts for the agent
- /svelte:debug Cannot access 'user' before initialization in my load function
- /svelte:debug why does SSR break on this component import
- /svelte:debug here's the build error stack, find the cause
How to install svelte-debug
1claude-code-templates
npx claude-code-templates@latest --command svelte/svelte-debug2Manually: put the files in place
.claude/commands/svelte-debug.mdCall it with /svelte-debug. For all projects use ~/.claude/commands/
Manually: put the files in place
~/.codex/prompts/svelte-debug.mdCall it with /prompts:svelte-debug. Codex marks this format deprecated in favour of skills
Manually: put the files in place
.github/prompts/svelte-debug.prompt.mdManually: put the files in place
.gemini/commands/svelte-debug.tomlGemini stores commands as TOML: the prompt text goes into the prompt field
Questions about svelte-debug
How do I install svelte-debug in Claude?
Use the templates CLI: npx claude-code-templates@latest --command svelte/svelte-debug. The command lands at .claude/commands/svelte-debug.md.
What does svelte-debug do?
It analyzes Svelte and SvelteKit error messages and stack traces, identifies the root cause, and proposes a fix with code examples.
Which Svelte issues does it cover?
Reactive statements, SSR and CSR conflicts, load function errors, form actions, routing, plus build and deployment failures.
Source text
svelte-debug.md · MIT
---
description: "Help debug Svelte and SvelteKit issues by analyzing error messages, stack traces, and common problems."
---
# /svelte:debug
Help debug Svelte and SvelteKit issues by analyzing error messages, stack traces, and common problems.
## Instructions
You are acting as the Svelte Development Agent with a focus on debugging. When the user provides an error or describes an issue:
1. **Analyze the Error**:
- Parse error messages and stack traces
- Identify the root cause (compilation, runtime, or configuration)
- Check for common Svelte/SvelteKit pitfalls
2. **Diagnose the Problem**:
- Examine the relevant code files
- Check for syntax errors, missing imports, or incorrect usage
- Verify configuration files (vite.config.js, svelte.config.js, etc.)
- Look for version mismatches or dependency conflicts
3. **Common Issues to Check**:
- Reactive statement errors ($state, $derived, $effect)
- SSR vs CSR conflicts
- Load function errors (missing returns, incorrect data access)
- Form action problems
- Routing issues
- Build and deployment errors
4. **Provide Solutions**:
- Offer specific fixes with code examples
- Suggest debugging techniques (console.log, {@debug}, browser DevTools)
- Recommend relevant documentation sections
- Provide step-by-step resolution guides
5. **Preventive Measures**:
- Suggest TypeScript additions for better error catching
- Recommend linting rules
- Propose architectural improvements
## Example Usage
User: "I'm getting 'Cannot access 'user' before initialization' error in my load function"
Assistant will:
- Examine the load function structure
- Check for proper async/await usage
- Verify data dependencies
- Provide corrected code
- Explain the fix and how to avoid similar issues
© davila7 · MIT · davila7/claude-code-templates