svelte-code-writer

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Svelte 5 Code Writer

Svelte 5 代码编写器

CLI Tools

CLI工具

You have access to
@sveltejs/mcp
CLI for Svelte-specific assistance. Use these commands via
npx
:
你可以使用
@sveltejs/mcp
CLI来获取Svelte相关的辅助支持。通过
npx
执行以下命令:

List Documentation Sections

列出文档章节

bash
npx @sveltejs/mcp list-sections
Lists all available Svelte 5 and SvelteKit documentation sections with titles and paths.
bash
npx @sveltejs/mcp list-sections
列出所有可用的Svelte 5和SvelteKit文档章节,包含标题和路径。

Get Documentation

获取文档

bash
npx @sveltejs/mcp get-documentation "<section1>,<section2>,..."
Retrieves full documentation for specified sections. Use after
list-sections
to fetch relevant docs.
Example:
bash
npx @sveltejs/mcp get-documentation "$state,$derived,$effect"
bash
npx @sveltejs/mcp get-documentation "<section1>,<section2>,..."
获取指定章节的完整文档。在执行
list-sections
后使用该命令来获取相关文档。
示例:
bash
npx @sveltejs/mcp get-documentation "$state,$derived,$effect"

Svelte Autofixer

Svelte 自动修复工具

bash
npx @sveltejs/mcp svelte-autofixer "<code_or_path>" [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
undefined
bash
npx @sveltejs/mcp svelte-autofixer "<code_or_path>" [options]
分析Svelte代码并针对常见问题提供修复建议。
选项:
  • --async
    - 启用Svelte异步模式(默认值:false)
  • --svelte-version
    - 目标版本:4或5(默认值:5)
示例:
bash
undefined

Analyze inline code (escape $ as $)

分析内联代码(将$转义为$)

npx @sveltejs/mcp svelte-autofixer '<script>let count = $state(0);</script>'
npx @sveltejs/mcp svelte-autofixer '<script>let count = $state(0);</script>'

Analyze a file

分析文件

npx @sveltejs/mcp svelte-autofixer ./src/lib/Component.svelte
npx @sveltejs/mcp svelte-autofixer ./src/lib/Component.svelte

Target Svelte 4

目标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.
npx @sveltejs/mcp svelte-autofixer ./Component.svelte --svelte-version 4

**重要提示:** 当通过终端传递包含runes(如`$state`、`$derived`等)的代码时,需将`$`字符转义为`\$`,以避免shell变量替换。

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
  1. 对语法不确定? 先执行
    list-sections
    ,然后针对相关主题执行
    get-documentation
  2. 审核/调试代码? 对代码执行
    svelte-autofixer
    以检测问题
  3. 务必验证 - 在最终确定任何Svelte组件之前执行
    svelte-autofixer