nodejs-best-practices

Guides Node.js architecture decisions covering framework selection, async patterns, security, and testing.

28|1|Updated Mar 15, 2026
One-click install
npx skills add https://github.com/NauelG/astro-blocks --skill nodejs-best-practices-nauelg
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: nodejs-best-practices
Source: https://github.com/NauelG/astro-blocks/tree/main/.agents/skills/nodejs-best-practices
Command: npx skills add https://github.com/NauelG/astro-blocks --skill nodejs-best-practices-nauelg

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Node.js developers often default to familiar frameworks and patterns without considering whether they fit the project's deployment target, performance needs, or team context. This Skill provides decision-making principles for architecture, framework selection, async patterns, validation, security, and testing so choices are grounded in actual project requirements. ## Core Features & Use Cases - Framework Selection Guidance: Decision trees and comparison tables for Hono, Fastify, Express, and NestJS based on deployment target, cold start needs, and ecosystem maturity. - Architecture & Async Principles: Layered structure concepts (controller/service/repository), event loop awareness, and guidance on when to use async/await, Promise.all, or worker threads. - Security & Validation Checklists: Boundary validation strategy, library selection (Zod, Valibot, ArkType), HTTP status code selection, and a security checklist covering hashing, JWT, rate limiting, and secrets management. - Use Case: When starting a new API for a serverless deployment, use this Skill to evaluate whether Hono fits better than Express, plan the layered structure, and define the validation and error-handling strategy before writing code. ## Quick Start Ask the AI to help you choose a Node.js framework and architecture for your project, describing your deployment target and performance requirements.

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 Hono, Fastify, and Express for a Node.js API?▼

Choose based on deployment target and priorities: Hono for edge and serverless with fast cold starts, Fastify for high-performance APIs, and Express for legacy codebases or maximum ecosystem support. Also consider team familiarity and TypeScript requirements.

What validation library should I use in Node.js?▼

Zod is the default choice for TypeScript-first projects with type inference. Valibot offers a smaller bundle through tree-shaking, ArkType targets performance-critical cases, and Yup fits projects already using React form integrations.

Should I use ESM or CommonJS for a new Node.js project?▼

Use ESM (import/export) for new projects since it is the modern standard with better tree-shaking and async module loading. CommonJS remains appropriate for existing codebases or when specific dependencies require it.

When does async/await not help Node.js performance?▼

Async patterns help I/O-bound work like database queries and HTTP requests, but not CPU-bound tasks such as cryptography, image processing, or complex calculations. Offload CPU-intensive work to worker threads to avoid blocking the event loop.

What are common Node.js security mistakes to avoid?▼

Common mistakes include skipping input validation, concatenating SQL strings, hardcoding secrets, and trusting external API responses. Validate all inputs at boundaries, use parameterized queries, hash passwords with bcrypt or argon2, and store secrets in environment variables.