electron-debug-skill 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "electron-debug-skill",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "type": "module",
5
5
  "description": "Claude Code Skill for debugging Electron applications using Chrome DevTools Protocol (CDP)",
6
6
  "main": "dist/index.js",
@@ -0,0 +1,339 @@
1
+ ---
2
+ name: electron-debug
3
+ description: |
4
+ Electron 应用调试技能,调试 Electron 应用的完整 CDP (Chrome DevTools Protocol) 工具。
5
+ Use this skill whenever the user wants to:
6
+ - Debug an Electron application
7
+ - Inspect DOM elements, console logs, or network requests in Electron
8
+ - Click elements or execute JavaScript in an Electron renderer
9
+ - Take screenshots of an Electron window
10
+ - Diagnose issues with Electron apps (button clicks not working, page loads slowly, data not displaying)
11
+ - Connect to a running Electron app via Chrome DevTools Protocol
12
+ - Test Electron app interactions programmatically
13
+
14
+ This skill is NOT for debugging web pages in regular browsers — use Chrome DevTools directly for that.
15
+
16
+ Trigger phrases include: "debug Electron", "Electron button click", "Electron console", "Electron network", "Electron screenshot", "test Electron", "Electron diagnose"
17
+ ---
18
+
19
+ # electron-debug
20
+
21
+ Electron 应用调试技能,支持 Chrome DevTools Protocol (CDP) 完整调试能力。
22
+
23
+ ## 中文入口
24
+
25
+ **什么时候用这个技能?**
26
+ - 调试 Electron 应用
27
+ - 帮朋友/自己排查"按钮点了没反应"的问题
28
+ - 看控制台有没有报错
29
+ - 抓包看网络请求
30
+ - 自动点页面上的按钮/输入框
31
+ - 截图看看页面长什么样
32
+ - AI 自动诊断问题
33
+
34
+ **使用流程:**
35
+ 1. 先启动 Electron: `electron . --remote-debugging-port=9333`
36
+ 2. 首次连接:`/electron-debug connect --electron-port 9333`
37
+ 3. 后续所有命令直接使用,无需重复连接
38
+ 4. 调试完成后断开:`/electron-debug disconnect`
39
+
40
+ **常用场景:**
41
+ - "debug Electron" → 自动连接调试
42
+ - "Electron 按钮没反应" → 自动点击+诊断
43
+ - "Electron 控制台报错" → 查看 console 错误
44
+ - "Electron 网络请求" → 抓包分析
45
+ - "Electron 截图" → 看看页面啥样
46
+ - "测试 Electron" → 自动化操作测试
47
+
48
+ ## 连接管理
49
+
50
+ ```bash
51
+ # 启动 daemon 并连接到 Electron (推荐)
52
+ /electron-debug connect --electron-port 9333
53
+
54
+ # 查看连接状态
55
+ /electron-debug status
56
+
57
+ # 断开连接并停止 daemon
58
+ /electron-debug disconnect
59
+ ```
60
+
61
+ ## Daemon 管理
62
+
63
+ ```bash
64
+ # 启动 daemon 并连接
65
+ /electron-debug daemon start --electron-port 9333
66
+
67
+ # 查看 daemon 状态
68
+ /electron-debug daemon status
69
+
70
+ # 停止 daemon
71
+ /electron-debug daemon stop
72
+ ```
73
+
74
+ ## 页面操作
75
+
76
+ ```bash
77
+ # 列出所有可调试页面
78
+ /electron-debug list-pages
79
+
80
+ # 切换到其他页面
81
+ /electron-debug switch-page --id <pageId>
82
+
83
+ # 截图 (显示 base64)
84
+ /electron-debug screenshot
85
+
86
+ # 截图并保存到文件
87
+ /electron-debug screenshot --path ./screenshot.png
88
+
89
+ # 全页面截图
90
+ /electron-debug screenshot --full
91
+ ```
92
+
93
+ ## 元素交互
94
+
95
+ ```bash
96
+ # 点击元素 (CSS 选择器)
97
+ /electron-debug click "#btn1"
98
+ /electron-debug click ".button-class"
99
+ /electron-debug click "button[type='submit']"
100
+ /electron-debug click "ul > li:first-child"
101
+ ```
102
+
103
+ ## 执行 JavaScript
104
+
105
+ ```bash
106
+ # 执行表达式
107
+ /electron-debug eval "document.title"
108
+ /electron-debug eval "navigator.userAgent"
109
+
110
+ /# 调用函数
111
+ /electron-debug eval "Math.random()"
112
+
113
+ /# 多行表达式
114
+ /electron-debug eval "(() => { return document.querySelector('#output').textContent; })()"
115
+ ```
116
+
117
+ ## DOM 查询
118
+
119
+ ```bash
120
+ # 查询元素
121
+ /electron-debug dom --selector "#my-element"
122
+ /electron-debug dom --selector ".class-name"
123
+
124
+ /# 查看元素属性
125
+ /electron-debug dom --selector "#my-input" --props "id,value,disabled"
126
+ ```
127
+
128
+ ## 控制台 (Console)
129
+
130
+ ```bash
131
+ # 查看控制台日志
132
+ /electron-debug console
133
+
134
+ # 过滤日志类型
135
+ /electron-debug console --type log
136
+ /electron-debug console --type warn
137
+ /electron-debug console --type error
138
+ /electron-debug console --type info
139
+
140
+ # 监听新的控制台消息
141
+ /electron-debug console --watch
142
+
143
+ # 清除控制台缓存
144
+ /electron-debug console --clear
145
+ ```
146
+
147
+ ## 网络 (Network)
148
+
149
+ ```bash
150
+ # 查看最近的网络请求
151
+ /electron-debug network
152
+
153
+ # 查看特定请求详情
154
+ /electron-debug network --request <requestId>
155
+
156
+ # 监听新的网络请求
157
+ /electron-debug network --watch
158
+
159
+ # 暂停/恢复网络监控
160
+ /electron-debug network --pause
161
+ /electron-debug network --resume
162
+ ```
163
+
164
+ ## 调试器 (Debugger)
165
+
166
+ ```bash
167
+ # 设置断点
168
+ /electron-debug breakpoint --url <file> --line <num>
169
+
170
+ # 列出所有断点
171
+ /electron-debug breakpoint --list
172
+
173
+ # 单步执行
174
+ /electron-debug step --action next
175
+ /electron-debug step --action in
176
+ /electron-debug step --action out
177
+ ```
178
+
179
+ ## 主进程调试
180
+
181
+ ```bash
182
+ # 连接主进程调试器 (需要 --inspect 启动)
183
+ /electron-debug main-connect --port 9229
184
+
185
+ # 查看主进程日志
186
+ /electron-debug main-logs
187
+ ```
188
+
189
+ ## AI 辅助诊断
190
+
191
+ ```bash
192
+ # 描述问题,自动收集调试信息
193
+ /electron-debug diagnose "按钮点击没反应"
194
+ /electron-debug diagnose "页面加载很慢"
195
+ /electron-debug diagnose "数据显示不正确"
196
+ /electron-debug diagnose "表单提交失败"
197
+ ```
198
+
199
+ ## 使用示例
200
+
201
+ ### 完整调试流程
202
+
203
+ ```bash
204
+ # 1. 连接 Electron
205
+ /electron-debug connect --electron-port 9333
206
+
207
+ # 2. 查看页面信息
208
+ /electron-debug list-pages
209
+ /electron-debug screenshot
210
+
211
+ # 3. 点击按钮并检查结果
212
+ /electron-debug click "#btn1"
213
+ /electron-debug eval "document.querySelector('#output').textContent"
214
+ /electron-debug console
215
+
216
+ # 4. AI 诊断问题
217
+ /electron-debug diagnose "点击按钮1后输出区域没有更新"
218
+
219
+ # 5. 断开连接
220
+ /electron-debug disconnect
221
+ ```
222
+
223
+ ### 连续操作测试
224
+
225
+ ```bash
226
+ # 连接
227
+ /electron-debug connect --electron-port 9333
228
+
229
+ # 点击按钮1
230
+ /electron-debug click "#btn1"
231
+ /electron-debug screenshot --path step1.png
232
+ /electron-debug eval "document.querySelector('#counter').textContent"
233
+
234
+ # 点击按钮2
235
+ /electron-debug click "#btn2"
236
+ /electron-debug screenshot --path step2.png
237
+ /electron-debug eval "document.querySelector('#counter').textContent"
238
+
239
+ # 点击按钮3
240
+ /electron-debug click "#btn3"
241
+ /electron-debug screenshot --path step3.png
242
+
243
+ # 查看所有控制台输出
244
+ /electron-debug console
245
+
246
+ # 断开
247
+ /electron-debug disconnect
248
+ ```
249
+
250
+ ## 日常使用示例(白话版)
251
+
252
+ ### 场景1:调试按钮点击无反应
253
+
254
+ **用户问 Claude:**
255
+ > "我点了 Electron App 里的提交按钮,但是页面啥反应都没有,帮我看看是咋回事"
256
+
257
+ **Claude 会自动调度 skill 工具:**
258
+ 1. 连接 Electron:`/electron-debug connect --electron-port 9333`
259
+ 2. 截图看页面状态
260
+ 3. 点击那个按钮
261
+ 4. 截图对比点击前后
262
+ 5. 查看控制台有没有报错
263
+ 6. 检查 DOM 看看按钮状态
264
+ 7. AI 诊断可能的原因
265
+
266
+ ---
267
+
268
+ ### 场景2:排查白屏问题
269
+
270
+ **用户问 Claude:**
271
+ > "Electron 应用打开后页面是白的,什么都没显示,帮我排查一下"
272
+
273
+ **Claude 会自动调度 skill 工具:**
274
+ 1. 连接 Electron
275
+ 2. 截图确认白屏
276
+ 3. 执行 JS 查看 `document.body.innerHTML` 看看 DOM 树
277
+ 4. 查看控制台错误
278
+ 5. 检查网络请求是否成功
279
+ 6. 给出诊断结果
280
+
281
+ ---
282
+
283
+ ### 场景3:分析页面加载性能
284
+
285
+ **用户问 Claude:**
286
+ > "这个 Electron 页面加载好慢,帮我看看是哪一步卡住了"
287
+
288
+ **Claude 会自动调度 skill 工具:**
289
+ 1. 连接 Electron
290
+ 2. 开启网络监控:`/electron-debug network --watch`
291
+ 3. 刷新页面
292
+ 4. 分析每个请求的耗时
293
+ 5. 找出最慢的请求
294
+ 6. 给出优化建议
295
+
296
+ ---
297
+
298
+ ### 场景4:检查表单验证问题
299
+
300
+ **用户问 Claude:**
301
+ > "表单填完了点提交没反应,是不是前端验证有问题?帮我看看"
302
+
303
+ **Claude 会自动调度 skill 工具:**
304
+ 1. 连接 Electron
305
+ 2. 执行 `form.checkValidity()` 检查表单验证状态
306
+ 3. 查看每个 input 的 validity 详情
307
+ 4. 查看控制台有没有验证错误日志
308
+ 5. 告诉你是哪个字段验证失败了
309
+
310
+ ---
311
+
312
+ ### 场景5:抓包看登录请求
313
+
314
+ **用户问 Claude:**
315
+ > "我想看看这个 Electron 应用登录的时候发了什么请求,帮我抓个包"
316
+
317
+ **Claude 会自动调度 skill 工具:**
318
+ 1. 连接 Electron
319
+ 2. 开启网络监控
320
+ 3. 用户在页面上操作登录
321
+ 4. 分析捕获的请求
322
+ 5. 显示登录 API 的请求参数和响应
323
+
324
+ ---
325
+
326
+ ### 场景6:自动化 UI 测试
327
+
328
+ **用户问 Claude:**
329
+ > "帮我测试一下购物车功能:连续把前5个商品都加入购物车,然后截图看看购物车页面"
330
+
331
+ **Claude 会自动调度 skill 工具:**
332
+ 1. 连接 Electron
333
+ 2. 点击第一个商品的"加入购物车"按钮
334
+ 3. 截图
335
+ 4. 点击第二个商品...
336
+ 5. 直到第五个
337
+ 6. 截图购物车页面
338
+ 7. 查看购物车数量 badge
339
+ 8. 断开连接