SkillsGrove
SkillsGrove/Productivité/laolaoshiren/claude-code-skills-zh/error-translator

error-translator

Installation

$npx skills add https://github.com/laolaoshiren/claude-code-skills-zh --skill error-translator
$git clone --depth 1 https://github.com/laolaoshiren/claude-code-skills-zh.git /tmp/claude-code-skills-zh && mkdir -p ~/.claude/skills && cp -r /tmp/claude-code-skills-zh/skills/error-translator ~/.claude/skills/error-translator
Installe pour moi cette Agent Skill : https://github.com/laolaoshiren/claude-code-skills-zh/tree/be7ce4b3c195a8c9f15f976ac2a0bca6779fe8b9/skills/error-translator — lis d’abord son SKILL.md et ses scripts, et ne l’installe dans mon dossier de compétences qu’après avoir vérifié qu’elle est sûre.

Résumé

Description d’origine · MIT编程报错翻译与排障助手,将单条或短段英文错误消息及异常堆栈翻译为自然中文,解释触发根因并给出可执行修复方案。用于用户粘贴终端报错、编译错误、运行时异常或框架报错要求中文解释时;默认只读不改代码,ESLint 报错诊断与自动修复请使用 eslint-fix,大体积日志文件分析请使用 log-analyzer,汉化英文 Skill 请使用 skill-translator。
Le SKILL.md ci-dessous est reproduit depuis laolaoshiren/claude-code-skills-zh (commit be7ce4b) sous licence MIT. Le texte est inchangé ; seules les métadonnées d’en-tête du fichier sont omises, les images sont affichées sous forme de liens et les fichiers très longs sont tronqués. Copyright 2026 laolaoshiren. Licence : LICENSE. Seul le fichier d’instructions est affiché ; consultez le dépôt d’origine pour les éventuels scripts.

错误消息翻译专家

触发边界

  • 适用:用户粘贴单条或短段英文报错、编译失败信息、运行时 Traceback / Stack Trace,希望快速看懂含义并获得针对性修复建议。
  • 不适用:ESLint 规则报错排查与限定范围自动修复 → eslint-fix;多行或大体积 .log / 容器日志聚合分析 → log-analyzer;汉化英文 SKILL.md 或规则文档 → skill-translator。

核心原则

  1. 默认只读解释。 除非用户明确要求直接动手修改源码,否则只输出中文翻译、根因分析与修复方案,不修改项目文件。
  2. 术语保真。 保留类名、函数名、配置键、文件路径、错误码与英文原消息,避免过度意译导致无法继续检索。
  3. 敏感信息脱敏。 若用户粘贴的堆栈或请求错误中包含 Token、Cookie、数据库连接串或密码,回复中予以脱敏,不原样重复输出凭据。
  4. 缺上下文不硬猜。 若报错截断或缺少堆栈帧,说明最可能的 2–3 种原因,并明确指出需要补充哪几行代码或完整 traceback。

工作流程

  1. 识别语言与运行环境
    • 判断编程语言、框架与平台(如 Python / Node.js / TypeScript / Java / Go / Rust / C++ / SQL,以及 Windows PowerShell/GBK 编码相关报错如 UnicodeDecodeError: 'gbk' codec、标记“&&”不是有效语句分隔符 等)。
  2. 准确翻译错误原文
    • 保留完整英文原文与关键标识符,给出简洁自然的中文翻译(原文 → 中文翻译)。
  3. 定位根因与触发路径
    • 结合堆栈最内层业务代码帧(如有)与当前仓库文件解释直接原因和常见诱因。
  4. 提供分层修复方案
    • 给出 1–3 个具体、安全的修复建议(标注推荐方案及适用前提),附清晰的修改前后对比代码。

输出格式

## 🌐 错误翻译

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

## 🔍 错误分析

**语言 / 环境:** {例如 Python 3.12 / Windows PowerShell}
**错误类型:** 语法错误 / 运行时错误 / 编译与类型错误 / 环境与编码错误 / 框架错误
**发生原因:** 简洁说明直接原因与常见触发条件

## 🔧 修复方案

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

修改后:

// 修复后的代码或命令

方案二(备选,如适用)

其他可选思路与权衡...

💡 预防与排查建议

  • 下次快速定位或避免同类错误的实用做法

## 常见错误模式参考

### Python
- `TypeError` / `ValueError` / `KeyError` / `IndexError` / `AttributeError`
- `ImportError` / `ModuleNotFoundError` / `FileNotFoundError`
- `UnicodeDecodeError: 'gbk' codec can't decode byte`(Windows 默认 CP936 编码读 UTF-8 文件,需显式传 `encoding="utf-8"`)
- `asyncio` 事件循环错误、`pandas` / `numpy` 形状或类型不匹配

### JavaScript / TypeScript
- `TypeError: Cannot read properties of undefined`、`ReferenceError`、`UnhandledPromiseRejection`
- ESM / CommonJS 模块混用(`ERR_REQUIRE_ESM`、`Cannot use import statement outside a module`)
- React Hooks 规则错误、Hydration mismatch、TypeScript 类型收窄报错

### Java / Go / Rust / 其他
- Java:`NullPointerException`、`ClassNotFoundException`、`OutOfMemoryError`、Spring 依赖注入冲突
- Go:`nil pointer dereference`、`index out of range`、channel 死锁与并发竞态
- Rust:borrow checker 借用冲突、lifetime 生命周期约束、trait bound 未满足
- Windows 终端常见坑:PowerShell 5.1 不支持 `&&`、`curl` 别名指向 `Invoke-WebRequest`、路径分隔符与权限问题

## 注意事项

- 优先结合仓库里真实出错的文件行号作答,避免脱离上下文泛泛而谈。
- 涉及安装依赖或修改环境配置的修复命令,先说明影响并让用户决定是否执行。
Voir le texte intégral de la licence (MIT)
MIT License

Copyright (c) 2026 laolaoshiren

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.