node-inspect-debugger
它能做什么
该技能教智能体如何使用内置调试器及相关工具,查找 Node.js 程序中的缺陷。适用于遇到难以找到的问题的开发者,例如程序卡死、测试不稳定或内存问题。
适用场景
- ✓当 Node.js 程序卡死或行为异常,而原因不明确时。
- ✓当测试不稳定,你需要在失败的确切位置暂停时。
- ✓当你需要内存快照或 CPU 分析,以找出 Node.js 应用中缓慢或泄漏的部分时。
技能链接
https://github.com/EKKOLearnAI/ekko-studio/blob/main/packages/ekko-agent/skills/node-inspect-debugger/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“我的 Node.js 脚本有时会卡住。请帮我在正确的行暂停它,并找出原因。”
每周 5 个新技能,1 分钟读完。
工作原理
智能体会使用 Node 内置的检查器启动程序,设置断点,并在每次暂停时检查变量值。对于脚本化的检查,它也可以通过本地端口连接到检查器。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Node Inspect Debugger
Use when Node.js debugging requires hidden locals, async hangs, flaky tests, child processes, startup races, memory analysis, or CPU profiling.
Default to node inspect first. Use Chrome DevTools Protocol only for scripted breakpoints, automated state capture, heap snapshots, or CPU profiles.
Quick start
node inspect path/to/script.js
node --inspect-brk --import tsx path/to/script.ts
kill -SIGUSR1 <pid>
node inspect -p <pid>
curl -s http://127.0.0.1:9229/json/list | jq
For a test runner such as Vitest, debug one file with one worker and avoid worker pools while stepping.
Debugger REPL
- Continue and step:
cont,next,step,out,pause. - Breakpoints:
sb('file.js', 42),sb(42),sb('functionName'),breakpoints,cb('file.js', 42). - Inspect:
bt,list(8),watch('expr'),exec expr. - Current scope: enter
repl, evaluate locals, then pressCtrl+Cto exit REPL mode. - Exit safely: use
contbefore quitting if the process should keep running; otherwise usekill.
Safe setup
- Prefer
127.0.0.1inspector binds. Do not expose--inspect=0.0.0.0unless the network is isolated. - Use
--enable-source-mapswhen TypeScript source breakpoints need it. NODE_OPTIONS=--inspect-brkcan propagate the inspector to child processes, but each process needs a unique port.- For a long-lived service, confirm the PID and
/json/listtarget before attaching.
Programmatic CDP
Install temporary tooling outside the project unless it is already a dependency:
mkdir -p /tmp/cdp-tools
npm --prefix /tmp/cdp-tools install chrome-remote-interface
NODE_PATH=/tmp/cdp-tools/node_modules node /tmp/cdp-debug.cjs
Minimal driver:
const CDP = require("chrome-remote-interface");
(async () => {
const client = await CDP({ port: 9229 });
const { Debugger, Runtime } = client;
Debugger.paused(async ({ callFrames, reason }) => {
const top = callFrames[0];
console.log("paused", reason, top.url, top.location.lineNumber + 1);
const { result } = await Debugger.evaluateOnCallFrame({
callFrameId: top.callFrameId,
expression: "JSON.stringify({ pid: process.pid })",
});
console.log(result.value ?? result.description);
await Debugger.resume();
});
await Runtime.enable();
await Debugger.enable();
await Debugger.setBreakpointByUrl({ urlRegex: ".*target\\.js$", lineNumber: 41 });
await Runtime.runIfWaitingForDebugger();
})();
Profiles
- CPU: enable
Profiler, start, wait, stop, write a.cpuprofile, then open it in Chrome DevTools. - Heap: enable
HeapProfiler, collectaddHeapSnapshotChunk, calltakeHeapSnapshot, then write a.heapsnapshot.
Pitfalls
--inspectdoes not pause; use--inspect-brkwhen startup code matters.- Port
9229is the default; use--inspect=0or a unique port for parallel targets. - If a breakpoint misses, confirm the path, source maps, and whether execution already passed the line.
- A process that appears frozen after detach may still be paused in the debugger.
常见问题
在网络上让调试器保持开启安全吗?
该技能建议把检查器绑定到 127.0.0.1,并避免将其暴露给所有网络地址。
它支持 TypeScript 吗?
支持。配合 source map,断点可以指向 TypeScript 源代码。
它能调试子进程吗?
能,但每个进程都需要自己的端口。
详情
作者的原始描述
Debug Node.js with node inspect, inspector attach, breakpoints, Chrome DevTools Protocol, heap snapshots, and CPU profiles.
repo: EKKOLearnAI/ekko-studio
热度
- GitHub 星标
- 12k
- 排名
- #11570
- 许可证
- —
- 更新时间
- 2026/11/2
评论
- …
同一仓库的更多技能
1password
12k帮你的智能体使用 1Password CLI 为命令和配置文件获取机密信息,同时不在聊天、日志或已保存的文件中显示这些信息。
apple-notes
12k帮你的智能体在 Mac 上使用 memo 命令行工具创建、搜索、阅读、编辑、移动或删除 Apple 备忘录。
apple-reminders
12k帮你的智能体在 Mac 上使用 remindctl 工具列出、创建、编辑、完成或删除 Apple 提醒事项及提醒列表。
document-to-action-items
12k帮你的智能体把文档、会议记录或一组笔记,整理成一张清晰的任务、负责人、截止日期和决定的表格。