nodejs-best-practices

Review Node.js 22 projects for async, stream, and runtime best practices.

2|1|Updated Feb 24, 2026
One-click install
npx skills add https://github.com/mikemikula/AI-Coding-Summit-2026 --skill nodejs-best-practices-mikemikula
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: nodejs-best-practices
Source: https://github.com/mikemikula/AI-Coding-Summit-2026/tree/main/.cursor/skills/nodejs-best-practices
Command: npx skills add https://github.com/mikemikula/AI-Coding-Summit-2026 --skill nodejs-best-practices-mikemikula

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Deployers need consistent Node.js 22 code that avoids legacy callbacks, mismanaged streams, and runtime pitfalls, so harnessing modern async, error, and runtime APIs prevents crashes and unpredictable behavior.

Core Features & Use Cases

  • Module conventions: Enforce full ESM usage, prefer named exports, and rely on import.meta utilities instead of __dirname/__filename to keep modules maintainable.
  • Async and error handling: Favor async/await, Promise.all for parallel tasks, top-level handlers, and typed AppError classes so failures surface clearly.
  • Streams, env, performance, and security: Recommend stream.pipeline, Web Streams, strict environment validation, worker_threads for CPU work, structured logging, crypto utilities, and NODE_ENV=production to stay efficient and safe.
  • Use case: Review a Node.js server handler, script, or utility in this project to confirm it follows these async, stream, and config safeguards before deployment.

Quick Start

Ask the Node.js 22 best practices skill to evaluate the new server route for async, stream, and environment compliance before merging the change.

Frequently Asked Questions about nodejs-best-practices

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I handle async errors in Node.js 22 to avoid unhandled rejections?

Handle async errors in Node.js 22 by using async/await with top-level handlers and typed AppError classes so failures surface clearly. Favor Promise.all for parallel tasks to prevent unpredictable behavior and unhandled rejections.

What is the best way to manage streams in Node.js 22 to prevent memory leaks?

The best way to manage streams in Node.js 22 is using stream.pipeline and Web Streams APIs. This approach prevents callback spaghetti and ensures streams are properly cleaned up to avoid memory leaks and runtime crashes.

How do I migrate Node.js scripts from CommonJS to ESM modules?

Migrate Node.js scripts to ESM modules by enforcing full ESM usage with named exports and replacing __dirname or __filename with import.meta utilities. This keeps modules maintainable and aligned with modern Node 22 APIs.

Does Node.js 22 support worker threads for CPU-bound workloads?

Yes, Node.js 22 supports worker_threads for CPU-bound workloads. Using worker threads offloads heavy computation from the event loop to stay efficient and safe while preventing runtime bottlenecks in server code.

Why do I need NODE_ENV=production for secure Node.js deployments?

You need NODE_ENV=production for secure Node.js deployments to enable built-in crypto routines and structured environment validation. This requirement ensures deployments stay efficient and safe by enforcing runtime safeguards.