|
| 1 | +--- |
| 2 | +name: svelte-code-writer |
| 3 | +description: 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. |
| 4 | +--- |
| 5 | + |
| 6 | +# Svelte 5 Code Writer |
| 7 | + |
| 8 | +## CLI Tools |
| 9 | + |
| 10 | +You have access to `@sveltejs/mcp` CLI for Svelte-specific assistance. Use these commands via `npx`: |
| 11 | + |
| 12 | +### List Documentation Sections |
| 13 | + |
| 14 | +```bash |
| 15 | +npx @sveltejs/mcp list-sections |
| 16 | +``` |
| 17 | + |
| 18 | +Lists all available Svelte 5 and SvelteKit documentation sections with titles and paths. |
| 19 | + |
| 20 | +### Get Documentation |
| 21 | + |
| 22 | +```bash |
| 23 | +npx @sveltejs/mcp get-documentation "<section1>,<section2>,..." |
| 24 | +``` |
| 25 | + |
| 26 | +Retrieves full documentation for specified sections. Use after `list-sections` to fetch relevant docs. |
| 27 | + |
| 28 | +**Example:** |
| 29 | + |
| 30 | +```bash |
| 31 | +npx @sveltejs/mcp get-documentation "$state,$derived,$effect" |
| 32 | +``` |
| 33 | + |
| 34 | +### Svelte Autofixer |
| 35 | + |
| 36 | +```bash |
| 37 | +npx @sveltejs/mcp svelte-autofixer "<code_or_path>" [options] |
| 38 | +``` |
| 39 | + |
| 40 | +Analyzes Svelte code and suggests fixes for common issues. |
| 41 | + |
| 42 | +**Options:** |
| 43 | + |
| 44 | +- `--async` - Enable async Svelte mode (default: false) |
| 45 | +- `--svelte-version` - Target version: 4 or 5 (default: 5) |
| 46 | + |
| 47 | +**Examples:** |
| 48 | + |
| 49 | +```bash |
| 50 | +# Analyze inline code (escape $ as \$) |
| 51 | +npx @sveltejs/mcp svelte-autofixer '<script>let count = \$state(0);</script>' |
| 52 | + |
| 53 | +# Analyze a file |
| 54 | +npx @sveltejs/mcp svelte-autofixer ./src/lib/Component.svelte |
| 55 | + |
| 56 | +# Target Svelte 4 |
| 57 | +npx @sveltejs/mcp svelte-autofixer ./Component.svelte --svelte-version 4 |
| 58 | +``` |
| 59 | + |
| 60 | +**Important:** When passing code with runes (`$state`, `$derived`, etc.) via the terminal, escape the `$` character as `\$` to prevent shell variable substitution. |
| 61 | + |
| 62 | +## Workflow |
| 63 | + |
| 64 | +1. **Uncertain about syntax?** Run `list-sections` then `get-documentation` for relevant topics |
| 65 | +2. **Reviewing/debugging?** Run `svelte-autofixer` on the code to detect issues |
| 66 | +3. **Always validate** - Run `svelte-autofixer` before finalizing any Svelte component |
0 commit comments