본문으로 건너뛰기
Skillpedia
일반 코딩394k · #67

node-inspect-debugger

하는 일

AI 에이전트가 Node.js 인스펙터로 코드를 멈추고, 변수를 살펴보고, 메모리와 CPU 프로파일을 캡처하도록 안내합니다. 일반 로그로는 드러나지 않는 버그를 찾아야 하는 개발자를 위한 스킬입니다.

사용하는 경우

  • ✓Node.js 프로그램이 멈추거나 충돌하거나, 실행할 때마다 다르게 동작할 때.
  • ✓Node.js 프로그램의 메모리 사용량이 계속 늘어나는 것 같을 때.
  • ✓코드를 특정 줄에서 멈추고 변수 값을 보고 싶을 때.

스킬 링크

https://github.com/openclaw/openclaw/blob/main/skills/node-inspect-debugger/SKILL.md

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/openclaw/openclaw/blob/main/skills/node-inspect-debugger/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“제 Node.js 스크립트가 몇 초 뒤에 멈춥니다. 실행을 멈추고 무엇이 막혀 있는지 보여 주세요.”

매주 새 스킬 5개. 읽는 데 1분.

작동 방식

스킬은 인스펙터와 함께 프로그램을 시작하고, 중단점을 설정한 뒤 상태를 살펴봅니다. 더 어려운 경우에는 힙이나 CPU 프로파일을 캡처하고 확인한 다음에 결론을 내립니다.

기술 내용 (원본 SKILL.md)

작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.

Node Inspect Debugger

Use for Node.js debugging that needs inspector access: hidden locals, async hangs, flaky tests, child processes, startup races, memory growth, or CPU hot paths.

Default to node inspect first. Use Chrome DevTools Protocol only when you need scripted breakpoints, automated state capture, heap snapshots, or CPU profiles.

Quick start

  • Pause on entry: node inspect path/to/script.js
  • TypeScript: node --inspect-brk --import tsx path/to/script.ts
  • Existing PID: kill -SIGUSR1 <pid> then node inspect -p <pid>
  • Inspect target list: curl -s http://127.0.0.1:9229/json/list | jq
  • OpenClaw CLI path: node --inspect-brk openclaw.mjs ...
  • OpenClaw test path: OPENCLAW_VITEST_MAX_WORKERS=1 node --inspect-brk scripts/run-vitest.mjs <file>

Debugger REPL

  • Continue/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: repl, then evaluate locals directly; Ctrl+C exits repl mode.
  • Exit safely: cont before quitting if the process should continue; otherwise kill.

OpenClaw tips

  • Prefer 127.0.0.1 inspector binds. Do not expose --inspect=0.0.0.0 unless the network is isolated.
  • For Vitest, debug one file with one worker. Avoid worker pools while stepping.
  • For TS source breakpoints, use --enable-source-maps when useful; node inspect can still show emitted paths.
  • For child processes, NODE_OPTIONS=--inspect-brk can propagate the inspector, but each child needs its own port.
  • For long-lived gateway or dev processes, attach by PID after confirming the target with /json/list.

Programmatic CDP

Install tooling outside the repo unless the project already depends on it:

mkdir -p /tmp/cdp-tools
npm --prefix /tmp/cdp-tools i 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 /tmp/profile.cpuprofile, open in Chrome DevTools.
  • Heap: enable HeapProfiler, collect addHeapSnapshotChunk, call takeHeapSnapshot, write /tmp/heap.heapsnapshot.

Pitfalls

  • --inspect does not pause; use --inspect-brk when setup must happen before code runs.
  • Default port is 9229; use --inspect=0 or a unique port for parallel targets.
  • If a breakpoint misses, confirm file path, source map behavior, and whether execution already passed the line.
  • If the process appears frozen after detaching, it may still be paused in the debugger.
자주 묻는 질문

디버거 명령을 알아야 하나요?

아닙니다. 스킬이 일반적인 명령을 대신 실행하고, 각 단계가 무엇을 보여 주는지 설명합니다.

네트워크에서 디버거를 열어도 안전한가요?

네트워크가 격리되어 있지 않다면 인스펙터를 127.0.0.1에 묶어 두세요. 노출하면 위험할 수 있습니다.

힙 스냅샷이란 무엇인가요?

특정 순간에 프로그램이 메모리에 담고 있는 내용을 찍은 그림으로, 해제되지 않는 메모리를 찾는 데 씁니다.

상세 정보

작성자의 원본 설명

Debug Node.js with node inspect, --inspect, breakpoints, CDP, heap, and CPU profiles.

repo: openclaw/openclaw

인기도

GitHub 스타
394k
순위
#67
라이선스
MIT
업데이트
2026. 11. 2.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