node-best-practices
Installation
SKILL.md
Node.js best practices
Use when writing server-side JS/TS, scripts, tooling, or SSR runtimes that execute on Node (e.g. Nitro output, build scripts).
Runtime and versions
- Declare
enginesinpackage.jsonand CI to match production; avoid “works on my machine” drift. - Prefer LTS Node for services; know ESM vs CJS boundaries in the repo (
"type": "module").
Configuration and secrets
- Never commit secrets; load from env or a secret manager; validate required vars at startup (Zod, t3-env, etc.).
- 12-factor config: one codebase, many environments via env, not branching logic per customer in code.
Errors and logging
- Use structured logging (JSON fields) in servers for searchability; include request id / correlation id when available.
- Differentiate operational errors (4xx) from bugs (5xx); don’t expose stack traces to clients in production.