This is the list of available skills provided by the Svelte MCP package. Skills are sets of instructions that AI agents can load on-demand to help with specific tasks. Skills are available in both the Claude Code plugin (installed via the marketplace) and the OpenCode plugin (`@sveltejs/opencode`). They can also be manually installed in your `.claude/skills/` or `.opencode/skills/` folder. You can download the latest skills from the [releases page](https://github.com/sveltejs/mcp/releases) or find them in the [`plugins/svelte/skills`](https://github.com/sveltejs/mcp/tree/main/plugins/svelte/skills) folder. ## `svelte-code-writer` CLI tools for Svelte 5 documentation lookup and code analysis. MUST be used whenever creating, editing or analyzing any Svelte component (.svelte) or Svelte module (.svelte.ts/.svelte.js). If possible, this skill should be executed within the svelte-file-editor agent for optimal results. Open Releases page
View skill content ````markdown # Svelte 5 Code Writer ## CLI Tools You have access to `@sveltejs/mcp` CLI for Svelte-specific assistance. Use these commands via `npx`: ### List Documentation Sections ```bash npx @sveltejs/mcp list-sections ``` Lists all available Svelte 5 and SvelteKit documentation sections with titles and paths. ### Get Documentation ```bash npx @sveltejs/mcp get-documentation ",,..." ``` Retrieves full documentation for specified sections. Use after `list-sections` to fetch relevant docs. **Example:** ```bash npx @sveltejs/mcp get-documentation "$state,$derived,$effect" ``` ### Svelte Autofixer ```bash npx @sveltejs/mcp svelte-autofixer "" [options] ``` Analyzes Svelte code and suggests fixes for common issues. **Options:** - `--async` - Enable async Svelte mode (default: false) - `--svelte-version` - Target version: 4 or 5 (default: 5) **Examples:** ```bash # Analyze inline code (escape $ as \$) npx @sveltejs/mcp svelte-autofixer '' # Analyze a file npx @sveltejs/mcp svelte-autofixer ./src/lib/Component.svelte # Target Svelte 4 npx @sveltejs/mcp svelte-autofixer ./Component.svelte --svelte-version 4 ``` **Important:** When passing code with runes (`$state`, `$derived`, etc.) via the terminal, escape the `$` character as `\$` to prevent shell variable substitution. ## Workflow 1. **Uncertain about syntax?** Run `list-sections` then `get-documentation` for relevant topics 2. **Reviewing/debugging?** Run `svelte-autofixer` on the code to detect issues 3. **Always validate** - Run `svelte-autofixer` before finalizing any Svelte component ````
## `svelte-core-bestpractices` Learn how to write very good svelte code...load this skill whenever in a Svelte project and asked to write/edit or analyze a Svelte component or module that uses client side reactivity. Open Releases page
View skill content ````markdown ## State and Deriveds When writing As Svelte component, each variable that needs to be used inside an effect a derived or in the template must be declared with `$state`. Objects and arrays are automatically deeply reactive, and you can just mutate properties or push to them to trigger reactivity. If you are not mutating or pushing, consider using `$state.raw` to improve performance. Not every variable must be stateful, if a variable is only used to store information and never in an `$effect`, `$derived` or in the template you can avoid using `$state` completely. If one stateful variable depends on another stateful variable, you must use `$derived` to create this new piece of state. `$derived` accepts an expression as input. If you want to use a function, you must use `$derived.by`. Only the stateful variables that are read within a derived actually count as a dependency of that derived. This means that if you guard the read of a stateful variable with an `if`, that stateful variable will only be a dependency when the condition is true. The value of a derived can be overridden; When overridden, the value will change immediately and trigger a DOM update. But when one of the dependencies changes, the value will be recalculated and the DOM updated once again. If a component is receiving a prop and you want a piece of state to be initialised from that prop, usually it's a good idea to use a derived because if that prop is a stateful variable, when it changes, Svelte will just update the value, not remount the component; If the value could be an object, a class, or an array, the suggestion is to use `$state.snapshot` to clone them (`$state.snapshot` is using `structuredClone` under the hood so it might not always be a good idea). ## The `$effect` rune `$effect` is generally considered a malpractice in Svelte. You should almost never use `$effect` to sync between stateful variables (use a `$derived` for that) and reassigning state within an `$effect` is especially bad. When encountering an `$effect` asks yourself if that's really needed. It can usually be substituted by: - A `$derived` - An `@attach` - A class that uses `createSubscriber` The valid use cases for `$effect` are mainly to sync svelte reactivity with a non-reactive system (like a D3 class or the local storage or inside an attachment to do imperative DOM operations). Like `$derived`, `$effect` automatically has every stateful variable (declared with `$state` or `$derived`) as a dependency when it's read (if you guard the read of a stateful variable with an `if`, that stateful variable will only be a dependency when the condition is true) If you want to log a value whenever the reactive variable changes use `$inspect` instead. For more information on when not to use `$effect` read [this file](references/when-not-to-use-effect.md). `$effect` only runs on the client so you don't need to guard with `browser` or `typeof window === "undefined"` ## `$bindable` You can use `$bindable` inside `MyComponent.svelte` like this ```svelte ``` to allow ``. This can get hairy when the value of the prop is not a literal value; try to use callbacks in that case. ```svelte ``` ## `$inspect.trace` `$inspect.trace` is a debugging tool for reactivity. If something is not updating properly or running more than it should you can put `$inspect.trace("[yourlabel]")` as the first line of an `$effect` or `$derived.by` to get detailed logs about the dependencies of it. ## Events on elements Every prop that starts with `on` is treated as an event listener for the element. To register a `click` listener on an element you can do `