Index of every page on this site: llms.txt
All skills
mcollina avatar

/nodejs-core

@c75d70d
by Matteo Collinamcollina/skills2k stars
146
Run it yourself

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.

Use this Skill: https://skilld.dev/gh/mcollina/skills/nodejs-core

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

rulesbuild-and-test-workflow.md

≈3.3k tokens on demand. Your agent reads this file only when SKILL.md points to it.

Build and Test Workflow

The mandatory edit → build → lint → test cycle for Node.js core development.

CRITICAL: You Must Rebuild After Every Code Change

Node.js embeds its JavaScript source files into the binary at compile time. Changes to files in lib/ or src/ are NOT picked up until you rebuild. This applies to both C++ (src/) and JavaScript (lib/) files.

edit src/ or lib/  →  make -j$(nproc)  →  then test

There are no exceptions. If you edit a file and run a test without rebuilding, you are testing the OLD code. The test results are meaningless.

The lib/ files are processed by tools/js2c.cc during the build and embedded as string constants in the binary. The running node binary does not read from the lib/ directory at runtime.

Fast JS-Only Iteration (Advanced)

If you are only changing lib/ files (no C++ changes), you can configure the build to load builtins from disk instead of the embedded copies:

./configure --node-builtin-modules-path "$(pwd)/lib"
make -j$(nproc)   # Must still build once with this flag

After this one-time build, changes to lib/ files take effect immediately without rebuilding. This does NOT work for src/ changes — those always require a rebuild.

When in doubt, rebuild. A rebuild of unchanged files is fast. Testing against stale code wastes far more time.

Ask the User About Their Build Setup

Before starting work on a Node.js core change, ask the user about their build configuration rather than assuming one. Key questions:

  • Has ./configure already been run? With what flags?
  • Are they using Make or Ninja?
  • Is this a debug or release build?

Most of the time, ./configure has already been run and you only need make -j$(nproc) to rebuild.

Build

make -j$(nproc)

This produces a ./node symlink pointing to out/Release/node.

For configure flags (debug builds, ASan, Ninja, etc.), see configure.md.

Rebuild After Errors

If a build fails partway through:

  • Fix the error
  • Run make -j$(nproc) again — it picks up where it left off
  • Only recompiles changed files and their dependents

If the build is completely broken:

make clean          # Remove object files, keep config
make -j$(nproc)     # Full rebuild

# Nuclear option — removes everything including config:
make distclean
./configure          # Must reconfigure (see configure.md for flags)
make -j$(nproc)

Lint

Run linting after your changes build successfully and before every commit. Node.js runs a Linters CI workflow on every non-draft pull request; linting locally first is what makes that workflow pass on the first attempt instead of costing a force-push and another CI cycle.

Note that on Unix make test runs no linters — a green test run says nothing about CI's lint jobs.

See pre-commit-lint.md for the full pre-commit gate, including the CI-job-to-command mapping and the checks make lint does not cover.

Full Lint

make lint

This runs JavaScript (ESLint), C++ (cpplint), addon docs, Markdown (remark), and YAML (yamllint). It does not run the Python linter, the shell linter, or the C++ formatter, all of which have their own CI jobs — see pre-commit-lint.md.

Targeted Lint Commands

Target What it checks
make lint All linters
make lint-js JavaScript with ESLint
make lint-js-fix JavaScript with ESLint --fix (auto-corrects)
make lint-cpp C++ with cpplint and checkimports
make lint-addon-docs C++ samples in the addon documentation
make lint-md Markdown with remark
make lint-py Python with ruff (needs make lint-py-build)
make lint-yaml YAML with yamllint (needs make lint-yaml-build)
tools/lint-sh.mjs . Shell scripts with shellcheck

Formatting C++ Code

After making C++ changes, format them with clang-format:

# First time only — install the clang-format tooling:
make format-cpp-build

# Format staged changes (default):
make format-cpp

# Format changes in the last commit:
CLANG_FORMAT_START=HEAD~1 make format-cpp

