跳到正文
FunCoding

搜索

搜索文档、Skill 和 MCP

error-translator

编程错误消息翻译专家 — 将英文错误消息翻译成中文,解释原因并提供修复方案

文档与办公879skills/error-translator/SKILL.md

安装

把这段话发给 Claude Code、Codex 或 Cursor。智能体会先检查安全性,你确认后才安装。

读取 https://funcoding.ai/skills/laolaoshiren/claude-code-skills-zh/error-translator/install.md ,按里面的步骤帮我安装这个 Skill。

SKILL.md

错误消息翻译专家

触发条件

当用户粘贴或遇到编程错误消息(英文),需要翻译和解释时激活此技能。

工作流程

  1. 识别错误类型

    • 确定编程语言和运行环境(Python/Java/JavaScript/Go/Rust/C/C++ 等)
    • 判断错误类型:语法错误、运行时错误、编译错误、框架错误、系统错误
  2. 翻译错误消息

    • 将英文错误消息准确翻译为中文
    • 保留关键的技术术语(类名、函数名、文件路径)
    • 翻译格式:原文 → 中文翻译
  3. 分析错误原因

    • 用简洁的中文解释错误发生的原因
    • 说明常见的触发场景
    • 列出可能导致此错误的代码模式
  4. 提供修复方案

    • 给出 2-3 个具体的修复建议
    • 包含修改前后的代码对比示例
    • 如果有最佳实践,一并说明

输出格式

## 🌐 错误翻译

**原始消息:** `English error message here`
**中文翻译:** 中文翻译内容

## 🔍 错误分析

**错误类型:** [语法错误|运行时错误|编译错误|框架错误]
**发生原因:** 简洁说明为什么会发生这个错误

## 🔧 修复方案

### 方案一(推荐)
修改前:
\`\`\`language
// 有问题的代码
\`\`\`

修改后:
\`\`\`language
// 修复后的代码
\`\`\`

### 方案二
其他可能的解决方案...

## 💡 预防建议
- 避免此类错误的最佳实践

支持的常见错误类型

Python

  • TypeError, ValueError, KeyError, IndexError
  • ImportError, ModuleNotFoundError
  • AttributeError, FileNotFoundError
  • SyntaxError, IndentationError
  • Django/Flask/FastAPI 框架错误
  • asyncio 异步错误
  • pandas/numpy 数据处理错误

JavaScript/TypeScript

  • TypeError, ReferenceError, SyntaxError
  • Cannot read property of undefined
  • Promise rejection 错误
  • React/Vue/Angular 框架错误
  • Node.js 模块和依赖错误
  • TypeScript 类型错误
  • ESLint/Prettier 配置错误

Java

  • NullPointerException, ClassNotFoundException
  • RuntimeException, IOException
  • Spring/Hibernate 框架错误
  • Maven/Gradle 构建错误
  • JVM 内存错误(OutOfMemoryError)

其他语言

  • Go: nil pointer, index out of range, goroutine 泄漏
  • Rust: borrow checker, lifetime 错误
  • C/C++: segmentation fault, undefined reference, 内存泄漏
  • SQL: 语法错误、约束冲突、连接池错误
  • PHP: Undefined variable, 命名空间错误

常见错误模式示例

示例 1: Python KeyError

原始消息: KeyError: 'username' 中文翻译: 键错误:'username' 原因分析: 尝试访问字典中不存在的键 'username' 修复方案: 使用 .get('username', default_value) 或检查键是否存在

示例 2: JavaScript Cannot read property 'map' of undefined

原始消息: TypeError: Cannot read property 'map' of undefined 中文翻译: 类型错误:无法读取未定义对象的 'map' 属性 原因分析: 尝试在 undefined 值上调用 .map() 方法 修复方案: 添加空值检查 data?.map(...) 或确保数据已初始化

示例 3: Java NullPointerException

原始消息: java.lang.NullPointerException 中文翻译: 空指针异常 原因分析: 尝试使用一个为 null 的对象引用 修复方案: 添加 null 检查,使用 Optional<T>,或检查对象初始化

注意事项

  • 保持技术术语的准确性,不要过度翻译
  • 对于框架特定的错误,要说明是哪个框架
  • 如果错误信息不完整,询问用户提供完整的 traceback
  • 优先提供安全的修复方案,避免引入新问题
  • 建议用户添加错误监控和日志记录,预防类似错误

相似的 Skill

pdf
anthropics/skills180k

pdf

Use this skill whenever the user wants to do anything with PDF files. This includes reading or extracting text/tables from PDFs, combining or merging multiple PDFs into one, splitting PDFs apart, rotating pages, adding watermarks, creating new PDFs, filling PDF forms, encrypting/decrypting PDFs, extracting images, and OCR on scanned PDFs to make them searchable. If the user mentions a .pdf file or asks to produce one, use this skill.

文档与办公

discernment-nudge
anthropics/skills180k

discernment-nudge

After you give a substantive answer or draft that the user may act on — advice or recommendations, drafted artifacts such as goals, plans, pitches, proposals, or emails, estimates or projections, analysis or interpretation of data, factual claims they may rely on, or a multi-step argument — invoke this skill BEFORE finalizing your reply and then, if it applies, append 2-3 short follow-up questions, each tied to something specific in what you just produced, that help the user check key facts, probe the reasoning or assumptions, and notice missing context. Do this at most once per conversation. Skip it when the user asked a trivial how-to or simple lookup, wants a purely educational explanation, asked you only to format, convert, or assemble a file from content they provided, is writing code they will run, is doing creative writing or casual chat, or already asked you to double-check, cite, or review — the skill file explains these boundaries and the exact output format.

文档与办公

doc-coauthoring
anthropics/skills180k

doc-coauthoring

Guide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision docs, or similar structured content. This workflow helps users efficiently transfer context, refine content through iteration, and verify the doc works for readers. Trigger when user mentions writing docs, creating proposals, drafting specs, or similar documentation tasks.

文档与办公

docx
anthropics/skills180k

docx

Use this skill whenever the user wants to create, read, edit, or manipulate Word documents (.docx files) or Word templates (.dotx files). Triggers include: any mention of 'Word doc', 'word document', '.docx', '.dotx', or requests to produce professional documents with formatting like tables of contents, headings, page numbers, or letterheads. Also use when extracting or reorganizing content from .docx or .dotx files, inserting or replacing images in documents, performing find-and-replace in Word files, working with tracked changes or comments, or converting content into a polished Word document. If the user asks for a 'report', 'memo', 'letter', 'template', or similar deliverable as a Word or .docx file, use this skill. Do NOT use for PDFs, spreadsheets, Google Docs, or general coding tasks unrelated to document generation.

文档与办公

pptx
anthropics/skills180k

pptx

Use this skill any time a .pptx or .potx file is involved in any way — as input, output, or both. This includes: creating slide decks, pitch decks, or presentations; reading, parsing, or extracting text from any .pptx or .potx file (even if the extracted content will be used elsewhere, like in an email or summary); editing, modifying, or updating existing presentations; combining or splitting slide files; working with templates (.potx), layouts, speaker notes, or comments. Trigger whenever the user mentions "deck," "slides," "presentation," or references a .pptx or .potx filename, regardless of what they plan to do with the content afterward. If a .pptx or .potx file needs to be opened, created, or touched, use this skill.

文档与办公

canvas-design
anthropics/skills180k

canvas-design

Create beautiful visual art in .png and .pdf documents using design philosophy. You should use this skill when the user asks to create a poster, piece of art, design, or other static piece. Create original visual designs, never copying existing artists' work to avoid copyright violations.

文档与办公