When to use
Use this skill when you need deep Node.js internals expertise, including:
- C++ addon development
- V8 engine debugging
- libuv event loop issues
- Build system problems
- Compilation failures
- Performance optimization at the engine level
- Understanding Node.js core architecture
- Writing or reviewing
nodejs/node commits and pull request descriptions
How to use
Read individual rule files for detailed explanations and code examples:
V8 Engine
- rules/v8-garbage-collection.md - Scavenger, Mark-Sweep, Mark-Compact, generational GC
- rules/v8-hidden-classes.md - Hidden classes, inline caching, optimization
- rules/v8-jit-compilation.md - TurboFan, optimization/deoptimization patterns
libuv
- rules/libuv-event-loop.md - Event loop phases, timers, I/O, idle, check, close
- rules/libuv-thread-pool.md - Thread pool size, blocking operations, UV_THREADPOOL_SIZE
- rules/libuv-async-io.md - Async I/O patterns, handles, requests
Native Addons
- rules/napi.md - N-API development, ABI stability, async workers
- rules/node-addon-api.md - C++ wrapper patterns, best practices
- rules/native-memory.md - Buffer handling, external memory, prevent leaks
Core Modules Internals
- rules/streams-internals.md - How Node.js streams work at C++ level
- rules/net-internals.md - TCP/UDP implementation, socket handling
- rules/fs-internals.md - libuv fs operations, sync vs async
- rules/crypto-internals.md - OpenSSL integration, performance considerations
- rules/child-process-internals.md - IPC, spawn, fork implementation
- rules/worker-threads-internals.md - SharedArrayBuffer, Atomics, MessageChannel
JavaScript Internals
- rules/primordials.md - Using primordials to prevent prototype pollution (required for
lib/internal/)
Build & Contributing
- rules/build-and-test-workflow.md - The edit-build-lint-test cycle (start here)
- rules/configure.md -
./configure flags for debug builds, ASan, Ninja, etc.
- rules/build-system.md - gyp, ninja, make, cross-platform compilation
- rules/cli-options.md - Adding CLI options and gating experimental modules
- rules/contributing.md - How to contribute to Node.js core, the process
- rules/commit-messages.md - Node.js commit style derived from 2024-2025 history and current requirements
- rules/pull-request-descriptions.md - Node.js PR title/body style derived from merged 2024-2025 PRs
- rules/reviewing-prs.md - Reviewing PRs for correctness, clarity, and contribution quality
Documentation
- rules/documentation.md - Updating doc/api/*.md files: structure, link ordering, error docs, code example constraints
Debugging & Profiling
- rules/debugging-native.md - gdb, lldb, debugging C++ addons
- rules/profiling-v8.md - --prof, --trace-opt, --trace-deopt, flame graphs
- rules/memory-debugging.md - Heap snapshots, memory leak detection
Instructions
Node.js contribution writing
When drafting a nodejs/node commit or pull request, read
rules/commit-messages.md and
rules/pull-request-descriptions.md.
Use terse subsystem-prefixed titles and plain, matter-of-fact prose. Lead with
concrete behavior, explain the reason for the change, and omit hype, canned
headings, file-by-file narration, and unsupported claims. Include the
contributor's DCO sign-off.
MANDATORY: Rebuild before testing
Node.js embeds lib/ JavaScript files into the binary at compile time via
js2c. After ANY change to src/ or lib/, you MUST rebuild before
running tests. Without a rebuild, tests run against stale code and results
are meaningless.
edit src/ or lib/ → make -j$(nproc) → make lint → then test
Never skip the rebuild step. Never run ./node test/... after editing
without building first.
Before starting work, ask the user about their build configuration
(Make vs Ninja, debug vs release, what configure flags they use). Do not
assume a specific setup. Most of the time, ./configure has already been
run and only make -j$(nproc) is needed to rebuild.
See rules/build-and-test-workflow.md
for the full workflow including configure flags, lint targets, and test
commands.
Core knowledge domains
Apply deep knowledge of Node.js internals across these domains:
- Core architecture: Node.js core modules and their C++ implementations, V8 GC and JIT, libuv event loop mechanics, thread pool behavior, startup/module-loading lifecycle
- Native development: N-API, node-addon-api, and NAN addon development; V8 C++ API handle management; memory safety; native debugging with gdb/lldb
- Build systems: node-gyp, gyp, ninja, make; cross-platform compilation; linker errors; dependency issues; platform-specific considerations (Windows, macOS, Linux, embedded)
- Performance & debugging: Event loop profiling, memory leak detection in JS and native code, CPU flame graphs, V8 optimization/deoptimization tracing
Quick-reference debugging commands
V8 optimization tracing:
node --trace-opt --trace-deopt script.js
# Checkpoint: confirm no unexpected deoptimization warnings before proceeding to profiling
node --prof script.js && node --prof-process isolate-*.log > processed.txt
Event loop lag detection:
node --trace-event-categories v8,node,node.async_hooks script.js
Native addon debugging (gdb):
gdb --args node --napi-modules ./build/Release/addon.node
# Inside gdb:
run
bt # backtrace on crash
# Checkpoint: verify backtrace shows the expected call site before applying a fix
Heap snapshot for memory leaks:
node --inspect script.js # then open chrome://inspect, take heap snapshot
# Checkpoint: compare two consecutive heap snapshots to confirm leak growth before and after the fix; run valgrind --leak-check=full node addon_test.js to confirm no native leaks remain
Node.js-specific diagnostic decision trees
Segfault / crash in native addon:
- Is the crash reproducible with
node --napi-modules? → Run gdb, capture bt
- Does
bt point to a V8 handle scope issue? → Check HandleScope / EscapableHandleScope usage in the addon
- Does it point to a libuv callback? → Inspect async handle lifetime and
uv_close() sequencing
- No clear C++ frame? → Check for JS-side type mismatches passed into the native binding
V8 deoptimization / performance regression:
- Run
--trace-opt --trace-deopt → identify the deoptimized function and reason (e.g., "not a Smi", "wrong map")
- Checkpoint: confirm the same function deoptimizes consistently across runs
- Inspect hidden class transitions (
--trace-ic) and fix property addition order or type inconsistencies
- Re-run
--trace-opt to confirm the function is now optimized
Build failure (node-gyp / binding.gyp):
- Is it a missing header? → Verify
include_dirs in binding.gyp and Node.js header installation
- Is it a linker error? → Check
libraries and link_settings entries; confirm ABI compatibility
- Is it platform-specific? → Consult
rules/build-system.md for Windows/macOS/Linux differences
Always consider both JavaScript-level and native-level causes, explain performance implications and trade-offs, and indicate the stability status of any experimental features discussed. Code examples should demonstrate Node.js internals patterns and be production-ready, accounting for edge cases typical developers might miss.
1---2name: nodejs-core3description: Contributes to and debugs Node.js core, including nodejs/node commit and PR tone, contribution workflows, native crashes, V8 performance, node-gyp builds, N-API bindings, and libuv issues. Use when drafting or reviewing a Node.js core commit or pull request, working in nodejs/node, or diagnosing C++ addons, binding.gyp failures, segfaults, native leaks, V8 deoptimizations, and event-loop internals.4---5
6## When to use
7
8Use this skill when you need deep Node.js internals expertise, including:
9- C++ addon development
10- V8 engine debugging
11- libuv event loop issues
12- Build system problems
13- Compilation failures
14- Performance optimization at the engine level
15- Understanding Node.js core architecture
16- Writing or reviewing `nodejs/node` commits and pull request descriptions
17
18## How to use
19
20Read individual rule files for detailed explanations and code examples:
21
22### V8 Engine
23
24- [rules/v8-garbage-collection.md](rules/v8-garbage-collection.md) - Scavenger, Mark-Sweep, Mark-Compact, generational GC
25- [rules/v8-hidden-classes.md](rules/v8-hidden-classes.md) - Hidden classes, inline caching, optimization
26- [rules/v8-jit-compilation.md](rules/v8-jit-compilation.md) - TurboFan, optimization/deoptimization patterns
27
28### libuv
29
30- [rules/libuv-event-loop.md](rules/libuv-event-loop.md) - Event loop phases, timers, I/O, idle, check, close
31- [rules/libuv-thread-pool.md](rules/libuv-thread-pool.md) - Thread pool size, blocking operations, UV_THREADPOOL_SIZE
32- [rules/libuv-async-io.md](rules/libuv-async-io.md) - Async I/O patterns, handles, requests
33
34### Native Addons
35
36- [rules/napi.md](rules/napi.md) - N-API development, ABI stability, async workers
37- [rules/node-addon-api.md](rules/node-addon-api.md) - C++ wrapper patterns, best practices
38- [rules/native-memory.md](rules/native-memory.md) - Buffer handling, external memory, prevent leaks
39
40### Core Modules Internals
41
42- [rules/streams-internals.md](rules/streams-internals.md) - How Node.js streams work at C++ level
43- [rules/net-internals.md](rules/net-internals.md) - TCP/UDP implementation, socket handling
44- [rules/fs-internals.md](rules/fs-internals.md) - libuv fs operations, sync vs async
45- [rules/crypto-internals.md](rules/crypto-internals.md) - OpenSSL integration, performance considerations
46- [rules/child-process-internals.md](rules/child-process-internals.md) - IPC, spawn, fork implementation
47- [rules/worker-threads-internals.md](rules/worker-threads-internals.md) - SharedArrayBuffer, Atomics, MessageChannel
48
49### JavaScript Internals
50
51- [rules/primordials.md](rules/primordials.md) - **Using primordials to prevent prototype pollution (required for `lib/internal/`)**
52
53### Build & Contributing
54
55- [rules/build-and-test-workflow.md](rules/build-and-test-workflow.md) - **The edit-build-lint-test cycle (start here)**
56- [rules/configure.md](rules/configure.md) - `./configure` flags for debug builds, ASan, Ninja, etc.
57- [rules/build-system.md](rules/build-system.md) - gyp, ninja, make, cross-platform compilation
58- [rules/cli-options.md](rules/cli-options.md) - Adding CLI options and gating experimental modules
59- [rules/contributing.md](rules/contributing.md) - How to contribute to Node.js core, the process
60- [rules/commit-messages.md](rules/commit-messages.md) - Node.js commit style derived from 2024-2025 history and current requirements
61- [rules/pull-request-descriptions.md](rules/pull-request-descriptions.md) - Node.js PR title/body style derived from merged 2024-2025 PRs
62- [rules/reviewing-prs.md](rules/reviewing-prs.md) - Reviewing PRs for correctness, clarity, and contribution quality
63
64### Documentation
65
66- [rules/documentation.md](rules/documentation.md) - **Updating doc/api/*.md files: structure, link ordering, error docs, code example constraints**
67
68### Debugging & Profiling
69
70- [rules/debugging-native.md](rules/debugging-native.md) - gdb, lldb, debugging C++ addons
71- [rules/profiling-v8.md](rules/profiling-v8.md) - --prof, --trace-opt, --trace-deopt, flame graphs
72- [rules/memory-debugging.md](rules/memory-debugging.md) - Heap snapshots, memory leak detection
73
74## Instructions
75
76### Node.js contribution writing
77
78When drafting a `nodejs/node` commit or pull request, read
79[rules/commit-messages.md](rules/commit-messages.md) and
80[rules/pull-request-descriptions.md](rules/pull-request-descriptions.md).
81Use terse subsystem-prefixed titles and plain, matter-of-fact prose. Lead with
82concrete behavior, explain the reason for the change, and omit hype, canned
83headings, file-by-file narration, and unsupported claims. Include the
84contributor's DCO sign-off.
85
86### MANDATORY: Rebuild before testing
87
88Node.js embeds `lib/` JavaScript files into the binary at compile time via
89`js2c`. **After ANY change to `src/` or `lib/`, you MUST rebuild before
90running tests.** Without a rebuild, tests run against stale code and results
91are meaningless.
92
93```
94edit src/ or lib/ → make -j$(nproc) → make lint → then test
95```
96
97Never skip the rebuild step. Never run `./node test/...` after editing
98without building first.
99
100Before starting work, **ask the user** about their build configuration
101(Make vs Ninja, debug vs release, what configure flags they use). Do not
102assume a specific setup. Most of the time, `./configure` has already been
103run and only `make -j$(nproc)` is needed to rebuild.
104
105See [rules/build-and-test-workflow.md](rules/build-and-test-workflow.md)
106for the full workflow including configure flags, lint targets, and test
107commands.
108
109### Core knowledge domains
110
111Apply deep knowledge of Node.js internals across these domains:
112
113- **Core architecture**: Node.js core modules and their C++ implementations, V8 GC and JIT, libuv event loop mechanics, thread pool behavior, startup/module-loading lifecycle
114- **Native development**: N-API, node-addon-api, and NAN addon development; V8 C++ API handle management; memory safety; native debugging with gdb/lldb
115- **Build systems**: node-gyp, gyp, ninja, make; cross-platform compilation; linker errors; dependency issues; platform-specific considerations (Windows, macOS, Linux, embedded)
116- **Performance & debugging**: Event loop profiling, memory leak detection in JS and native code, CPU flame graphs, V8 optimization/deoptimization tracing
117
118### Quick-reference debugging commands
119
120**V8 optimization tracing:**
121```bash
122node --trace-opt --trace-deopt script.js
123# Checkpoint: confirm no unexpected deoptimization warnings before proceeding to profiling
124node --prof script.js && node --prof-process isolate-*.log > processed.txt
125```
126
127**Event loop lag detection:**
128```bash
129node --trace-event-categories v8,node,node.async_hooks script.js
130```
131
132**Native addon debugging (gdb):**
133```bash
134gdb --args node --napi-modules ./build/Release/addon.node
135# Inside gdb:
136run
137bt # backtrace on crash
138# Checkpoint: verify backtrace shows the expected call site before applying a fix
139```
140
141**Heap snapshot for memory leaks:**
142```bash
143node --inspect script.js # then open chrome://inspect, take heap snapshot
144# Checkpoint: compare two consecutive heap snapshots to confirm leak growth before and after the fix; run valgrind --leak-check=full node addon_test.js to confirm no native leaks remain
145```
146
147### Node.js-specific diagnostic decision trees
148
149**Segfault / crash in native addon:**
1501. Is the crash reproducible with `node --napi-modules`? → Run `gdb`, capture `bt`
1512. Does `bt` point to a V8 handle scope issue? → Check `HandleScope` / `EscapableHandleScope` usage in the addon
1523. Does it point to a libuv callback? → Inspect async handle lifetime and `uv_close()` sequencing
1534. No clear C++ frame? → Check for JS-side type mismatches passed into the native binding
154
155**V8 deoptimization / performance regression:**
1561. Run `--trace-opt --trace-deopt` → identify the deoptimized function and reason (e.g., "not a Smi", "wrong map")
1572. Checkpoint: confirm the same function deoptimizes consistently across runs
1583. Inspect hidden class transitions (`--trace-ic`) and fix property addition order or type inconsistencies
1594. Re-run `--trace-opt` to confirm the function is now optimized
160
161**Build failure (node-gyp / binding.gyp):**
1621. Is it a missing header? → Verify `include_dirs` in `binding.gyp` and Node.js header installation
1632. Is it a linker error? → Check `libraries` and `link_settings` entries; confirm ABI compatibility
1643. Is it platform-specific? → Consult `rules/build-system.md` for Windows/macOS/Linux differences
165
166Always consider both JavaScript-level and native-level causes, explain performance implications and trade-offs, and indicate the stability status of any experimental features discussed. Code examples should demonstrate Node.js internals patterns and be production-ready, accounting for edge cases typical developers might miss.