# What CI actually checks — every change on the branch:
CLANG_FORMAT_START="$(git merge-base HEAD upstream/main)" make format-cpp
git --no-pager diff --exit-code   # must be empty

make format-cpp uses git-clang-format with the repo's .clang-format config. It only formats the diff, not the entire codebase. Run it before committing C++ changes.

The default (CLANG_FORMAT_START=HEAD) covers staged changes only, while CI's format-cpp job formats from the merge base with the target branch and fails if any diff remains. Use the merge-base form above before pushing, or an unformatted earlier commit in the branch will fail CI despite a clean local run.

Formatting Markdown

make format-md

Formatting JavaScript

make lint-js-fix

ESLint with --fix handles JavaScript formatting. There is no separate format target for JS.

Test

The Full Test Cycle

# Build + all tests (recommended before pushing):
make test

make test does the following in order:

  1. Builds node (make all)
  2. Runs Python tool tests (make tooltest)
  3. Builds addon test fixtures (addons, N-API, Node-API, SQLite)
  4. Runs C++ tests (make cctest)
  5. Runs JavaScript test suites (make jstest)

Test Without Rebuilding Docs

make test-only

Same as make test but skips documentation build. Use this for faster iteration when you're not changing docs.

Running Specific Tests

Single test file (most common during development):

./node test/parallel/test-stream-transform.js

Via the test runner (honors skip/flaky annotations):

python3 tools/test.py parallel/test-stream-transform

All tests matching a subsystem name:

python3 tools/test.py stream     # Matches */test*-stream-*
python3 tools/test.py assert     # Matches */test*-assert-*

A whole suite:

python3 tools/test.py parallel
python3 tools/test.py sequential

Multiple suites:

python3 tools/test.py parallel sequential message

Test Runner Options (tools/test.py)

Option Default Purpose
-j N (all CPUs) Number of parallel test processes
-m, --mode MODE release release, debug, or debug,release
-t, --timeout SECS 120 Timeout per test
--shell PATH auto-detect Path to node binary
--node-args ARGS (none) Extra args passed to node
--flaky-tests ACTION run run, skip, dontcare, keep_retrying
-v, --verbose off Verbose output
--repeat N 1 Repeat tests N times

Specialized Test Targets

Target Purpose
make jstest JS test suites + native addon suites only
make cctest C++ gtest suite only
make test-ci CI mode (JUnit XML + TAP output)
make test-internet Tests requiring network access
make test-valgrind Run tests under Valgrind
make test-addons Native addon tests
make test-node-api Node-API tests
make test-wpt Web Platform Tests
make test-v8 V8 test suite
make test-doc Documentation tests + Markdown lint

Filtering C++ Tests

# Run all C++ tests:
make cctest

# Filter to specific test(s):
out/Release/cctest --gtest_filter="*EnvironmentTest*"

# List all available C++ tests:
make list-gtests

Typical Development Workflow

For a JavaScript Change (lib/)

# 1. Make your changes to lib/
$EDITOR lib/internal/streams/transform.js

# 2. Rebuild (MANDATORY — JS is embedded in the binary)
make -j$(nproc)

# 3. Lint JavaScript (before committing, not after)
make lint-js

# 4. Run the relevant test(s)
./node test/parallel/test-stream-transform.js

# 5. Commit only once lint is clean, then validate the message
git add -A && git commit -s
npx core-validate-commit --no-validate-metadata HEAD

# 6. Before pushing, run broader tests
make test-only

For a C++ Change (src/)

# 1. Make your changes to src/
$EDITOR src/node_options.cc

# 2. Rebuild (MANDATORY)
make -j$(nproc)

# 3. Format C++ the way CI does — from the merge base, not just staged changes
CLANG_FORMAT_START="$(git merge-base HEAD upstream/main)" make format-cpp
git --no-pager diff --exit-code

# 4. Lint C++
make lint-cpp

