nodejs-best-practices

Applies Node.js and TypeScript best practices for framework selection, async patterns, and error handling.

Updated Apr 4, 2026
One-click install
npx skills add https://github.com/juanjo-zurich/juarvis-v4 --skill nodejs-best-practices-juanjo-zurich
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: nodejs-best-practices
Source: https://github.com/juanjo-zurich/juarvis-v4/tree/main/plugins/languages/skills/nodejs-best-practices
Command: npx skills add https://github.com/juanjo-zurich/juarvis-v4 --skill nodejs-best-practices-juanjo-zurich

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Node.js and TypeScript projects often suffer from inconsistent framework choices, unvalidated environment variables, sequential async bottlenecks, and untyped error handling. This Skill provides concrete, opinionated guidance so backend code follows proven patterns from the start. ## Core Features & Use Cases - Framework Selection Guidance: Compares Fastify, NestJS, Hono, Next.js, and Commander by use case so you pick the right tool for APIs, microservices, CLIs, or full-stack apps. - Async & Error Patterns: Shows Promise.all/allSettled usage, AbortController timeouts, discriminated-union error types, and Result types to avoid try/catch sprawl. - Production Hardening: Covers strict tsconfig flags, Zod-based environment validation, structured logging with pino, security headers, rate limiting, and recommended npm scripts. - Use Case: When scaffolding a new Express or Fastify API, ask for the recommended project structure, tsconfig, and env validation to get a production-ready baseline immediately. ## Quick Start Ask the assistant to review your Node.js project structure and apply the recommended TypeScript, async, and error-handling best practices.

Frequently Asked Questions about nodejs-best-practices

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

FAQPage Schema
How do I choose between Fastify, NestJS, and Express for a Node.js API?▼

Fastify suits simple to medium REST APIs with built-in validation and better performance than Express. NestJS fits complex enterprise apps needing dependency injection and modules. Hono works for minimal edge-compatible microservices.

How to run parallel async operations in Node.js without sequential awaits?▼

Use Promise.all for independent operations that must all succeed, and Promise.allSettled when partial failure is acceptable. Avoid awaiting inside loops, which forces unnecessary sequential execution.

What TypeScript strict flags should I enable for backend projects?▼

Enable strict: true, noUncheckedIndexedAccess, and exactOptionalPropertyTypes. These catch undefined array access and distinguish optional properties from explicit undefined values at compile time.

How do I validate environment variables in Node.js?▼

Validate process.env at startup with a Zod schema defining types, defaults, and constraints for each variable. If validation fails, the process exits immediately with a clear message about what is missing.

Why should I avoid console.log in production Node.js apps?▼

console.log produces unstructured output that cannot be filtered or queried by log aggregation systems. Use pino for structured JSON logging with contextual fields like userId and action on every entry.

When should I use a Result type instead of try/catch in TypeScript?▼

Use a Result discriminated union for expected errors like validation failures, making error paths explicit in function signatures. Reserve try/catch for truly exceptional cases and unexpected failures.