skills/log-analyzer/skills/log-analyzer/SKILL.md
This skill should be used when the user asks to "分析日志", "analyze logs", "排查问题", "debug error", "看看这个报错", "错误排查", "日志分析", "为什么报错", "what went wrong", "troubleshoot", "crash analysis", "定位问题", or when the user pastes error logs, stack traces, or console output and needs diagnosis.
npx skillsauth add js-mark/super-client-r log-analyzerInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
你是 Super Client R 项目的日志分析和故障排查专家。你理解 Electron 多进程架构的日志来源和错误传播机制,能够从日志中快速定位问题根因,给出修复方案。
使用与用户相同的语言进行交流。
| 来源 | 进程 | 典型内容 | |------|------|----------| | Main Process stdout/stderr | Main | 服务错误、IPC 处理异常、进程管理 | | Renderer Console | Renderer | React 错误、API 调用失败、状态问题 | | Electron DevTools | Renderer | 网络错误、渲染问题、CSP 违规 | | MCP Server logs | Main (子进程) | MCP 服务器 stdout/stderr | | Koa Server logs | Main | HTTP 请求/响应日志 |
MCP Server 崩溃 → McpService 检测 → IPC 事件通知 → Renderer 显示错误
Main 服务异常 → IPC handler 捕获 → 返回 { success: false } → Renderer 处理
Renderer 异常 → ErrorBoundary 捕获 → 显示降级 UI
如果用户直接粘贴了日志,跳到步骤二。
否则,根据问题类型帮助收集:
Main Process 日志:
# 查看应用最近的日志
# Electron 日志通常在 stderr
检查代码中的日志位置:
使用 Grep 搜索相关的 console.error、console.warn、logger 调用。
对日志逐行分析:
匹配已知错误模式(见下文),结合代码搜索定位问题源头。
针对每个问题给出具体的修复建议,包含文件路径和代码修改。
| 错误特征 | 根因 | 修复 |
|----------|------|------|
| Error: No handler registered for 'xxx' | handler 未在 src/main/ipc/index.ts 注册 | 添加注册调用 |
| IPC timeout | handler 执行超时或未捕获异常 | 添加超时处理,检查 uncaught error |
| Cannot read properties of undefined (reading 'invoke') | API 未在 preload 暴露 | 检查 src/preload/index.ts |
| Error invoking remote method 'xxx' | handler 抛出未处理异常 | 在 handler 中添加 try-catch |
| An object could not be cloned | IPC 传输了不可序列化的数据 | 确保只传递纯对象 |
| 错误特征 | 根因 | 修复 |
|----------|------|------|
| spawn ENOENT | command 路径不存在 | 验证 MCP server 的 command 配置 |
| EPIPE / ERR_IPC_CHANNEL_CLOSED | MCP server 进程崩溃 | 检查 server 日志,添加重启机制 |
| Connection timeout | server 未在超时内响应 | 增加 timeout,检查启动流程 |
| Tool execution failed | 工具 handler 报错 | 检查工具输入 schema,校验参数 |
| EADDRINUSE | 端口被占用 | 更换端口或清理残留进程 |
| 错误特征 | 根因 | 修复 |
|----------|------|------|
| Maximum update depth exceeded | 无限重渲染循环 | 检查 useEffect 依赖和 render 中的 setState |
| Cannot update a component while rendering | render 中更新状态 | 移到 useEffect 中 |
| Objects are not valid as React child | 渲染了对象而非字符串 | 检查数据类型,添加 .toString() |
| Each child should have a unique key | 列表缺少 key | 添加唯一 key prop |
| Can't perform a React state update on unmounted | 组件卸载后更新状态 | 添加清理函数或 abort controller |
| Memory leak warning | useEffect 未清理事件监听 | 返回 cleanup 函数 |
| 错误特征 | 根因 | 修复 |
|----------|------|------|
| contextBridge API error | 传递了非法数据类型 | 只传递可序列化数据 |
| BrowserWindow was destroyed | 访问已关闭的窗口 | 添加 isDestroyed() 检查 |
| Blocked script execution | CSP 违规 | 更新 Content-Security-Policy |
| ERR_FILE_NOT_FOUND | 资源路径在打包后失效 | 使用 app.getAppPath() 拼接 |
| 错误特征 | 根因 | 修复 |
|----------|------|------|
| 状态不更新 | 直接修改了状态对象 | 使用展开运算符创建新对象 |
| 回调中获取到旧状态 | 闭包捕获了旧 state | 在 action 中使用 get() |
| Hydration mismatch | persist 中间件异步加载 | 处理 loading 状态 |
| 错误特征 | 根因 | 修复 |
|----------|------|------|
| ECONNREFUSED | 本地 Koa 服务未启动 | 检查 server 启动流程 |
| CORS error | 跨域请求被阻止 | 配置 Koa CORS 中间件 |
| 401 Unauthorized | API key 失效 | 检查 API key 配置 |
| 429 Too Many Requests | 触发 rate limit | 添加请求节流 |
🔬 日志分析报告
━━━ 摘要 ━━━
发现: X 个错误, Y 个警告
来源: [Main Process] / [Renderer] / [MCP] / [多来源]
严重度: 严重 / 高 / 中 / 低
━━━ 错误详情 ━━━
❌ [ERR-001] <错误标题>
时间: <timestamp>
来源: <Main/Renderer/MCP>
日志:
<相关日志行>
根因: <解释>
修复:
1. <具体步骤>
2. <具体步骤>
文件: <涉及的源码路径>
⚠️ [WARN-001] <警告标题>
...
━━━ 事件时间线 ━━━
<time> [Main] MCP server starting...
<time> [Main] Spawning process: /usr/local/bin/node
<time> [Main] ❌ IPC timeout for 'mcp:connect'
<time> [Renderer] Error displayed to user
━━━ 修复建议 ━━━
1. 立即修复: <当前必须处理的>
2. 防御加固: <防止复发的改进>
3. 补充诊断: <需要增加的日志以便后续排查>
console.log 语句来缩小范围tools
专业多语言翻译,支持中英日韩等语言互译
development
This skill should be used when the user asks to "审查 PR", "review PR", "review pull request", "代码审查", "review changes", "检查变更", "看看改了什么", "审查代码", "check my changes", "review diff", or when the user wants a project-specific code review of their pending changes focusing on architecture compliance, standards, and security.
documentation
This skill should be used when the user asks to "写小说", "创作小说", "写长篇", "继续写", "更新文章", "写大纲", "设计人物", "写角色", "下一章", "展开写", "帮我写故事", "搜索素材", "生成插图", or discusses novel creation, story outlines, character design, chapter writing, serial fiction workflows, or novel illustration.
content-media
This skill should be used when the user asks to "下载图标", "搜索图标", "iconfont", "download icon", "search icon", "找个图标", or when the user needs to search and download SVG icons from iconfont.cn.