# 5. Run the relevant test(s)
./node test/parallel/test-cli-options.js

# 6. Run C++ tests if you touched testable C++
make cctest

# 7. Commit only once format and lint are clean, then validate the message
git add -A && git commit -s
npx core-validate-commit --no-validate-metadata HEAD

# 8. Run broader tests
make test-only

For a Mixed Change (src/ + lib/ + doc/)

# 1. Make all changes
$EDITOR src/node_options.h src/node_options.cc
$EDITOR lib/internal/process/pre_execution.js
$EDITOR doc/api/cli.md

# 2. Rebuild (MANDATORY)
make -j$(nproc)

# 3. Format and lint
CLANG_FORMAT_START="$(git merge-base HEAD upstream/main)" make format-cpp
git --no-pager diff --exit-code
make lint

# 4. Run targeted tests
./node test/parallel/test-your-feature.js

# 5. Commit only once format and lint are clean, then validate the message
git add -A && git commit -s
npx core-validate-commit --no-validate-metadata HEAD

# 6. Full test run
make test

Common Mistakes

Testing without rebuilding

# WRONG — tests the old binary, not your changes:
$EDITOR lib/internal/streams/transform.js
./node test/parallel/test-stream-transform.js    # ← STALE CODE

# CORRECT:
$EDITOR lib/internal/streams/transform.js
make -j$(nproc)                                   # ← REBUILD FIRST
./node test/parallel/test-stream-transform.js

Committing without linting

# WRONG — the Linters CI job fails, costing a force-push and a new CI cycle:
$EDITOR lib/internal/streams/transform.js
make -j$(nproc)
git commit -s -am "stream: ..."

# CORRECT:
$EDITOR lib/internal/streams/transform.js
make -j$(nproc)
make lint                                         # ← gate the commit
git commit -s -am "stream: ..."
npx core-validate-commit --no-validate-metadata HEAD

make test does not run linters on Unix, so a green test run is not a substitute. See pre-commit-lint.md.

Forgetting to format C++ before committing

# The CI will reject unformatted C++ code.
# Always run after C++ changes, before committing:
make format-cpp-build   # first time only

# Use the merge-base form: bare `make format-cpp` only covers staged
# changes, while CI formats the whole branch and fails on any diff.
CLANG_FORMAT_START="$(git merge-base HEAD upstream/main)" make format-cpp
git --no-pager diff --exit-code

Running make test without make first

make test includes a build step (all), so it will rebuild automatically. But make test-only does too. The only case where you'd test stale code is running ./node test/... directly without rebuilding first.

Confusing make and ninja after --ninja

If you configured with --ninja, you still use make for all higher-level targets. The Makefile invokes Ninja internally for the compilation step.

# Both are fine after ./configure --ninja:
make -j$(nproc)
ninja -C out/Release

# All higher-level targets still use make:
make test        # ✓ works
make lint        # ✓ works
make format-cpp  # ✓ works

References

  • Build instructions: BUILDING.md in the Node.js repo
  • Makefile: Makefile in the repo root
  • Test runner: tools/test.py
  • Configure: configure.py

Source: SKILL.md on GitHub

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

1 alert2mo5 checks · Risk SAFE
  • Gen Agent Trust Hub2mo

    The skill provides comprehensive guidance, documentation, and best practices for developing, building, testing, and debugging Node.js core and its native C++ addons. It contains no security risks, malicious code, or prompt injections.

  • Socket2mo

    No alerts

  • Snyk2mo

    Risk: LOW · No issues

  • Runlayer8mo

    13/23 files flagged

  • ZeroLeaks7mo

    Score: 93/100 · 2 sections analyzed

Signed by skilld at c75d70d. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub last month.

Activeupdated 4 months ago
Other metadata
metadata
{
  "tags": "nodejs, nodejs-core, contributing, commit-message, pull-request, v8, libuv, cpp, native-addons, performance, debugging, internals"
}

README badge

README badge for mcollina/skills/nodejs-core